A text classification method, device, computer equipment and storage medium
By combining multi-level analysis of text to be classified with memory network feature fusion, the problem of insufficient accuracy of existing text classification models in identifying clickbait texts is solved, achieving more efficient text classification results.
Patent Information
- Application Number
- CN202111481657.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2042-02-13
AI Technical Summary
Existing text classification models are not accurate enough in identifying anomalous text data, especially in effectively identifying clickbait news content that does not match the actual content.
A multi-level text analysis method is adopted, which analyzes different character sets of the text to be classified, combines memory network and feature fusion module, and uses reference text feature vectors to overcome subjective interpretation bias and improve classification accuracy.
By combining multi-level text analysis and memory networks, it is possible to more accurately identify and classify anomalous texts such as clickbait headlines, reduce manual costs, and improve the overall accuracy of text classification.
Smart Images

Figure CN114328913B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a text classification method and device, computer equipment and storage medium. BACKGROUND
[0002] In recent years, with the popularity of the use of media applications by users, various news data are uploaded to the network for sharing among users. Generally, the uploader sets a title for the news data to briefly summarize the news data, and the title can attract users to a certain extent.
[0003] However, in order to attract users to browse the uploaded media data to a greater extent to obtain traffic, some uploaders tend to set the title as content that can attract users more, and the content reflected by the title is often exaggerated and deviates from the real content of the news data, to maliciously attract users to click / play, which will lead to the fact that after the user is attracted by the title to click and watch, the content of the news data does not match the title.
[0004] For such abnormal news content or article text data, a text classification model can be used to automatically identify, such as a traditional machine learning model, a deep learning model and the like; the text is feature-extracted through the model, and the classification task is completed through the multi-dimensional text features obtained by the extraction. It is found in actual application that the analysis of abnormal text data by some common models is not accurate enough. SUMMARY
[0005] The embodiments of the present application provide a text classification method, device, computer equipment and storage medium, which can improve the accuracy of text classification.
[0006] In one aspect, the embodiments of the present application provide a text classification method, which comprises:
[0007] obtaining a text to be classified;
[0008] performing text analysis on a first character set included in the text to be classified to obtain a first vector corresponding to the text to be classified;
[0009] performing text analysis on a second character set included in the text to be classified to obtain a second vector corresponding to the text to be classified; the lengths of characters included in the first character set and the second character set are different;
[0010] performing analysis on the text to be classified according to a reference vector set to obtain an auxiliary vector corresponding to the text to be classified, wherein the reference vector set is obtained according to the text to be classified and a plurality of reference texts associated with the text to be classified;
[0011] performing a classification processing on the text to be classified based on the first vector, the second vector and the auxiliary vector, to obtain a target category to which the text to be classified belongs.
[0012] In one embodiment, the target category to which the text to be classified belongs is determined by performing a classification processing on the text to be classified by a text classification model, the text classification model comprising a first text processing module, a second text processing module and an auxiliary text processing module;
[0013] The first vector is obtained by analyzing a first character set included in the text to be classified by the first text processing module; the second vector is obtained by analyzing a second character set included in the text to be classified by the second text processing module; and the auxiliary vector is obtained by analyzing the text to be classified according to a reference vector set by the auxiliary text processing module.
[0014] In one embodiment, the auxiliary text processing module comprises an analysis submodule constructed based on a memory network and a feature fusion module, and the method further comprises:
[0015] calling the analysis submodule to perform a similarity analysis on a text feature vector of the text to be classified and a reference text feature vector corresponding to a reference text in a reference text set, to obtain a similarity analysis result;
[0016] obtaining a reference vector set comprising one or more reference vectors according to the similarity analysis result, each reference vector comprising a category label and a similarity score;
[0017] analyzing the text to be classified according to the reference vector set to obtain an auxiliary vector corresponding to the text to be classified, comprising:
[0018] calling the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector to obtain the auxiliary vector corresponding to the text to be classified.
[0019] In one embodiment, calling the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector to obtain the auxiliary vector corresponding to the text to be classified comprises: if there is a target reference vector in the reference vector set, adjusting a similarity score corresponding to the target reference vector to a target score, the target reference vector being a reference vector with a similarity score less than a similarity threshold; calling the feature fusion module to perform feature fusion on the category label and the target score included in the target reference vector, and on the category label and the similarity score included in the remaining reference vectors to obtain the auxiliary vector corresponding to the text to be classified; wherein the remaining reference vectors are the reference vectors in the reference vector set excluding the target reference vector.
[0020] In one embodiment, the analysis submodule includes a third text processing module and a memory network, the memory network stores reference text feature vectors corresponding to a reference text set, the reference text feature vectors corresponding to the reference text set are obtained by performing feature vector analysis on reference texts in the reference text set by a fourth text processing model, and the analysis submodule is called to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vectors corresponding to the reference text set to obtain a similarity analysis result, including:
[0021] The third text processing module is called to perform text processing on the text to be classified to obtain a text feature vector corresponding to the text to be classified;
[0022] The memory network is called to perform similarity calculation on the text feature vector and the reference text feature vectors corresponding to the reference text set to obtain a similarity score of the text feature vector and the reference text feature vectors.
[0023] In one embodiment, the number of reference text feature vectors is a plurality, and the reference vector set including one or more reference vectors is obtained according to the similarity analysis result, including:
[0024] A target reference text feature vector is determined according to the similarity score of the text feature vector of the text to be classified and each reference text feature vector, a reference vector corresponding to the target reference text feature vector is obtained according to the class label and the similarity score corresponding to the target reference text feature vector, and the reference vector corresponding to the target reference text feature vector is added to the reference vector set.
[0025] In one embodiment, the target reference text feature vector is determined according to the similarity score of the text feature vector of the text to be classified and each reference text feature vector, including:
[0026] The similarity scores of the text feature vector of the text to be classified and each reference text feature vector are arranged in descending order to obtain an arrangement result, and the reference text feature vectors corresponding to the first K similarity scores are determined from the arrangement result as target reference text feature vectors, and K is an integer greater than or equal to 1.
[0027] In one embodiment, the method further includes:
[0028] obtain a target training set, the target training set comprising a plurality of sample texts and a category label corresponding to each sample text; invoke an initial model to perform classification processing on each sample text to obtain a predicted category to which the sample text belongs; determine a model loss value according to the predicted category to which each sample text belongs and the corresponding category label; update model parameters of the initial model based on the model loss value to obtain a text classification model.
[0029] In one embodiment, the obtaining the target training set comprises:
[0030] obtain an initial training set, the initial training set comprising a plurality of initial training samples;
[0031] invoke a text screening model to perform classification processing on the initial training set to obtain a text category to which each initial training sample belongs and a category confidence;
[0032] determine a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence, and add the plurality of sample texts to the target training set.
[0033] In one embodiment, the text screening model outputs M text categories, the text category to which each initial training sample belongs belongs to any one of the M text categories, and M is an integer greater than or equal to 1.
[0034] In one embodiment, determining a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence comprises:
[0035] add each initial training sample to a sample set corresponding to the M text categories according to the text category to which each initial training sample belongs to obtain the sample set corresponding to the M text categories;
[0036] respectively screen initial training samples with a category confidence satisfying a category screening condition from each sample set corresponding to a text category;
[0037] add the screened initial training samples as sample texts.
[0038] In one aspect, an embodiment of the present application provides a text classification device, which comprises:
[0039] an obtaining unit configured to obtain a text to be classified;
[0040] a processing unit configured to perform text analysis on a first character set included in the text to be classified to obtain a first vector corresponding to the text to be classified;
[0041] The processing unit is further configured to perform text analysis on a second character set included in the text to be classified to obtain a second vector corresponding to the text to be classified; the first character set and the second character set include characters of different lengths.
[0042] The processing unit is further configured to analyze the text to be classified according to a reference vector set to obtain an auxiliary vector corresponding to the text to be classified, wherein the reference vector set is obtained according to the text to be classified and a plurality of reference texts associated with the text to be classified.
[0043] The processing unit is further configured to perform classification processing on the text to be classified based on the first vector, the second vector, and the auxiliary vector to obtain a target category to which the text to be classified belongs.
[0044] In one aspect, the application provides a computer device, which includes an input device, an output device, a processor, and a computer storage medium, wherein the processor and the computer storage medium are connected to each other, the computer storage medium is configured to store a computer program, and the processor is configured to invoke the computer program to execute the above-mentioned text classification method.
[0045] In one aspect, the application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the above-mentioned text classification method.
[0046] In one aspect, the application provides a computer program product or a computer program, which includes a computer program; the computer program is stored in a computer readable storage medium, and the computer program is executed by a processor of a computer device to execute the above-mentioned text classification method.
[0047] In the embodiments of the application, the text to be classified is obtained, then a first character set included in the text to be classified is analyzed to obtain a first vector corresponding to the text to be classified, and a second character set included in the text to be classified is analyzed to obtain a second vector corresponding to the text to be classified; then the text to be classified is analyzed according to a reference vector set corresponding to the text to be classified and a plurality of reference texts associated with the text to be classified to obtain an auxiliary vector corresponding to the text to be classified, and the text to be classified is classified based on the first vector, the second vector, and the auxiliary vector to obtain a target category to which the text to be classified belongs. The first vector and the second vector can obtain the full text information of the text to be classified, and the auxiliary vector can overcome the subjective understanding bias of the text to be classified, thereby improving the classification effect of the text to be classified from the overall scheme and improving the accuracy of text classification. BRIEF DESCRIPTION OF DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the accompanying drawings required by the embodiments or prior art description will be briefly introduced below. Obviously, the accompanying drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0049] Figure 1 is a flowchart of a text classification method provided by an embodiment of the present application;
[0050] Figure 2a is a schematic diagram of a text being a title party provided by an embodiment of the present application;
[0051] Figure 2b is an architecture diagram of a text classification model provided by an embodiment of the present application;
[0052] Figure 2c is an architecture diagram of another text classification model provided by an embodiment of the present application;
[0053] Figure 3 is a flowchart of another text classification method provided by an embodiment of the present application;
[0054] Figure 4 is a structural schematic diagram of an analysis submodule provided by an embodiment of the present application;
[0055] Figure 5a is a structural schematic diagram of a memory network provided by an embodiment of the present application;
[0056] Figure 5b is a structural schematic diagram of another memory network provided by an embodiment of the present application;
[0057] Figure 5c is a structural schematic diagram of still another memory network provided by an embodiment of the present application;
[0058] Figure 5d is a structural schematic diagram of still another memory network provided by an embodiment of the present application;
[0059] Figure 6a is an architecture diagram of text classification model training provided by an embodiment of the present application;
[0060] Figure 6b is a flowchart of model training provided by an embodiment of the present application;
[0061] Figure 7 is a schematic diagram of a model loss value reverse update analysis submodule provided by an embodiment of the present application;
[0062] Figure 8 is a structural schematic diagram of a text classification device provided by an embodiment of the present application;
[0063] Figure 9 is a structural schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0064] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0065] Artificial intelligence (AI) is to use a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, perceive environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machine has the functions of perception, reasoning and decision-making.
[0066] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software technologies. Artificial intelligence basic technologies generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.
[0067] Among them, machine learning is a multi-field interdisciplinary subject, involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It is to study how a computer simulates or implements human learning behavior to acquire new knowledge or skills, and reorganizes existing knowledge structure to continuously improve its own performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent, and its applications are widespread in various fields of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and inductive learning.
[0068] The text classification scheme provided by the embodiments of the present application relates to machine learning technology of artificial intelligence, and can be applied to news text classification (or news text title party identification), literature classification, magazine classification, etc. In the embodiments of the present application, on the one hand, the text classification scheme can perform text analysis on different length character sets included in the text to be classified, so as to obtain as much full text information of the text to be classified as possible, for example, the first character set in the text to be classified can be analyzed to obtain a first vector corresponding to the text to be classified, and the second character set in the text to be classified can be analyzed to obtain a second vector corresponding to the text to be classified. On the other hand, considering that each user has subjective understanding bias on the text to be classified, the embodiments of the present application further introduce a reference text set, obtain a plurality of reference texts associated with the text to be classified from the reference text set, and determine a reference vector set based on the reference text feature vectors of the plurality of reference texts and the text feature vector of the text to be classified, and perform auxiliary analysis on the text to be classified based on the reference vector set to obtain an auxiliary vector corresponding to the text to be classified, so as to overcome the problem of subjective understanding bias of the standard in low-quality content identification. Then, the first vector, the second vector and the auxiliary vector are used to process the text to be classified to obtain a target category to which the text to be classified belongs, so as to improve the accuracy of text classification.
[0069] In one embodiment, a text classification model can be pre-trained, which can be a model combined by a first text processing module, a second text processing module and an auxiliary text processing module. The first text processing module can complete the understanding of the text to be classified, for example, the first text processing module can be a bert model (a self-encoding language model); the second text processing module can be used to supplement the global information of the text, and the second text processing module can be a TextCNN (text convolutional neural network) model; the auxiliary text processing module can complete the search of the "reference text", retrieve a plurality of reference texts associated with the text to be classified from a large memory bank (or reference text set), obtain a retrieval result, process the reference text features included in the retrieval result to obtain a reference vector, and analyze the text to be classified based on the reference vector to obtain an auxiliary vector corresponding to the text to be classified; wherein the auxiliary text processing module can include an analysis submodule and a feature fusion module based on a memory network. The memory network can be used to store the reference text features corresponding to the reference text set, and the feature fusion module can be used to fuse the reference vectors in the reference vector set to obtain the auxiliary vector. The auxiliary text vector processing module can solve the problem of subjective understanding bias of the standard in low-quality content identification.
[0070] In one embodiment, the text classification model can be trained before being used. Since the sample data used to train the text classification model can have a class imbalance problem, which affects the classification ability of the text classification model after training, a pre-trained fine-grained model can be used to pre-screen the sample text. Pre-screening by the fine-grained model can solve the class imbalance problem and improve the annotation quality and efficiency. The fine-grained model only performs preliminary screening of abnormal texts such as sensationalist content. Then, the sample text is added with a class label, and the initial model is trained based on the sample text with the added class label to obtain the text classification model. In specific use, the first text processing module in the text classification model can be used to perform text analysis on a first character set included in the text to be classified to obtain a first vector, the second text processing module in the text classification model can be used to perform text analysis on a second character set included in the text to be classified to obtain a second vector, and the feature fusion module in the auxiliary text processing module in the text classification model can be used to perform feature fusion according to the class label and the similarity score included in the reference vector to obtain an auxiliary vector.
[0071] Through the above-provided text classification scheme, the embodiments of the present application have the following beneficial effects: innovatively using a memory network to construct an auxiliary text processing module in the model structure, avoiding the influence of low-quality standard understanding bias by using the memory of historical cases in the reference text set stored in the memory network, effectively solving the problem of inaccurate text classification, and respectively proposing technical methods such as fine-grained model pre-screening and feature fusion module in data screening and labeling and feature selection and fusion, thereby improving the accuracy of text classification as a whole. In the embodiments of the present application, the text classification model can integrate the Bert model, the TextCNN model, and the memory network. The TextCNN solves the problem of long news text, and the memory network solves the problem of subjective understanding bias. In the embodiments of the present application, data screening and labeling is also performed: pre-screening of the labeled data by using a pre-trained fine-grained model greatly improves the distribution balance problem of the training samples in the training set compared to directly labeling random data, thereby improving the annotation quality and efficiency, and the labeled data can also be used as a supplement to the existing training set, which can expand the training sample richness and improve the accuracy of the model. In the embodiments of the present application, feature fusion is also performed: the reference vectors in the reference vector set are fused by using the feature fusion module, which can improve the accuracy of the text classification model.
[0072] Based on the above-provided text classification scheme, the embodiments of the present application provide a text classification method, please refer to Figure 1The text classification method can be executed by a computer device, which can be a terminal device or a server. The terminal device can be a smartphone, a tablet computer, a notebook computer, a desktop computer, an AR / VR device, a vehicle-mounted terminal, or the like, but is not limited thereto. The server can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. The text classification method can include the following steps S101-S105.
[0073] S101: Obtain a text to be classified. The text to be classified can be a news text, a magazine text, or the like. Alternatively, the text to be classified can be an abnormal text such as a clickbait text or a normal text such as a non-clickbait text. In the embodiments of the present application, the abnormal text mainly refers to a title reflecting content that is excessively exaggerated and deviates from the real content in the text to maliciously attract user clicks / views, for example, Figure 2a The text to be classified framed by the dashed line, for the text to be classified 201, the exaggerated 3 billion is actually not mentioned in the text to be classified 201, and the actual content is not 3 billion. For the text to be classified 202, the title attracts people by the smell of a star, and the actual content is that Xiao C says to eat dumplings with garlic, and the breath is bad. Therefore, the text to be classified 201 and the text to be classified 202 both belong to abnormal texts. The normal text referred to in the embodiments of the present application refers to a title consistent with the text content.
[0074] In one embodiment, the text to be classified can also be a text to be classified in abnormal texts, such as a title-text unrelated text, an over-interpretation text, a meaningless text, and a suspense text. The title-text unrelated text refers to a text title unrelated to the text content. Over-interpretation refers to over-interpretation of the text content by the title, which exceeds the original meaning of the text content. The text to be classified can include a text title and a text content. The text to be classified can be a text uploaded by an uploader to an application platform and needs to be classified. The computer device can obtain the text to be classified from the application platform, which can be an instant messaging software, an information recommendation platform, or the like.
[0075] S102: text analysis is performed on a first character set included in the text to be classified to obtain a first vector corresponding to the text to be classified. The first character set can include one or more characters. The characters included in the first character set can be randomly obtained from the text to be classified. For example, the text to be classified is "Li Si's truth has appeared, proving that he is an innocent woman", and the characters included in the first character set can be "Li", "Si", "out", "no", and "guilt". Alternatively, the characters included in the first character set can be consecutive characters obtained from the text to be classified. For example, the text to be classified is also "Li Si's truth has appeared, proving that he is an innocent woman", and the characters included in the first character set can be "Li Si's truth has appeared".
[0076] In an embodiment, the computer device can obtain the first character set from the characters included in the text to be classified, and perform text analysis on the characters included in the first character set to obtain the first vector. Alternatively, the first text processing module is used to perform text analysis on the first character set included in the text to be classified to obtain the first vector corresponding to the text to be classified. The first text processing module can better understand the text content and complete the understanding of the text content. The first text processing module can be a bert model, and the length of the characters included in the first character set can be obtained according to requirements. For example, the length of the characters included in the first character set can be the length of the characters included in the above example "Li Si's truth has appeared". For another example, the length of the characters included in the first character set can be 128, 256, etc. In the embodiment of the present application, the length of the characters included in the first character set can also be 512.
[0077] S103: text analysis is performed on a second character set included in the text to be classified to obtain a second vector corresponding to the text to be classified. After step S102, the present application can better understand the text to be classified, but since the text to be classified can be a long text, the pure text is generally in the order of thousands of characters, and the first processing text module cannot process the long text. In order to correctly obtain the content information of the entire text, text analysis is performed on the second character set to obtain the second vector corresponding to the text to be classified, so as to supplement the text information indicated by the first vector.
[0078] The characters in the first character set and the characters in the second character set have different lengths. The second character set can include multiple characters; the characters in the second character set can be characters randomly obtained from the text to be classified. For example, if the text to be classified is "Li Si's truth has come out, proving that she is an innocent woman," the characters in the second character set could be "Li," "Si," "zhen," "xiang," "zi," "ji," "wu," "gu," "nü," "ren." Alternatively, the characters in the second character set can be consecutive characters obtained from the text to be classified. For example, if the text to be classified is also "Li Si's truth has come out, proving that she is an innocent woman," the characters in the second character set could be "Li Si's truth has come out, proving that she is an innocent woman."
[0079] The length of the characters included in the second character set can be obtained according to requirements. For example, the length of the characters included in the second character set can be the same as the length of the characters included in the example above, "Li Si's truth has come out, proving that she is an innocent woman." Optionally, the length of the characters included in the second character set can be 515, 1024, 2000, etc., and this application embodiment does not limit it. The characters included in the first character set and the characters included in the second character set can be partially the same, or the characters included in the first character set and the characters included in the second character set can be completely different. For example, the characters included in the first character set are "Li," "Si," "Zhen," and "Xiang," and the characters included in the second character set are "proving that she is an innocent woman."
[0080] In one embodiment, step S103 can be implemented as follows: a computer device can obtain a second character set from the text to be classified, and perform text analysis on the characters included in the second character set to obtain a second vector corresponding to the text to be classified. Optionally, a second text processing module can be invoked to perform text analysis on the characters included in the second character set to obtain a second vector corresponding to the text to be classified. The second text processing module can be a TextCNN model. The second text processing module can process text of arbitrary length. In this application example, the second text processing module can be set to process text of length 2000.
[0081] S104: Analyze the text to be classified based on the reference vector set to obtain the auxiliary vector corresponding to the text to be classified. The reference vector set is obtained based on the text to be classified and multiple reference texts associated with it. The reference vector set includes one or more reference vectors, and the multiple reference texts associated with the text to be classified can refer to texts whose similarity scores with the text to be classified meet a similarity threshold.
[0082] In an embodiment, the computer device can obtain a reference text set, which can include a plurality of reference texts. The reference text set can be obtained by a quality detection device (specifically, a quality detection device corresponding to a quality detection team) performing quality detection on online texts every day and feeding back the results. The computer device can select a plurality of reference texts associated with the text to be classified from the reference text set. As an implementation, a similarity score between each reference text and the text to be classified can be calculated, and the plurality of reference texts associated with the text to be classified can be determined from the reference text set according to the similarity score between each reference text and the text to be classified. For example, reference texts with a similarity score greater than or equal to a similarity threshold can be selected from the reference text set as reference texts associated with the text to be classified. For another example, the plurality of reference texts associated with the text to be classified can be selected from the reference text set according to the similarity score between each reference text and the text to be classified in descending order to obtain a ranking result, and then the top K reference texts in the ranking result can be selected as the plurality of reference texts associated with the text to be classified. After obtaining the plurality of reference texts associated with the text to be classified, the text feature vector of each reference text in the plurality of reference texts associated with the text to be classified can be obtained. For a target reference text in the plurality of reference texts associated with the text to be classified, a feature vector analysis can be performed on the target reference text to obtain a text feature vector of the target reference text. According to the category label and the similarity score corresponding to the text feature vector of the target reference text, a reference vector corresponding to the text feature vector of the target reference text can be determined, and the obtained reference vector can be added to a reference vector set.
[0083] In an embodiment, the computer device can use an auxiliary text processing module to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vectors corresponding to the reference text set to obtain a similarity analysis result, and obtain a reference vector set including one or more reference vectors based on the similarity analysis result. The similarity analysis result includes a similarity score between the text feature vector of the text to be classified and the reference text feature vectors. According to an implementation of obtaining the reference vector set including one or more reference vectors based on the similarity analysis result, a target reference text feature vector is determined based on the similarity score between the text feature vector of the text to be classified and the reference text feature vectors, and a reference vector corresponding to the target reference text feature vector is determined based on the similarity score and the category label corresponding to the target reference text feature vector. The determined reference vector is added to the reference vector set. The auxiliary text processing module determines the reference vector set by determining the similarity between the text to be classified and the reference text feature vectors corresponding to the reference text set, and the reference vector set can be used as auxiliary features for classifying the text to be classified, thereby solving the classification inaccuracy caused by subjective understanding factors.
[0084] After obtaining the set of reference vectors, the computer device can obtain the category label and the similarity score included in each reference vector, and perform feature fusion on the category label and the similarity score included in each reference vector to obtain an auxiliary vector corresponding to the text to be classified. The category label included in each reference vector can be determined by performing text classification on the reference text corresponding to the reference vector, or the category label included in each reference vector can be obtained by a quality detection team that performs quality inspection on online texts every day and feeds back the results. The category label can be used to indicate which category the reference text corresponding to the reference vector belongs to. For example, if the category label included in the reference vector is abnormal, it indicates that the reference text corresponding to the reference vector is an abnormal text. The similarity score included in each reference vector is determined based on the similarity analysis result.
[0085] S105: classifying the text to be classified based on the first vector, the second vector, and the auxiliary vector to obtain a target category to which the text to be classified belongs. The target category to which the text to be classified belongs can be news, magazines, etc. Alternatively, the target category to which the text to be classified belongs can be a title party or a non-title party. Alternatively, the target category to which the text to be classified belongs can be a gossip text. The target category to which the text to be classified belongs can be determined according to a classification task. For example, if the classification task is abnormal text recognition, the target category to which the text to be classified belongs can be an abnormal text or a normal text. If the classification task is gossip text recognition, the target category to which the text to be classified belongs can be a gossip text or a non-gossip text. In an embodiment, the computer device can call a classifier to classify the text to be classified based on the first vector, the second vector, and the auxiliary vector to obtain the target category to which the text to be classified belongs.
[0086] In the embodiments of the present application, the computer device can obtain characters of different lengths to extract text features, and analyze the text to be classified based on the set of reference vectors corresponding to the text to be classified and a plurality of reference texts associated with the text to be classified to obtain an auxiliary vector corresponding to the text to be classified. By classifying the text to be classified based on the first vector, the second vector, and the auxiliary vector, the target category to which the text to be classified belongs is obtained. By performing text analysis on the first character set and the second character set in the text to be classified, the classification effect of the text to be classified can be improved from the overall scheme, and the accuracy of text classification can be improved. Specifically, in a multimedia network platform or a terminal browser application, some abnormal texts uploaded by uploaders can be automatically and accurately filtered out through the multimedia network platform, reducing the labor cost. When applied to the terminal browser application, it can also help users to filter out some abnormal texts of the title party type, making it convenient for users to obtain meaningful news information.
[0087] Based on the above provided text classification method, an embodiment of the present application provides a text classification model. The target category to which the above-mentioned to-be-classified text belongs can be determined by the computer device calling the text classification model to perform classification processing on the to-be-classified text. The architecture diagram of the text classification model can be as shown in Figure 2b The text classification model can include a first text processing module, a second text processing module, and an auxiliary text processing module. The first vector can be obtained by the first processing module analyzing a first character set included in the to-be-classified text. The second vector can be obtained by the second text processing module analyzing a second character set included in the to-be-classified text. The auxiliary vector can be obtained by the auxiliary text processing module analyzing the to-be-classified text according to a reference vector set.
[0088] Optionally, the architecture diagram of the text classification model can also be as shown in Figure 2c Since the Bert model pre-trained on news corpus can better adapt to the downstream task of classifying news text, and the Bert model has the best understanding ability at present, the first text processing module in Figure 2c may be a Bert model. Since the maximum input length of the first text processing module is 512, the text content exceeding the maximum length will not enter the first text processing module, so using only the first text processing module will cause the loss of information exceeding the maximum length. Therefore, in order to correctly obtain all the text information and improve the classification ability of the overall model, and considering the pressure of online application of the text classification model, in addition to using means such as text truncation, sliding window, and compression to solve the problem of long text, the second text processing module can also be used to analyze the characters included in the second character set. Therefore, the second text processing module in Figure 2c may be a relatively lightweight TextCNN model.
[0089] In one embodiment, through analysis of a large number of abnormal texts, it is found that the abnormal text recognition task of common headlines is one of low-quality recognition tasks. Through research, it is found that there are two problems in the abnormal text recognition task in the low-quality recognition task:
[0090] (1) Content bias understanding: Unlike the simple definition of general sentence structure, tone, keywords, etc., the judgment of part of the headline party needs to have a certain understanding of the text content, to judge whether the "meaning" embodied by the headline is the same as the "meaning" embodied by the content. For example, several examples in Table 1:
[0091] Table 1
[0092]
[0093] (2) Ambiguity caused by subjective understanding factors: The definition of low-quality content has its own standards, which come from actual online scenarios. The judgment of title parties depends on the defined standards, but due to the influence of subjective factors, actual manual discrimination is also prone to ambiguity, and this difference will be further passed to the model side through the labeled data, affecting the recognition result of the model. How to minimize the differences caused by subjective ambiguity problems is a common and important problem for low-quality content. Like most low-quality content, the abnormal text standard has a subjective ambiguity problem, and in the embodiments of the present application, the abnormal text recognition task has two different data production sources, one is a dedicated training set, that is, set A, and the other is an abnormal text set screened by a professional abnormal text quality inspection team through manual recognition, that is, set B. There is a certain difference between the generated sets, and the production source of set B is a quality inspection team in actual business, which produces an abnormal text set after daily online data quality inspection and feedback of the results. In the optimization process of the classification model, through the analysis of the case text of the quality inspection result, it is found that the early model has limited recognition ability for some case texts similar to the quality inspection data. The case text has a certain similarity with the quality inspection data, but the model does not give the correct recognition, and does not regard these case texts as title party type texts and other abnormal texts.
[0094] The reason for the above situation is that: on the one hand, the distribution of the training set (from set A) is different from set B due to subjective factors of manual auditing ambiguity, and on the other hand, the training set data is small (3w) and the data richness is insufficient. A simple solution is to directly add set B to the training set and retrain the model, but the model generated in this way performs fluctuation in the experiment, and the indicators fluctuate unpredictably after adding different batches of quality inspection data. That is, in this way, the influence of data difference cannot be controlled, and there is no good interpretability and universality. From the perspective of data standards, for the ambiguity problem caused by subjective factors, on the one hand, improve the accuracy of labeling and model as much as possible, and on the other hand, jump out of the current field and expand the idea more widely. For example, the legal field usually divides the legal system into "maritime law system" and "continental law system", and the "maritime law system" emphasizes the use of cases (historical cases) to interpret the current case, thereby avoiding the judgment deviation caused by the ambiguity of understanding the written regulations in the "continental law system". Since the quality inspection result has a certain lag, it is similar to a "historical case", so the idea of "maritime law system" is borrowed; if the data in set B is used as a historical case text, the model will use similar case texts in these "historical case texts" as a reference when judging data, which can solve the above-mentioned problem. In this case, the memory network idea can be selected to design the model, and set B (hereinafter referred to as the reference text set) is used as the memory part of the model, that is, the "case text" mentioned above. The experimental results also verify that the model has good performance. For the title party identification task or classification task, another advantage of using the memory network structure is that it can better utilize the two data sources A and B, avoiding the problem of disturbance caused by different data AB as the same input. In addition, this memory network structure has certain universality for other similar tasks.
[0095] Based on this, the auxiliary text processing module in the embodiment of the application can include an analysis submodule constructed based on a memory network. Since the reference text feature vectors corresponding to the reference text set stored in the memory network correspond to the category label label and the similarity score score, the auxiliary text processing module can include a feature fusion module, which can perform feature fusion on the output of the analysis submodule.
[0096] Based on the above-provided text classification scheme and text classification model, the embodiment of the application provides a text classification method, please see Figure 3The text classification method can be executed by a computer device, which can be a terminal device or a server. The terminal device can be a smartphone, a tablet computer, a notebook computer, a desktop computer, an AR / VR device, a vehicle-mounted terminal, etc., but is not limited thereto. The server can be a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. The text classification method can be implemented by a text classification model, and the text classification method can include steps S301-S305.
[0097] S301: Obtain a text to be classified.
[0098] S302: Call a first text processing module in the text classification model to perform text analysis on a first character set included in the text to be classified, to obtain a first vector corresponding to the text to be classified. The first text processing module can be a BERT model, and the first vector is a 768-dimensional cls vector output by the first processing module. The length of the characters included in the first character set can be 64, 512, etc. Alternatively, when the first text processing module is a BERT model, the maximum length of the text that can be processed by the first text processing module is 512, i.e., the length of the characters included in the first character set can also be 512. In an embodiment, the computer device can call the first text processing module in the text classification model to perform feature vector extraction on the characters included in the first character set, to obtain the first vector corresponding to the text to be classified.
[0099] S303: Call a second text processing module in the text classification model to perform text analysis on a second character set included in the text to be classified, to obtain a second vector corresponding to the text to be classified; the lengths of the characters included in the first character set and the second character set are different.
[0100] Since the maximum input length of the first text processing module is 512, the text content exceeding the maximum length cannot enter the first text processing module for processing, and thus the use of the first text processing module alone can cause loss of part of the information in the text to be classified. In order to correctly obtain all the text information of the text to be classified and improve the accuracy of the final classification, and considering the pressure of using the text classification model in online application, the embodiments of the present application can not only use means such as truncation, sliding window, compression, etc. to solve the long text problem, but also can introduce a second text processing module that can process text of any length. When the maximum text length processed by the second text processing module (i.e. the maximum length of the characters included in the second character set) is 2000, the text classification model has good classification ability.
[0101] In one embodiment, the text length processed by the second text processing module (i.e. the length of the characters included in the second character set) can also be 512, 1024, etc., which is not limited by the embodiments of the present application. The second vector obtained by the second text processing module in step S303 for text analysis of the characters included in the second character set can supplement the text information indicated by the first vector corresponding to the text to be classified in step S302, thereby solving the problem of information loss caused by long text content. The second text processing module can be a TextCNN module, and the second vector refers to a 128-dimensional vector output by the second text processing module. In one embodiment, the second vector can be used to indicate the full text information in the text to be classified. By comparing the second text processing module with other basic models in terms of full text information acquisition, the comparison results are shown in Table 2, and the experimental values in Table 2 represent the effect of the second text processing module index compared with the base model. As can be seen, the second text processing module, i.e. TextCNN, can better obtain all the information of the text.
[0102] Table 2
[0103]
[0104] In one embodiment, the computer device can call the second text processing module in the text classification model to extract the feature vector of the characters included in the second character set, to obtain the second vector corresponding to the text to be classified.
[0105] S304: calling an auxiliary text processing module in the text classification model to analyze the text to be classified according to the reference vector set, to obtain an auxiliary vector corresponding to the text to be classified, wherein the reference vector set is obtained according to the text to be classified and a plurality of reference texts associated with the text to be classified.
[0106] In one embodiment, as known from the foregoing, the auxiliary text processing module can include an analysis submodule and a feature fusion module constructed based on a memory network. The feature fusion module can be a deepFM model (a kind of deep learning model). The computer device can invoke the analysis submodule to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vector corresponding to the reference text set of the reference text, obtain a similarity analysis result, and then obtain a reference vector set including one or more reference vectors according to the similarity analysis result; each reference vector can include a category label and a similarity score. The text feature vector can include character features of the text to be classified and the like; the reference text feature vector includes character features of the reference text and the like. The category label is used to indicate which category the reference text corresponding to the reference vector belongs to, and the similarity score is obtained by calculating the similarity between the text feature vector of the text to be classified and the reference text feature vector. The analysis submodule can include a third text processing module and a memory network as shown in Figure 4 , the third text processing module can be used for text processing of the text to be classified, and the third text processing module can be a BERT model.
[0107] In one embodiment, the architecture of the memory network can be as shown in Figure 5a , the memory network mainly includes memory slots and I, G, O, and R modules. The G module selects the content in the memory slots according to the feature vector generated by the I module, combines the output vector in the O module according to the relevance to the question, and finally generates the result in the R module. The models used in the four modules can be freely selected. In this structure, since the four modules need to be trained separately, it is not easy to update and adjust the parameters and the like on the overall task, which limits the performance of the model to some extent.
[0108] In another embodiment, the architecture of the memory network (which is an end-to-end memory network structure) can be as shown in Figure 5b , the memory network can select the memory part with the highest relevance to the input by combining the attention mechanism, and finally obtain the output result by combining the input text. This end-to-end structure allows the parameters to be updated in time.
[0109] In another embodiment, the architecture of the memory network can be as shown in Figure 5cAs shown, the input is respectively mapped into input memory and output memory in the form of memory using key-value pairs, the key is used to find the memory unit, and the value is used to weight the output of the memory. The advantage of this method is very flexible, and the form of key-value can be set by itself, without relying completely on the embedding matrix of the model, that is, different retrieval methods can be used.
[0110] The main idea of the three memory networks is to obtain the memory with the strongest relevance to the input in the memory part through a certain method (such as attention), as a reference for the final output result. The above idea can be applied to the text classification model of the embodiment of the present application. Since a large number of reference text sets can be obtained in the embodiment of the present application, the reference text feature vectors corresponding to the reference text sets can be used as a memory retrieval library, that is, as a memory part in the memory network. The reference text feature vectors included in the memory part can be understood as a kind of "reference case text" and can be used to solve the ambiguity problem. Unlike the question and answer task, in the text classification task, texts of the same category have similarities, so the similarity of the text feature vectors can be used to retrieve the most relevant memory content. The memory content (i.e. the reference text feature vector) is the feature vector of the reference text. The reference text feature vector can be obtained by the fourth text processing module analyzing the reference text.
[0111] As shown in Figure 5d The fourth text processing module can be a pre-Bert model, and the reference text feature vector can be a cls vector. Then the reference text feature vector corresponding to the reference text can be stored in the memory network. When the reference text feature vectors corresponding to the reference texts are all stored in the memory network, the fourth text processing module does not participate in other processing. The memory network is designed as an end-to-end structure, and the model parameters and the memory part vectors can be continuously updated during the training of the text classification model to achieve the optimal effect. In Figure 5dIn this embodiment, the memory data module can be part of the memory network, or the memory data module can be a separate module, which is not limited in the present application. In one embodiment, before generating the reference text feature vectors corresponding to the reference text set and storing the reference text feature vectors corresponding to the reference text set into the memory network, since the number of reference text feature vectors in the reference text set and the category to which the reference text belongs will directly affect the model parameters and then affect the classification ability of the model, therefore, the ratio of different categories to which the reference text belongs needs to be considered, that is, the number of reference texts in each category in the reference text set needs to be considered. In one embodiment, the ratio of the number of reference texts in each category can be 1:1, that is, the number of reference texts in each category is the same. For example, the number of reference texts in category 1 is the same as the number of reference texts in category 2. For another example, the text classification model is an abnormal text recognition, and the ratio of the number of abnormal texts (positive) to the number of non-abnormal texts (negative) in the reference text set is 1:1, which is optimal.
[0112] In one embodiment, the reference text feature vectors corresponding to the reference text set are obtained by the fourth text processing module performing feature vector analysis processing on the reference texts in the reference text set, and the reference text feature vectors corresponding to the reference text set are stored into the memory network. The specific implementation manner of the computer device calling the analysis submodule to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vectors corresponding to the reference text set to obtain the similarity analysis result can be: calling the third text processing module to perform text processing on the text to be classified to obtain the text feature vector corresponding to the text to be classified; calling the memory network to perform similarity calculation on the text feature vector and the reference text feature vectors corresponding to the reference text set to obtain the similarity score of the text feature vector and the reference text feature vector. The number of reference text feature vectors can be one or more. Specifically, the cosine similarity of the text feature vector and the reference text feature vectors corresponding to the reference text set can be calculated to obtain the similarity score of the text feature vector and the reference text feature vector.
[0113] When the number of reference text feature vectors is multiple, the specific implementation manner of the computer device obtaining the reference vector set including one or more reference vectors according to the similarity analysis result can be: the computer device can determine a target reference text feature vector according to the similarity score of the text feature vector of the text to be classified with each reference text feature vector; determine the reference vector corresponding to the target reference text feature vector according to the category label and the similarity score corresponding to the target reference text feature vector; add the reference vector corresponding to the target reference text feature vector to the reference vector set. The computer device can process the category label and the similarity score corresponding to the target reference text feature vector to obtain the reference vector corresponding to the target text feature vector. The processing of the category label and the similarity score corresponding to the target reference text feature vector can be splicing the category label and the similarity score (for example, the category label is 1 and the similarity score is 98, and the splicing is 198); or, the processing of the category label and the similarity score corresponding to the target reference text feature vector can be calling a deepFM model to perform feature fusion on the category label and the similarity score.
[0114] In one embodiment, there are two implementation manners for determining the target reference text feature vector according to the similarity score of the text feature vector of the text to be classified with each reference text feature vector. The first implementation manner can be: the computer device determines the reference text feature vector corresponding to the similarity threshold as the target reference text feature vector, where the similarity threshold can be set according to requirements.
[0115] In one embodiment, by verifying the actual effect of the text classification method proposed in the application on the product side, typical online texts are extracted, and the recognition effects of the Bert model and the Bert+memory network classification are compared. As shown in Table 3, three typical texts to be tested are selected, and the top 3 memory retrieval results of the memory network are displayed for each text. It can be seen that when the Bert model prediction is wrong, the memory retrieval result of the memory network can effectively help the model to correct, so that the final text classification model can obtain the correct prediction result. In addition, in the third text, although the top 1 memory result is opposite to the true label (the top 2 and top 3 are the same), the model still predicts the correct result, which shows that the memory network using the top K features has a certain fault tolerance.
[0116] Table 3
[0117]
[0118] In this case, given that the Bert+memory network classification has a certain fault tolerance, and the reference text feature vectors corresponding to the reference text set are used to solve the subjective understanding ambiguity problem, while trying to avoid the influence of data noise and improve the noise resistance of the model, in the embodiment of the application, the top K reference text feature vectors corresponding to the features can be selected, that is, K can be an integer greater than or equal to 1. At this time, the second implementation manner can be: the computer device arranges the similarity scores of the text feature vector of the text to be classified and each reference text feature vector in descending order to obtain an arrangement result; and then determines the reference text feature vectors corresponding to the top K similarity scores from the arrangement result as target reference text feature vectors, K being an integer greater than or equal to 1. For example, the similarity score of the text feature vector of the text to be classified and the reference text feature vector 1 is 0.988, the similarity score of the text feature vector of the text to be classified and the reference text feature vector 2 is 0.987; the similarity score of the text feature vector of the text to be classified and the reference text feature vector 3 is 0.988, and the similarity scores are arranged in descending order as: 0.988, 0.988, 0.987; the reference text feature vector 1 and the reference text feature vector 3 corresponding to the top 2 similarity scores can be determined as target reference text feature vectors from the arrangement result.
[0119] In one embodiment, considering that the determined reference vector is determined according to the similarity between the text feature vector of the text to be classified and the reference text feature vector, that is, the reference vector is retrieved from the cls vector (that is, the reference text feature vector) in the memory network through similarity, the reference text feature vector and the text feature vector of the classified text have a large information overlap, and therefore the category label and the similarity score corresponding to the reference vector can be used as auxiliary features of the text to be classified in the memory network part. After obtaining the reference vector set, the computer device can analyze the text to be classified according to the reference vector set, and the specific implementation manner of obtaining the auxiliary vector corresponding to the text to be classified can be: calling the feature fusion module to fuse the category label and the similarity score included in each reference vector to obtain the auxiliary vector corresponding to the text to be classified, and the total dimension of the features of the auxiliary vector is topK*2.
[0120] wherein the above category label label (such as the category label can be abnormal text or normal text) and the similarity score score (such as cosine similarity) belong to discrete features and continuous features respectively, in order to better fuse the two, the DeepFM model can be used to process the features generated by the Memory Network, and for the discrete and continuous features of the Memory Network part, several fusion methods are tried, and the base method is that the two features directly enter the classification layer, and the experimental results are shown in Table 4. The implementation results show that the DeepFM method has the best effect, that is, the feature fusion module in the embodiment of the application can be a DeepFM model.
[0121] Table 4
[0122]
[0123] In one embodiment, the reference vector set including one or more reference vectors obtained based on the similarity analysis result does not necessarily fully meet the desired "similar" effect, and the results with relatively low similarity scores may interfere, therefore, the similarity scores included in the reference vectors in the reference vector set can be compared with a similarity threshold value, and the similarity scores below the similarity threshold value can be set to special values, reminding the text classification model not to pay attention to it, wherein the similarity threshold value belongs to the model parameters. In this case, the computer device calls the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector to obtain the specific implementation of the auxiliary vector corresponding to the text to be classified. The computer device can determine whether there is a target reference vector in the reference vector set, if there is a target reference vector in the reference vector set, the similarity score corresponding to the target reference vector is adjusted to a target score, and the target reference vector refers to a reference vector with a similarity score less than the similarity threshold value; the feature fusion module is called to perform feature fusion on the category label and the target score included in the target reference vector, and the category label and the similarity score included in the remaining reference vectors to obtain the auxiliary vector corresponding to the text to be classified; wherein the remaining reference vectors refer to the reference vectors in the reference vector set except the target reference vector. If there is no target reference vector in the reference vector set, the similarity scores corresponding to the reference vectors in the reference vector set do not need to be adjusted. The target score can take a special value, such as -1, 0, etc.; optionally, since the similarity threshold value belongs to the model parameters, the similarity threshold value is different according to the text classification task of the text classification model. For example, for the abnormal text recognition task of the text classification model, the similarity threshold value of 0.98 is optimal in the experiment.
[0124] S305: calling the classifier in the text classification module to classify the text to be classified based on the first vector, the second vector and the auxiliary vector to obtain the target category to which the text to be classified belongs.
[0125] In the embodiment of the present application, the computer device can obtain the text to be classified, then call the first text processing module in the text classification model to perform text analysis on the first character set included in the text to be classified, obtain the first vector corresponding to the text to be classified, call the second text processing module in the text classification model to perform text analysis on the second character set included in the text to be classified, obtain the second vector corresponding to the text to be classified, call the auxiliary text processing module in the text classification model to analyze the text to be classified according to the reference vector set, obtain the auxiliary vector corresponding to the text to be classified, call the classifier in the text classification module to perform classification processing on the text to be classified based on the first vector, the second vector and the auxiliary vector, obtain the target category to which the text to be classified belongs, the second text processing module can solve the problem of long text, and the first text processing module and the second text processing module can better understand the text and obtain all text information of the text, and the auxiliary text processing module can solve the subjective understanding deviation, thereby improving the accuracy of the text to be classified.
[0126] Based on the above text classification model, the embodiment of the present application further provides a model training architecture diagram and a model training method, wherein the architecture diagram of the whole text classification model training is as shown in Figure 6a The architecture diagram of the text classification model training includes an initial model and a data screening module, wherein the specific architecture of the initial model is as described above, and will not be described here. The data screening module can include a data screening model and a threshold screening. The data screening model can classify the initial training set in the random data, and the threshold screening can perform threshold screening on the initial training samples in the classified initial training set to obtain the labeled sample text. The model training method can be as shown in Figure 6b The model training method can be executed by a computer device, which can be a server or a terminal device. The terminal device can be a smartphone, a tablet computer, a notebook computer, a desktop computer, etc., but is not limited thereto. The server can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. The model training method can include the following steps S601-S609.
[0127] S601: Obtain a target training set, wherein the target training set can include a plurality of sample texts and a category label corresponding to each sample text. In an embodiment, the computer device can obtain an initial training set including a plurality of initial training samples, and each training sample in the initial training set is used as a sample text, and finally a target training set is obtained.
[0128] In another embodiment, taking the classification of abnormal text recognition as an example, the abnormal text is a binary classification task as a whole, that is, to determine whether a text is an abnormal text. In a specific definition, the actual distribution ratio of online abnormal text content (positive) to normal text content (negative) is about 1:9, and there is a class distribution imbalance problem, and this problem not only exists in the positive-negative ratio, but also exists in the four different subcategories of abnormal text (for example, in random data, the proportions of four categories of irrelevant to the title, over-interpretation, meaningless and suspense are about 0.52:0.20:0.09:0.19), which further aggravates the severity of the imbalance problem. The class distribution imbalance problem not only affects the classification or recognition ability of the text classification model, but also increases the cost of manual labeling. The data imbalance problem is a common problem in machine learning, and the common solutions include oversampling, downsampling, setting different class weights, etc. These methods can solve the problem to a certain extent, but they also have the problem of not being able to expand the data richness. Since the training data can be continuously supplemented by manual labeling, in the embodiments of the present application, attention is paid to how to obtain balanced data, on the one hand to ensure the richness of the data, and on the other hand to improve the efficiency of labeling. Before a large amount of labeled data is sent, a fine classification model is first trained using a small amount of data, for example, for the abnormal text recognition classification task, a text screening model (such as a four-classification model, a five-classification model, etc., a five-classification model, which specifically identifies the five subcategories of non-headline, irrelevant to the title, over-interpretation, meaningless and suspense) can be trained. Through the text screening model, appropriate initial training samples can be selected from the obtained initial training set as sample texts, and a target training set is obtained based on the sample texts. In specific operations, the initial training samples in the initial training set can be predicted and labeled by using the text screening model, and the class confidence of the initial training samples in different categories is set to different type confidence thresholds. The text screening model can be a BERT model.
[0129] In an embodiment, the specific implementation manner of obtaining the target training set can be: obtaining an initial training set, then calling the text screening model to perform classification processing on the initial training set to obtain a text category to which each initial training sample belongs and a category confidence; then determining a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence, and the plurality of sample texts can be used to perform optimized training on the initial model to obtain the target classification model. As an implementation manner, the determined plurality of sample texts can be directly added to the target training set. The plurality of sample texts included in the target training set can be the sample texts determined from the initial training set. Alternatively, the plurality of sample texts included in the target training set can be the sample texts in the original training sample set, that is, the sample texts determined from the initial training set can be understood as a supplement to the original training sample set, and the original training sample set can be understood as the samples obtained in advance for training the text classification model. By using the text screening model, a relatively balanced sample text to be labeled can be obtained, and an initial training text that is difficult to identify the boundary (the initial training sample that is difficult to identify the boundary can refer to an initial training sample that cannot be determined to belong to a category) can be determined, and the initial training sample that is difficult to identify the boundary can also be determined as a sample text. Compared with directly sending random data for labeling, the data distribution balance problem in the target training set generated by this pre-screening data labeling manner can be greatly improved, and the labeling efficiency is also improved.
[0130] In an embodiment, since the text screening model is a pre-trained fine-grained model. Therefore, the text screening model in the embodiment of the present application can output M text categories, where M is an integer greater than or equal to 1. The text category to which each initial training sample belongs belongs to any of the M text categories. Then, the category confidence thresholds of different text categories are determined according to the confidence thresholds of the text categories to which each initial training sample belongs. In an embodiment, the specific implementation manner of determining a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence can be: adding each initial training sample to the sample set corresponding to the M text categories according to the text category to which each initial training sample belongs, to obtain the sample set corresponding to the M text categories; and screening the initial training samples whose category confidence satisfies the category screening condition from the sample set corresponding to each text category, and taking the screened initial training samples as sample texts.
[0131] For example, the sample set corresponding to the text category 1 includes the initial training sample 1 belonging to the text category 1 corresponding to the category confidence of 20, and the initial training sample 2 belonging to the text category 1 corresponding to the category confidence of 80. The computer device can filter the initial training sample with the category confidence greater than 10 and less than 50 from the sample set corresponding to the text category 1, that is, the initial training sample satisfying the category confidence greater than 10 and less than 50 is the initial training sample 1, and the initial training sample 1 is used as the sample text. For another example, the sample set corresponding to the text category 2 includes the initial training sample 3 belonging to the text category 2 corresponding to the category confidence of 40, and the initial training sample 4 belonging to the text category 2 corresponding to the category confidence of 60. The computer device can filter the initial training sample with the category confidence greater than 50 and the confidence less than 70 from the sample set corresponding to the text category 2, that is, the initial training sample with the category confidence greater than 50 and the confidence less than 70 is the initial training sample 4, and the initial training sample 4 is used as the sample text. It can be understood that in the embodiment of the present application, the sample set corresponding to each text category is different in the category screening condition corresponding to the sample set corresponding to each text category when the initial training sample is screened, for example, the category screening condition can be that the category confidence is greater than the confidence threshold, or the category screening condition can be that the category confidence is less than the confidence threshold, which is not limited in the present application. By setting the category screening condition, the initial training sample can be filtered from the sample set corresponding to each text category as the sample text, and the balance of the sample category is ensured.
[0132] In an embodiment, after obtaining the target training set in step S601, the computer device can label each sample text based on the text category to which each sample text belongs as determined by the text screening model, to obtain a category label corresponding to each sample text. For example, the text category to which sample text 1 belongs is category 1, and the category label corresponding to sample text 1 is category 1; the text category to which sample text 2 belongs is category 2, and the category label corresponding to sample text 2 is category 2. In an embodiment, each sample text can be labeled based on the classification task and the text category to which each sample text belongs as determined by the text screening model, to obtain a category label corresponding to each sample text. For example, the classification task is an abnormal text identification task, and the abnormal text identification is a binary classification task as a whole, i.e., to determine whether a text is an abnormal text. As described above, the text screening model can be a five-classification model, i.e., a five-classification model that specifically identifies normal text, irrelevant to the text, over-interpretation, nonsense, and suspense. After obtaining the text category to which each of the obtained multiple sample texts belongs, which is any of the five categories, the computer device re-labels each of the multiple sample texts based on the text category to which each sample text belongs. For example, the text category to which sample text A belongs is irrelevant to the text, and the computer device labels sample text A based on the text category to which sample text A belongs, to obtain a category label corresponding to sample text A, which is an abnormal text.
[0133] S602: calling the initial model to perform classification processing on each sample text to obtain a predicted category to which each sample text belongs. The structure of the initial model can refer to the architecture of the text classification model described above.
[0134] S603: determining a model loss value based on the predicted category to which each sample text belongs and the corresponding category label. The computer device can compare the predicted category to which each sample text belongs and the corresponding category label to obtain the model loss value of the initial model.
[0135] S604: updating the model parameters of the initial model based on the model loss value to obtain a text classification model. The computer device can update the model parameters of the initial model in reverse based on the model loss value. The model parameters can include parameters in the auxiliary text processing module, parameters in the first text processing module and parameters in the second text processing module, a similarity threshold, and the like. Taking the analysis submodule based on network memory construction included in the auxiliary text processing module as an example, the computer device will update the memory parameters in the memory network and the third text processing module in reverse based on the model loss value. In Figure 7 the dashed line is the process of updating the analysis submodule in reverse based on the model loss value.
[0136] S605: obtaining a text to be classified.
[0137] S606: Call the first text processing module in the text classification model to perform text analysis on the first character set included in the text to be classified, to obtain a first vector corresponding to the text to be classified.
[0138] S607: Call the second text processing module in the text classification model to perform text analysis on the second character set included in the text to be classified, to obtain a second vector corresponding to the text to be classified.
[0139] S608: Call the auxiliary text processing module in the text classification model to analyze the text to be classified according to the reference vector set, to obtain an auxiliary vector corresponding to the text to be classified.
[0140] S609: Call the classifier in the text classification module to perform classification processing on the text to be classified based on the first vector, the second vector, and the auxiliary vector, to obtain a target category to which the text to be classified belongs.
[0141] It should be noted that the specific implementation of steps S605-S609 can refer to the specific implementation of S301-S305 in the above Figure 3 , which will not be repeated here.
[0142] In the embodiments of the present application, a target training set is obtained, the target training set including a plurality of sample texts and a category label corresponding to each sample text; an initial model is called to perform classification processing on each sample text, to obtain a predicted category to which each sample text belongs; a model loss value is determined according to the predicted category to which each sample text belongs and the corresponding category label; the model parameters of the initial model are updated based on the model loss value, to obtain a text classification model. By training the initial model, the accuracy of the text classification model can be improved. When training the model, the sample text is obtained by the text screening model, which can solve the class imbalance problem and improve the labeling efficiency compared to directly labeling random data, and can improve the classification ability of the text classification model. The second text processing module in the text classification model can solve the problem of long text, and the first text processing module and the second text processing module in the text classification model can better understand the text and obtain all the text information of the text, and the auxiliary text processing module can solve the subjective understanding bias, thereby improving the accuracy of the text to be classified.
[0143] The text classification model provided in the embodiments of the present application can be applied to a news client, a novel client, and the like. The text classification model can have universality, for example, the text classification model can be used for text classification, or the text classification model can be used for abnormal text recognition on text, water text recognition on text (which is part of content low-quality recognition and similar to abnormal text), and the like. Through testing of the title party recognition and the water text recognition in the abnormal text recognition using the text classification model in the text classification method and other classification models, the experimental effect of the text classification model provided in the embodiments of the present application is shown in Table 5.
[0144] Table 5
[0145]
[0146] In the table, the experimental values represent the effect of different model indicators compared with the basic model. It can be seen that the text classification model provided in the embodiments of the present application has a positive performance in the title party recognition and the water text recognition, which indicates that the model capability of the text classification model provided in the embodiments of the present application is good and has universality.
[0147] Based on the description of the above text classification method embodiments, the embodiments of the present application further disclose a text classification device. The text classification device can be a computer program (including program code) running in the above-mentioned computer device. The text classification device can perform the method shown in Figure 1 、 Figure 3 and Figure 6b . Please refer to Figure 8 , the text classification device can include the following units:
[0148] The obtaining unit 801 is configured to obtain a text to be classified.
[0149] The processing unit 802 is configured to perform text analysis on a first character set included in the text to be classified to obtain a first vector corresponding to the text to be classified.
[0150] The processing unit 802 is further configured to perform text analysis on a second character set included in the text to be classified to obtain a second vector corresponding to the text to be classified. The lengths of the characters included in the first character set and the characters included in the second character set are different.
[0151] The processing unit 802 is further configured to analyze the text to be classified according to a reference vector set to obtain an auxiliary vector corresponding to the text to be classified. The reference vector set is obtained according to the text to be classified and a plurality of reference texts associated with the text to be classified.
[0152] The processing unit 802 is further configured to perform classification processing on the text to be classified based on the first vector, the second vector and the auxiliary vector, to obtain a target category to which the text to be classified belongs.
[0153] In an embodiment, the target category to which the text to be classified belongs is determined by performing classification processing on the text to be classified by a text classification model, the text classification model comprising a first text processing module, a second text processing module and an auxiliary text processing module; the first vector is obtained by analyzing a first character set included in the text to be classified by the first text processing module; the second vector is obtained by analyzing a second character set included in the text to be classified by the second text processing module; and the auxiliary vector is obtained by analyzing the text to be classified according to a reference vector set by the auxiliary text processing module.
[0154] In an embodiment, the auxiliary text processing module comprises an analysis submodule and a feature fusion module constructed based on a memory network, and the processing unit 802 is further configured to:
[0155] invoke the analysis submodule to perform similarity analysis on a text feature vector of the text to be classified and a reference text feature vector corresponding to a reference text in a reference text set, to obtain a similarity analysis result;
[0156] obtain a reference vector set comprising one or more reference vectors according to the similarity analysis result, each reference vector comprising a category label and a similarity score;
[0157] When the processing unit 802 analyzes the text to be classified according to the reference vector set to obtain the auxiliary vector corresponding to the text to be classified, it can be specifically configured to:
[0158] invoke the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector, to obtain the auxiliary vector corresponding to the text to be classified.
[0159] In an embodiment, when the processing unit 802 invokes the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector, to obtain the auxiliary vector corresponding to the text to be classified, it can be specifically configured to:
[0160] if there is a target reference vector in the reference vector set, adjust the similarity score corresponding to the target reference vector to a target score, the target reference vector being a reference vector with a similarity score less than a similarity threshold;
[0161] The feature fusion module is called to perform feature fusion on the category label and target score included in the target reference vector and the category label and similarity score included in the remaining reference vector, to obtain an auxiliary vector corresponding to the text to be classified.
[0162] The remaining reference vector refers to a reference vector in the reference vector set other than the target reference vector.
[0163] In one embodiment, the analysis submodule includes a third text processing module and a memory network. The memory network stores reference text feature vectors corresponding to a reference text set. The reference text feature vectors corresponding to the reference text set are obtained by performing feature vector analysis on reference texts in the reference text set by a fourth text processing model. When the processing unit 802 calls the analysis submodule to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vectors corresponding to the reference text set, the similarity analysis result can be obtained, and the processing unit 802 can be specifically used to:
[0164] The third text processing module is called to perform text processing on the text to be classified, to obtain a text feature vector corresponding to the text to be classified.
[0165] The memory network is called to perform similarity calculation on the text feature vector and the reference text feature vectors corresponding to the reference text set, to obtain similarity scores of the text feature vector and the reference text feature vectors.
[0166] In one embodiment, the number of reference text feature vectors is a plurality. When the processing unit 802 obtains a reference vector set including one or more reference vectors according to the similarity analysis result, the processing unit 802 can be specifically used to:
[0167] Determine a target reference text feature vector according to the similarity scores of the text feature vector of the text to be classified and each reference text feature vector.
[0168] Obtain a reference vector corresponding to the target reference text feature vector according to the category label and similarity score corresponding to the target reference text feature vector.
[0169] Add the reference vector corresponding to the target reference text feature vector to the reference vector set.
[0170] In one embodiment, when the processing unit 802 determines a target reference text feature vector according to the similarity scores of the text feature vector of the text to be classified and each reference text feature vector, the processing unit 802 can be specifically used to:
[0171] arrange the similarity scores of the text feature vector of the text to be classified and each reference text feature vector in descending order to obtain an arrangement result;
[0172] determine reference text feature vectors corresponding to the first K similarity scores in the arrangement result as target reference text feature vectors respectively, K being an integer greater than or equal to 1.
[0173] In an embodiment, the obtaining unit 801 is further configured to obtain a target training set, the target training set including a plurality of sample texts, and a category label corresponding to each sample text;
[0174] The processing unit 802 is further configured to invoke the initial model to perform classification processing on each sample text to obtain a predicted category to which each sample text belongs; determine a model loss value according to the predicted category to which each sample text belongs and the corresponding category label; and update the model parameters of the initial model based on the model loss value to obtain a text classification model.
[0175] In an embodiment, when obtaining the target training set, the obtaining unit 801 can be specifically configured to:
[0176] obtain an initial training set, the initial training set including a plurality of initial training samples;
[0177] invoke a text screening model to perform classification processing on the initial training set to obtain a text category to which each initial training sample belongs and a category confidence;
[0178] determine a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence, and add the plurality of sample texts to the target training set.
[0179] In an embodiment, the text screening model outputs M text categories, the text category to which each initial training sample belongs belongs to any one of the M text categories, and M is an integer greater than or equal to 1.
[0180] In an embodiment, when determining a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence, the processing unit 802 can be specifically configured to:
[0181] add each initial training sample to a sample set corresponding to M text categories according to the text category to which each initial training sample belongs, to obtain the sample set corresponding to the M text categories;
[0182] respectively screen initial training samples with a category confidence satisfying a category screening condition from each sample set corresponding to a text category;
[0183] The initial training samples obtained from the screening are used as sample text.
[0184] According to one embodiment of this application, Figure 1 , Figure 3 and Figure 6b Each step involved in the method shown can be performed by... Figure 8 The text classification device shown is executed by each unit. For example, Figure 1 The step S101 shown is by Figure 8 The acquisition unit 801 shown is used to execute steps S102-S105. Figure 8 The processing unit 802 shown is used to execute this. For example, Figure 3 The step S301 shown is by Figure 8 The acquisition unit 801 shown is used to execute steps S302-S305. Figure 8 The processing unit 802 shown is used to execute this. For example, Figure 6b The step S601 shown is by Figure 8 The acquisition unit 801 shown is used to execute steps S602-S604. Figure 8 The processing unit 802 shown executes step S605 by... Figure 8 The acquisition unit 801 shown is used to execute steps S606-S609. Figure 8 The processing unit 802 shown is used to execute this.
[0185] According to another embodiment of this application, Figure 8 The text classification device shown can be constructed by combining each unit individually or entirely into one or more other units, or one or more of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effect of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the text classification device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0186] According to another embodiment of this application, processing elements and storage elements, such as a central processing unit (CPU), random access storage medium (RAM), and read-only storage medium (ROM), can be used. For example, a general-purpose computing device such as a computer can run on a device capable of performing tasks such as... Figure 1 , Figure 3 and Figure 6bA computer program (including program codes) for each step involved in the corresponding method shown is constructed to construct a text classification device as Figure 8 The computer program can be recorded on a computer readable recording medium, for example, and loaded into the computer device described above through the computer readable recording medium, and run therein.
[0187] In the embodiments of the present application, the computer device can obtain characters of different lengths to extract text features; meanwhile, the computer device analyzes the text to be classified according to a reference vector set corresponding to a plurality of reference texts associated with the text to be classified, and obtains an auxiliary vector corresponding to the text to be classified. The text to be classified is classified based on the first vector, the second vector and the auxiliary vector, and the target category to which the text to be classified belongs is obtained. By analyzing the first character set and the second character set in the text to be classified, the classification effect of the text to be classified is improved from the overall scheme, and the accuracy of text classification is improved.
[0188] Based on the description of the above text classification method embodiments, the embodiments of the present application also disclose a computer device, please see Figure 9 The computer device can at least include a processor 901, an input device 902, an output device 903 and a memory 904. The processor 901, the input device 902, the output device 903 and the memory 904 in the computer device can be connected through a bus or other means.
[0189] The memory 904 is a memory device in the computer device, used to store programs and data. It can be understood that the memory 904 here can include the built-in storage medium of the computer device, and of course can also include the expansion storage medium supported by the computer device. The memory 904 provides a storage space which stores the operating system of the computer device. And, the computer program (including program codes) is also stored in the storage space. It should be noted that the computer storage medium here can be a high-speed RAM memory; optionally, it can also be at least one computer storage medium away from the aforementioned processor, and the processor can be referred to as a central processing unit (Central Processing Unit, CPU), which is the core and control center of the computer device, used to run the computer program stored in the memory 904.
[0190] In an embodiment, the computer program stored in the memory 904 can be loaded and executed by the processor 901 to realize the corresponding steps of the method in the above text classification method embodiments; specifically, the processor 901 loads and executes the computer program stored in the memory 904, which is used to:
[0191] obtaining a text to be classified;
[0192] performing text analysis on a first character set included in the text to be classified to obtain a first vector corresponding to the text to be classified;
[0193] performing text analysis on a second character set included in the text to be classified to obtain a second vector corresponding to the text to be classified; the first character set and the second character set include characters of different lengths;
[0194] performing analysis on the text to be classified according to a reference vector set to obtain an auxiliary vector corresponding to the text to be classified, the reference vector set being obtained according to the text to be classified and a plurality of reference texts associated with the text to be classified;
[0195] performing classification processing on the text to be classified based on the first vector, the second vector and the auxiliary vector to obtain a target category to which the text to be classified belongs.
[0196] In one embodiment, the target category to which the text to be classified belongs is determined by performing classification processing on the text to be classified by a text classification model, the text classification model including a first text processing module, a second text processing module and an auxiliary text processing module; the first vector is obtained by analyzing a first character set included in the text to be classified by the first text processing module; the second vector is obtained by analyzing a second character set included in the text to be classified by the second text processing module; and the auxiliary vector is obtained by performing analysis on the text to be classified according to a reference vector set by the auxiliary text processing module.
[0197] In one embodiment, the auxiliary text processing module includes an analysis submodule constructed based on a memory network and a feature fusion module, and the processor 901 is further configured to:
[0198] invoke the analysis submodule to perform similarity analysis on a text feature vector of the text to be classified and reference text feature vectors corresponding to a reference text set to obtain a similarity analysis result;
[0199] obtain a reference vector set including one or more reference vectors according to the similarity analysis result, each reference vector including a category label and a similarity score;
[0200] the analysis on the text to be classified according to the reference vector set to obtain the auxiliary vector corresponding to the text to be classified includes:
[0201] invoke the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector to obtain the auxiliary vector corresponding to the text to be classified.
[0202] In one embodiment, the processor 901, when calling the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector, can be specifically used to:
[0203] If there is a target reference vector in the reference vector set, the similarity score corresponding to the target reference vector is adjusted to a target score, and the target reference vector refers to a reference vector with a similarity score less than a similarity threshold;
[0204] Call the feature fusion module to perform feature fusion on the category label and the target score included in the target reference vector, and the category label and the similarity score included in the remaining reference vector, to obtain an auxiliary vector corresponding to the text to be classified;
[0205] Wherein, the remaining reference vector refers to a reference vector in the reference vector set other than the target reference vector.
[0206] In one embodiment, the analysis submodule includes a third text processing module and a memory network, the memory network stores reference text feature vectors corresponding to a reference text set, the reference text feature vectors corresponding to the reference text set are obtained by performing feature vector analysis on the reference texts in the reference text set using a fourth text processing model, and the processor 901, when calling the analysis submodule to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vectors corresponding to the reference text set, can be specifically used to:
[0207] Call the third text processing module to perform text processing on the text to be classified to obtain a text feature vector corresponding to the text to be classified;
[0208] Call the memory network to perform similarity calculation on the text feature vector and the reference text feature vectors corresponding to the reference text set to obtain a similarity score of the text feature vector and the reference text feature vector.
[0209] In one embodiment, the number of reference text feature vectors is a plurality, and the processor 901, when obtaining a reference vector set including one or more reference vectors according to the similarity analysis result, can be specifically used to:
[0210] Determine a target reference text feature vector according to the similarity score of the text feature vector of the text to be classified and each reference text feature vector;
[0211] Obtain a reference vector corresponding to the target reference text feature vector according to the category label and the similarity score corresponding to the target reference text feature vector.
[0212] adding the reference vector corresponding to the target reference text feature vector to a reference vector set.
[0213] In an embodiment, the processor 901, when determining the target reference text feature vector according to the similarity scores of the text feature vector of the text to be classified and each reference text feature vector, can be specifically configured to:
[0214] arranging the similarity scores of the text feature vector of the text to be classified and each reference text feature vector in descending order to obtain an arrangement result;
[0215] determining the reference text feature vectors corresponding to the top K similarity scores in the arrangement result as the target reference text feature vectors respectively, K being an integer greater than or equal to 1.
[0216] In an embodiment, the processor 901 is further configured to:
[0217] obtaining a target training set, the target training set including a plurality of sample texts and a category label corresponding to each sample text;
[0218] calling an initial model to perform classification processing on each sample text to obtain a predicted category to which the sample text belongs;
[0219] determining a model loss value according to the predicted category to which each sample text belongs and the corresponding category label;
[0220] updating model parameters of the initial model based on the model loss value to obtain a text classification model.
[0221] In an embodiment, the processor 901, when obtaining a target training set, can be specifically configured to:
[0222] obtaining an initial training set, the initial training set including a plurality of initial training samples;
[0223] calling a text screening model to perform classification processing on the initial training set to obtain a text category to which each initial training sample belongs and a category confidence;
[0224] determining a plurality of sample texts from the initial training set according to the text category to which each initial training sample belongs and the category confidence, and adding the plurality of sample texts to the target training set.
[0225] In an embodiment, the text screening model outputs M text categories, the text category to which each initial training sample belongs belongs to any one of the M text categories, and M is an integer greater than or equal to 1.
[0226] In an embodiment, the processor 901 can be specifically configured to:
[0227] add each initial training sample to a sample set corresponding to a text category to which the initial training sample belongs according to the text category, to obtain the sample set corresponding to the M text categories;
[0228] select, from each sample set corresponding to a text category, an initial training sample whose category confidence satisfies a category screening condition;
[0229] use the selected initial training sample as a sample text.
[0230] It should be understood that, in the embodiments of the present application, the processor 901 can be a central processing unit (CPU), and the processor 901 can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0231] In the embodiments of the present application, the computer device can obtain characters of different lengths to extract text features; meanwhile, the computer device can analyze the text to be classified according to a reference vector set corresponding to a plurality of reference texts associated with the text to be classified, to obtain an auxiliary vector corresponding to the text to be classified. The text to be classified is classified based on the first vector, the second vector and the auxiliary vector, to obtain a target category to which the text to be classified belongs. The classification effect of the text to be classified is improved as a whole, and the accuracy of text classification is improved by analyzing the first character set and the second character set in the text to be classified.
[0232] In the embodiments of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program includes program instructions, and the program instructions are executed by a processor to perform the steps in all the embodiments.
[0233] The embodiment of the present application further provides a computer program product or computer program, the computer program product or computer program comprising computer instructions, the computer instructions being stored in a computer readable storage medium, and the computer instructions being executed by a processor of a computer device to perform the method in any of the above embodiments.
[0234] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the program can be stored in a computer readable storage medium. When the program is executed, the program can include the processes of the above-mentioned embodiment methods. The storage medium can be a magnetic disc, an optical disc, a read-only memory (ROM), a random access memory (RAM), or the like.
[0235] The above only discloses a preferred embodiment of the present application, and of course cannot limit the scope of the rights of the present application. Those skilled in the art can understand that all or part of the processes of the above-mentioned embodiment can be implemented, and equivalent changes made according to the claims of the present application still fall within the scope of the present application.
Claims
1. A method of text classification, characterized by, The application is applied to a text classification model, the text classification model comprises a classifier and a first text processing module, a second text processing module and an auxiliary text processing module connected with the classifier respectively; the auxiliary text processing module comprises an analysis submodule and a feature fusion module constructed based on a memory network, the memory network is an end-to-end structure, the memory network is used for storing reference text feature vectors corresponding to a reference text set, and model parameters of the memory network and the stored reference text feature vectors are dynamically updated in the process of training the text classification model; the method comprises: obtaining a text to be classified; calling the first text processing module to perform text analysis on a first character set included in the text to be classified, and obtaining a first vector corresponding to the text to be classified; calling the second text processing module to perform text analysis on a second character set included in the text to be classified, and obtaining a second vector corresponding to the text to be classified; the lengths of characters included in the first character set and the second character set are different, and the maximum input length of the second text processing module is greater than the maximum input length of the first text processing module; calling the analysis submodule to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vector corresponding to the reference text set, and obtaining a similarity analysis result; obtaining a reference vector set comprising one or more reference vectors according to the similarity analysis result, each reference vector comprising a category label and a similarity score, and the category label included in each reference vector being from the quality inspection result of the reference text corresponding to the reference vector; calling the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector, and obtaining an auxiliary vector corresponding to the text to be classified; calling the classifier to perform classification processing on the text to be classified based on the first vector, the second vector and the auxiliary vector, and obtaining a target category to which the text to be classified belongs.
2. The method of claim 1, wherein, The calling of the feature fusion module to perform feature fusion on the category label and the similarity score included in each reference vector, and the obtaining of the auxiliary vector corresponding to the text to be classified, comprises: if there is a target reference vector in the reference vector set, adjusting the similarity score corresponding to the target reference vector to a target score, the target reference vector being a reference vector with a similarity score less than a similarity threshold; calling the feature fusion module to perform feature fusion on the category label and the target score included in the target reference vector, and the category label and the similarity score included in the remaining reference vectors, and obtaining the auxiliary vector corresponding to the text to be classified; wherein, the remaining reference vectors are reference vectors other than the target reference vector in the reference vector set.
3. The method of claim 1, wherein, The analysis submodule includes a third text processing module and a memory network, the reference text feature vector corresponding to the reference text set is obtained by performing feature vector analysis processing on the reference text in the reference text set by the fourth text processing model, the analysis submodule is called to perform similarity analysis on the text feature vector of the text to be classified and the reference text feature vector corresponding to the reference text set, and a similarity analysis result is obtained, including: The third text processing module is called to perform text processing on the text to be classified, and a text feature vector corresponding to the text to be classified is obtained. The memory network is called to perform similarity calculation on the text feature vector and the reference text feature vector corresponding to the reference text set, and a similarity score of the text feature vector and the reference text feature vector is obtained.
4. The method of claim 3, wherein, The number of reference text feature vectors is multiple, the reference vector set including one or more reference vectors is obtained according to the similarity analysis result, including: A target reference text feature vector is determined according to the similarity score of the text feature vector of the text to be classified and each reference text feature vector; A reference vector corresponding to the target reference text feature vector is obtained according to the category label and the similarity score corresponding to the target reference text feature vector; The reference vector corresponding to the target reference text feature vector is added to the reference vector set.
5. The method of claim 4, wherein, The target reference text feature vector is determined according to the similarity score of the text feature vector of the text to be classified and each reference text feature vector, including: The similarity scores of the text feature vector of the text to be classified and each reference text feature vector are arranged in descending order to obtain an arrangement result; The reference text feature vectors corresponding to the first K similarity scores are determined from the arrangement result as target reference text feature vectors, and K is an integer greater than or equal to 1.
6. The method of claim 1, wherein, The method further includes: Obtaining a target training set, the target training set including multiple sample texts and a category label corresponding to each sample text; An initial model is called to classify each sample text to obtain a predicted category to which each sample text belongs; A model loss value is determined according to the predicted category to which each sample text belongs and the corresponding category label; The model parameters of the initial model are updated based on the model loss value to obtain a text classification model.
7. The method of claim 6, wherein, The target training set is obtained, including: An initial training set is obtained, the initial training set including multiple initial training samples; A text screening model is called to classify the initial training set to obtain a text category to which each initial training sample belongs and a category confidence; Multiple sample texts are determined from the initial training set according to the text category to which each initial training sample belongs and the category confidence, and the multiple sample texts are added to the target training set.
8. The method of claim 7, wherein, The text screening model outputs M text categories, the text category to which each initial training sample belongs belongs to any text category in the M text categories, and M is an integer greater than or equal to 1.
9. The method of claim 8, wherein, The method comprises the following steps: According to the text category to which each initial training sample belongs, adding each initial training sample to a sample set corresponding to M text categories, to obtain the sample set corresponding to the M text categories; Respectively screening initial training samples with a category confidence satisfying a category screening condition from each sample set corresponding to a text category; Screening the obtained initial training samples as sample texts.
10. A text classification apparatus characterized by comprising: A text classification model is called to determine a target category to which the text to be classified belongs; the text classification model comprises a classifier and a first text processing module, a second text processing module, and an auxiliary text processing module connected with the classifier respectively; the auxiliary text processing module comprises an analysis submodule and a feature fusion module constructed based on a memory network; the memory network is an end-to-end structure, and is used to store reference text feature vectors corresponding to a reference text set; model parameters of the memory network and the stored reference text feature vectors are dynamically updated in the process of training the text classification model; comprising: An acquisition unit is configured to acquire the text to be classified; A processing unit is configured to call the first text processing module to perform text analysis on a first character set included in the text to be classified, to obtain a first vector corresponding to the text to be classified; The processing unit is further configured to call the second text processing module to perform text analysis on a second character set included in the text to be classified, to obtain a second vector corresponding to the text to be classified; the lengths of characters included in the first character set and the second character set are different, and the maximum input length of the second text processing module is greater than the maximum input length of the first text processing module; The processing unit is further configured to call the analysis submodule to perform similarity analysis on a text feature vector of the text to be classified and reference text feature vectors corresponding to the reference text set, to obtain a similarity analysis result; according to the similarity analysis result, a reference vector set comprising one or more reference vectors is obtained, each reference vector comprising a category label and a similarity score; the category label included in each reference vector is from a quality inspection result of a reference text corresponding to the reference vector; the feature fusion module is called to perform feature fusion on the category label and the similarity score included in each reference vector, to obtain an auxiliary vector corresponding to the text to be classified; The processing unit is further configured to call the classifier to perform classification processing on the text to be classified based on the first vector, the second vector, and the auxiliary vector, to obtain the target category to which the text to be classified belongs.
11. A computer device, comprising: A memory is configured to store a computer program; A processor is configured to run the computer program stored in the memory, to implement the text classification method according to any one of claims 1-9. The computer storage medium stores a computer program, and the computer program is executed by a processor to implement the text classification method according to any one of claims 1-9.
12. A computer storage medium, characterized in that 13. A computer program product, characterised in that, The computer program product comprises a computer program which, when executed by a processor, is adapted to implement the text classification method according to any one of claims 1-9. The computer program product comprises a computer program which, when executed by a processor, is adapted to implement the text classification method according to any one of claims 1-9.
Citation Information
Patent Citations
Long text classification method and device based on word bag model, computer equipment and storage medium
CN110096591A
Text classification method and device, equipment and storage medium
CN113268597A