Text identification method, device, equipment and storage medium based on deep learning
Through deep learning methods, character-word vector transformation and fusion feature extraction of text titles and contents is solved, which solves the problem of insufficient accuracy of text classification, especially when identifying vulgar information, which significantly improves the recognition ability of the model.
Patent Information
- Application Number
- CN202110037860.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-12
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-01-12
AI Technical Summary
The accuracy of text classification in the prior art is insufficiently improved, especially when identifying vulgar information.
The text identification method based on deep learning is adopted. By obtaining the text title and content of the target text to be identified, the words and sentences are parsed and converted into character vectors, and the fusion feature extraction is performed to generate text vectors to determine category attributes.
It improves the accuracy of text classification, especially when identifying vulgar information, which can better understand the target text to be identified, and improves the recognition ability of the model.
Smart Images

Figure CN113535946B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of artificial intelligence and cloud technology. Specifically, the present application relates to a text identification method, apparatus, device and storage medium based on deep learning. Background Art
[0002] With the research and advancement of artificial intelligence (AI) technology, it has played an increasingly important role in the field of information processing. Text classification is a widely used application of AI technology. Text classification models enable rapid text classification. For example, in the application scenario of recommending information to users, information needs to be filtered before being recommended to improve user perception. For example, it is necessary to identify vulgar information in recommended information so that high-quality information can be recommended to users. Identifying vulgar information is a form of text classification.
[0003] Although there are many text classification methods in the prior art, improving the accuracy of text classification has always been one of the issues that need to be improved. Summary of the Invention
[0004] The embodiments of the present application provide a deep learning-based text identification method, apparatus, device, and storage medium that can improve the accuracy of text classification.
[0005] In one aspect, an embodiment of the present application provides a text identification method based on deep learning, the method comprising:
[0006] Obtaining the target text to be identified, the target text to be identified includes the text title and text content;
[0007] Call the pre-trained text classification model to perform category attribute identification on the target text to be identified, so as to obtain the category attributes to which the target text to be identified belongs, including:
[0008] Parsing the target text for identification by analyzing the title and content of the target text to obtain the characters of the target text;
[0009] Perform word vector conversion on each character of the target text to be identified to obtain a word vector for each character;
[0010] The word vectors of each character are fused and feature extracted to obtain the text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector.
[0011] On the other hand, an embodiment of the present application provides a text identification device based on deep learning, comprising:
[0012] A text acquisition module is used to acquire the target text to be identified, and the target text to be identified includes the text title and text content;
[0013] The text identification module is used to call the pre-trained text classification model to perform category attribute identification processing on the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs. The text identification module is specifically used to:
[0014] Parsing the target text for identification by analyzing the title and content of the target text to obtain the characters of the target text;
[0015] Perform word vector conversion on each character of the target text to be identified to obtain a word vector for each character;
[0016] The word vectors of each character are fused and feature extracted to obtain the text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector.
[0017] In a possible implementation, the device further includes:
[0018] A position vector determination module is used to perform vector conversion processing on the position of each character in the target text to be identified to obtain the position vector of each character;
[0019] The text identification module extracts the fusion features of the word vectors of each character to obtain the text vector of the target text to be identified. Specifically, it is used to:
[0020] For each character, the first target vector is obtained by concatenating the character's position vector and the character's word vector;
[0021] The first target vector of each character is subjected to fusion feature extraction to obtain the text vector of the target text to be identified.
[0022] In a possible implementation, the method further includes:
[0023] An attribution vector determination module is used to obtain an attribution vector for each character based on the text title or text content to which each character belongs in the target text to be identified;
[0024] The text identification module extracts the fusion features of the word vectors of each character to obtain the text vector of the target text to be identified. Specifically, it is used to:
[0025] For each character, a second target vector is obtained by concatenating the character's word vector and the character's belonging vector;
[0026] The second target vector of each character is subjected to fusion feature extraction to obtain the text vector of the target text to be identified.
[0027] In a possible implementation, the method further includes:
[0028] The weight acquisition module is used to obtain the weight of the text title and the weight of the text content;
[0029] The text identification module extracts the fusion features of the word vectors of each character to obtain the text vector of the target text to be identified. Specifically, it is used to:
[0030] According to the text title or text content to which each character belongs, the character's word vector is weighted with the corresponding weight to obtain a weighted word vector;
[0031] The weighted word vectors of each character are fused and feature extracted to obtain the text vector of the target text to be identified.
[0032] In one possible implementation, when the text identification module extracts the fused features of the word vectors of each character to obtain the text vector of the target text to be identified, it is specifically used to:
[0033] For each character, determining the relevance of the character to each of the characters based on the word vector of the character and the word vector of each of the characters;
[0034] For each character, based on the correlations corresponding to the character, the word vectors of the characters corresponding to the correlations are weightedly fused to obtain the fused vector of the character;
[0035] The fusion feature extraction is performed on the fusion vector of each character to obtain the text vector of the target text to be identified.
[0036] In one possible implementation, the text classification model is trained by a text training module, which is specifically used to:
[0037] Obtain labeled datasets and unlabeled datasets annotated with real text category attribute labels;
[0038] Based on the labeled dataset and the unlabeled dataset, the model parameters of the initial text classification model are adjusted by repeatedly performing the following operations until the preset end conditions are met to obtain the final text classification model:
[0039] Input each unlabeled text in the unlabeled data set into the text classification model based on the last model parameter adjustment to obtain the predicted probability of each unlabeled text corresponding to each text category attribute;
[0040] For each unlabeled text, if the difference between the predicted probabilities of the unlabeled text is less than or equal to a first set threshold, the unlabeled text is determined as the first target text;
[0041] Obtain each first target text annotated with a real text category attribute label, add each annotated first target text to the labeled dataset, and delete each first target text from the unlabeled dataset;
[0042] Each labeled text in the labeled data set is input into the text classification model to obtain the predicted probability of each labeled text corresponding to each text category attribute. The value of the loss function is determined based on the predicted probability of each labeled text and the true text category attribute label, and the model parameters are adjusted based on the value of the loss function.
[0043] In a possible implementation, for any first target text, the real text category attribute label of the first target text is obtained by annotating in the following manner:
[0044] Calling a pre-trained target classification model to perform category attribute identification processing on the first target text to obtain the category attribute to which the first target text belongs;
[0045] According to the category attribute to which the first target text belongs, a real text category attribute label of the first target text is marked.
[0046] In a possible implementation, for any operation, the text training module is further configured to:
[0047] For each unlabeled text, if any predicted probability of the unlabeled text is greater than or equal to a second set threshold corresponding to the predicted probability, the unlabeled text is determined as a second target text, and each second target text is deleted from the unlabeled dataset;
[0048] For each second target text, determining the text category attribute corresponding to the predicted probability of the second target text that is greater than or equal to the second set threshold as the true text category attribute label of the second target text;
[0049] The text training module inputs each labeled text in the labeled data set into the text classification model to obtain the predicted probability of each labeled text corresponding to each text category attribute. The module determines the value of the loss function based on the predicted probability of each labeled text and the actual text category attribute label. Specifically, it is used to:
[0050] Input each labeled text in the labeled data set and each second target text determined in this operation into the text classification model to obtain the predicted probability of each labeled text and each second target text corresponding to each text category attribute;
[0051] The value of the loss function is determined based on the predicted probabilities corresponding to each labeled text and each second target text and the true text category attribute label.
[0052] In one possible implementation, for any operation, when the text training module determines the value of the loss function based on the predicted probabilities corresponding to each labeled text and each second target text and the true text category attribute label, it is specifically configured to:
[0053] Calculate a first loss value based on the true text category attribute label and each predicted probability of each labeled text;
[0054] Determine a second loss value based on the true text category attribute label and each predicted probability of each second target text determined in this operation;
[0055] A value of a loss function is determined based on the first loss value and the second loss value.
[0056] In one possible implementation, the text classification model is a binary classification model for classifying a first text category attribute and a second text category attribute, the target text to be identified is text information in the content to be recommended, and the device further includes:
[0057] The to-be-recommended content processing module is configured to recommend the to-be-recommended content to the user if the category attribute of the text information is the first text category attribute; and to filter out the to-be-recommended content if the category attribute of the text information is the second text category attribute.
[0058] On the other hand, an embodiment of the present application provides an electronic device, which includes a memory and a processor, wherein a computer program is stored in the memory; when the processor runs the computer program, it executes the deep learning-based text identification method provided in any optional embodiment of the present application.
[0059] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the deep learning-based text identification method provided in any optional embodiment of the present application.
[0060] The beneficial effects of the technical solution provided by this application are:
[0061] The present application provides a text identification method, apparatus, device and storage medium based on deep learning. Compared with the prior art, the target text to be identified in the present application includes a text title and text content. A text classification model can be called to perform word and sentence parsing of the text title and text content to obtain each character of the target text to be identified, and each character is converted into a word vector to obtain a word vector of each character. The word vector of each character is fused with features to extract the text vector, so as to obtain the category attribute to which the target text to be identified belongs according to the text vector. Since the text classification model performs fused feature extraction based on the word vectors of each character in the title and the word vectors of each character in the text when classifying the text, the extracted text vector can better express the target text to be identified, so that when the model performs text classification based on the text vector, the model can better understand the target text to be identified, and can effectively improve the accuracy of the model in identifying text categories. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments of the present application.
[0063] Figure 1 A schematic diagram of pre-training of a text feature extraction module provided in an embodiment of the present application;
[0064] Figure 2 A diagram of the training process of a text classification model provided in an embodiment of the present application;
[0065] Figure 3 A schematic diagram of a recommended content display interface provided in this embodiment;
[0066] Figure 4A A flowchart of a text identification method based on deep learning provided in an embodiment of the present application;
[0067] Figure 4B A schematic diagram of a process for determining text category attributes provided in an embodiment of the present application;
[0068] Figure 5 A flowchart of a text classification model training method provided in an embodiment of the present application;
[0069] Figure 6 A flowchart of a text vector determination method provided in an embodiment of the present application;
[0070] Figure 7 A schematic diagram of the structure of a text identification device based on deep learning provided in an embodiment of the present application;
[0071] Figure 8A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0072] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and are not to be construed as limiting the present application.
[0073] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any units and all combinations of one or more associated listed items.
[0074] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0075] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0076] The present application provides a text identification method based on deep learning. Compared with the prior art, the target text to be identified in the present application includes a text title and text content. A text classification model can be called to perform word and sentence parsing of the text title and text content to obtain each character of the target text to be identified, and each character is converted into a word vector to obtain a word vector of each character. The word vector of each character is fused with feature extraction to obtain a text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector. Since the text classification model performs fused feature extraction based on the word vectors of each character in the title and the word vectors of each character in the text when classifying the text, the extracted text vector can better express the target text to be identified, so that when the model performs text classification based on the text vector, the model can better understand the target text to be identified, and can effectively improve the accuracy of the model in identifying text categories.
[0077] The optional embodiments of the present application can be implemented based on artificial intelligence technology, such as using artificial intelligence technology to determine the category of the target text to be identified.
[0078] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0079] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0080] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0081] The data involved in the various optional embodiments provided in this application can be implemented based on cloud technology, and the data processing / data calculation involved in the implementation of the solution can be implemented based on cloud computing.
[0082] Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide or local area network (WAN) to enable data computing, storage, processing, and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used on demand with flexibility and convenience. Cloud computing technology will become a crucial support. Backend services for technical network systems, such as video websites, image websites, and more portals, require extensive computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identification mark and will need to be transmitted to backend systems for logical processing. Data of varying levels will be processed separately, and data from all industries will require a strong system backend, which can only be achieved through cloud computing.
[0083] Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network that provides these resources is called the "cloud." To users, these resources appear infinitely scalable and can be accessed at any time, used on demand, expanded at any time, and paid for on a per-use basis.
[0084] As a provider of cloud computing infrastructure, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) is established. Various types of virtual resources are deployed in the resource pool for external customers to choose and use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0085] Based on logical functional divisions, the PaaS (Platform as a Service) layer can be deployed on top of the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. SaaS can also be deployed directly on top of IaaS. PaaS is a platform for software execution, such as databases and web containers. SaaS is a variety of business software, such as web portals and text messaging tools. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
[0086] Cloud computing refers to the delivery and usage model of IT infrastructure, enabling on-demand, scalable access to required resources over the internet. Broadly speaking, cloud computing refers to the delivery and usage model of services, enabling on-demand, scalable access to required services over the internet. These services can be IT-related, software-related, internet-related, or other services. Cloud computing is the product of the convergence of traditional computer and network technologies, including grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0087] Cloud computing has rapidly grown, driven by the internet, real-time data streams, the diversification of connected devices, and the growing demand for search services, social networks, mobile commerce, and open collaboration. Unlike previous parallel and distributed computing approaches, the emergence of cloud computing will fundamentally revolutionize the entire internet and enterprise management model.
[0088] An embodiment of the present application provides a text identification method based on deep learning, which can be executed by any electronic device, which can be a terminal device, a server or a server cluster, wherein the server cluster includes at least one server, which can be a physical server or the cloud server mentioned above.
[0089] In order to better understand and illustrate the embodiments of the present application, some technical terms involved in the embodiments of the present application are first explained below.
[0090] Easy-to-classify text: A text is input into the text classification model, and the text classification model outputs the probability of the text belonging to each text category. If the probability of the text belonging to a certain text category is significantly greater than the probability of the text belonging to other text categories except the text category, that is, the difference between the probability of the text belonging to the text category and the probability of the text belonging to any other text category is greater than or equal to a first preset value, then it indicates that the text is easy to classify.
[0091] For example, text A is input into a text classification model, and the text classification model outputs the probabilities that text A belongs to text categories 1-3 respectively. If the probabilities that text A belongs to text categories 1-3 are 0.85, 0.05, and 0.1 respectively, and the first set value is 0.7, it can be clearly concluded that the probability that text A belongs to text category 1, 0.85, is significantly greater than the probability that text A belongs to text category 2, 0.05, and the probability that text A belongs to text category 1, 0.85, is significantly greater than the probability that text A belongs to text category 3, 0.1. In other words, the difference (0.8) between the probability that text A belongs to text category 1, 0.85, and the probability that text A belongs to text category 2, 0.05, is greater than the first set value (0.75), and the difference (0.75) between the probability that text A belongs to text category 1, 0.85, and the probability that text A belongs to text category 3, 0.1, is also greater than the first set value (0.7), which indicates that text A is easily categorized.
[0092] Difficult-to-classify text: A text is input into a text classification model, and the text classification model outputs the probability of the text belonging to each text category. If the probability of the text belonging to a certain text category is close to the probability of the text belonging to another text category other than the text category, that is, the difference between the probability of the text belonging to a certain text category and the probability of the text belonging to another text category is less than or equal to a second preset value, then it indicates that the text is difficult to classify.
[0093] For example, if text A is input into a text classification model, and the model outputs the probabilities that text A belongs to text categories 1-3, respectively, and the probabilities that text A belongs to text categories 1-3 are 0.47, 0.5, and 0.03, respectively, and the second set value is 0.1, it can be clearly concluded that the probability that text A belongs to text category 1 (0.47) is similar to the probability that text A belongs to text category 2 (0.5). In other words, the difference (0.03) between the probability that text A belongs to text category 1 (0.47) and the probability that text A belongs to text category 2 (0.5) is less than the second set value (0.1), indicating that text A is difficult to classify.
[0094] Vulgar text: If a text contains content that is of low taste, ridiculous, vulgar, depressing, hooligan, decadent, etc., the text is a vulgar text. For example, if a text contains content that is of low taste, the text is a vulgar text.
[0095] Active learning: Use a certain algorithm to query the most useful unlabeled samples, and then have them labeled by experts. Then use the expert-labeled samples to train the classification model to improve the model's accuracy.
[0096] Pseudo-label learning: Use labeled data to train a classification model, and use this classification model to classify unlabeled data, which will generate pseudo labels. Unlabeled samples that are considered to be correctly classified are selected, and the selected unlabeled samples are used to optimize the training classification model.
[0097] The solution of the present application will be described in detail below in conjunction with a specific optional embodiment. For the convenience of description and explanation, the text identification method based on deep learning of the embodiment of the present application will be described in detail from two aspects, one aspect is the training method of the text classification model, and the other aspect is the text classification method.
[0098] In the training method of the text classification model, the initial text classification model includes a cascaded text feature extraction module and a text category prediction module. The specific network structure of the text feature extraction module and the text category prediction module is not limited in this embodiment of the application and can be configured according to actual needs. Among them, the text feature extraction module is used to extract the semantic features of the text input to the text classification model, and the text category prediction model is used to predict the category of the text based on the semantic features.
[0099] Optionally, the text feature extraction module can be a feature extraction module based on a bidirectional encoder representation (Bidirectional Encoder Representations from Transformers, BERT) model, which can be referred to as a BERT model. That is, as an optional solution, the text classification model can be constructed based on the BERT model. Optionally, in order to improve the training efficiency and performance of the initial text classification model, the text feature extraction module in the initial text classification model can be a pre-trained text feature extraction module. For example, the text feature extraction module can be a pre-trained BERT model, and the text category prediction module can be cascaded to the pre-trained BERT model to obtain the initial text classification model.
[0100] Optionally, the text category prediction module may be a classifier. The specific structure of the classifier is not limited in the embodiment of the present application. For example, the classifier may include a cascaded fully connected layer and a Softmax layer.
[0101] As an optional implementation, such as Figure 1 As shown, Figure 1A schematic diagram of a pre-training process for a text feature extraction module provided in an embodiment of the present application. The pre-training phase of the text feature extraction module can be based on the task of training a masked language model (MLM). In layman's terms, this involves randomly masking a portion of characters in a sentence and then simultaneously predicting the masked characters using contextual information.
[0102] like Figure 1 As shown, sentence A includes N characters, which are respectively recorded as characters A1, ..., and An, and sentence B includes M characters, which are respectively recorded as characters B1, ..., and Bm, where M and N are both positive integers. When sentences A and B are input into the text feature extraction module, it is necessary to add the first character before sentence A, for example, the first character can be the [CLS] mark, and add a separator character between sentences A and B, for example, the separator character can be the [SEP] mark. That is, when sentences A and B need to be input into the text feature extraction module, the actual input is the first character, characters A1, ..., characters An, the separator character, characters B1, ..., and characters Bm.
[0103] Among them, the first character and the separator character are characters with special functions in the text feature extraction module. The first character is placed in front of the first sentence, and the separator character is placed between two input sentences to separate the two input sentences.
[0104] After the first character, character A1, ..., character An, separator character, character B1, ..., character Bm are input into the text feature extraction module, the text feature extraction module can convert each character into the initial feature vector corresponding to the character, referred to as the initial vector for short, and based on the initial vector of each character, obtain the final feature vector of each character, also called the fused feature vector, referred to as the fused vector for short. The text feature extraction module can output the fused vector of each character.
[0105] like Figure 1 In the text, the first character, character A1, ..., character An, separator character, character B1, ..., character Bm are input into the text feature extraction module. The text feature extraction module can convert the first character, character A1, ..., character An, separator character, character B1, ..., character Bm into the initial vectors corresponding to each character, which are the first initial vector, A1 initial vector, ..., An initial vector, separator initial vector, B1 initial vector, ..., Bm initial vector respectively. The text feature extraction module can obtain the fusion vector corresponding to each character based on the initial vectors corresponding to each character and output the fusion vector corresponding to each character, including the first fusion vector, A1 fusion vector, ..., An fusion vector, separator fusion vector, B1 fusion vector, ..., Bm fusion vector.
[0106] Among them, the first fusion vector is the feature vector corresponding to the classification symbol bit output by the text feature extraction module, and the first fusion vector can be used to represent the sentence vector of the sentence input into the text feature extraction module.
[0107] When pre-training the text feature extraction module, it can be based on the MLM task training. A portion of the characters in sentence A and sentence B can be randomly masked, and then the masked characters can be predicted using the uncovered characters in sentence A and sentence B. That is, some of the characters A1, ..., character An and characters B1, ..., character Bm are randomly masked, and the first character, character A1, ..., character An, the separator character, character B1, ..., character Bm are input into the text feature extraction module, and the text feature extraction module outputs the first fusion vector, A1 fusion vector, ..., An fusion vector, separator fusion vector, B1 fusion vector, ..., Bm fusion vector. Among them, the characters input into the text feature extraction module include masked characters and uncovered characters, and the fusion vectors output by the text feature extraction module include feature vectors obtained by predicting the masked characters.
[0108] like Figure 2 As shown, Figure 2 A training flow diagram of a text classification model provided in an embodiment of the present application. When training the text classification model, a large amount of text corpus (i.e., text) can be acquired in advance to form a text corpus, and any text corpus includes a text title and text content. Part of the text corpus is randomly selected from the text corpus, and this part of the text corpus is annotated by experts, that is, manually annotated to form a first data set, and the remaining unannotated text corpus in the text corpus constitutes a second data set. For ease of distinction and explanation, the text corpus after manual annotating in the first data set is referred to as the first text, and the unannotated text corpus in the second data set is referred to as the second text.
[0109] When manually annotating text corpora, any text corpora can be labeled with a label. The label can be a vulgar label or a non-vulgar label. That is, any annotated text corpus includes the original text corpus and its label. If the text corpus is a vulgar text, the text corpus is labeled with a vulgar label; if the text corpus is a non-vulgar text, the text corpus is labeled with a non-vulgar label. If the label of the text corpus is a vulgar label, it indicates that the text corpus is a vulgar text, that is, the probability of the text corpus being a vulgar text is 1, and the probability of being a non-vulgar text is 0; if the label of the text corpus is a non-vulgar label, it indicates that the text corpus is a non-vulgar text, that is, the probability of the text corpus being a vulgar text is 0, and the probability of being a non-vulgar text is 1.
[0110] For example, a text corpus containing vulgar content is a vulgar text and can be labeled as vulgar.
[0111] It is understandable that the text corpus in the text corpus is large, usually hundreds of thousands or even millions or tens of millions. A smaller amount of text corpus can be selected from the text corpus for manual annotation. For example, selecting tens of thousands of text corpora for manual annotation can reduce the number of manually annotated text corpora and save manpower.
[0112] like Figure 2 As shown, in this embodiment, samples are randomly selected from the text corpus for annotation, that is, part of the text corpus is randomly selected from the text corpus for manual annotation to form a first data set, the first data set is used to train the initial text classification model, the value of the loss function corresponding to this training is calculated, and the model parameters are adjusted based on the value of the loss function.
[0113] Specifically, the first data set can be input into the initial text classification model (the text classification model trained this time is the initial text classification model). For each first text in the first data set, the first text is input into the initial text classification model in the form of a sentence, that is, a sentence is input into the initial text classification model, and the text classification model can perform word analysis on the sentence to obtain each character in the sentence, such as Figure 2 In the example, characters 1, ..., and n are used to represent the individual characters in the sentence. The first character and each character of the sentence can be input into a text feature extraction module, which outputs a feature vector corresponding to the classification symbol bit, i.e., the first fusion vector. This feature vector can be used as the sentence vector of the first text. The sentence vector of the first text is input into a classifier, which outputs a predicted probability of the first text, i.e., the probability of the first text being a vulgar text or a non-vulgar text.
[0114] In this embodiment, if a text is vulgar, it is a negative sample; if it is non-vulgar, it is a positive sample. Therefore, the classifier can predict the probability of the first text being a positive or negative sample, respectively. The loss function value corresponding to this training is calculated based on the predicted probability of each first text and its corresponding annotation result. Based on the loss function value, the parameters of the initial text classification model are adjusted to obtain the text classification model after the model parameter adjustment for this training.
[0115] In this embodiment, the text classification model includes a text feature extraction module and a classifier, wherein the text feature extraction module can provide a conversion field, so that each character in the sentence can be conveniently converted into a word vector, and the text feature extraction module can output the first fusion vector, which is input into the classifier, and the classifier outputs the probability of positive and negative samples, and the output of the classifier can be used as the output of the text classification model.
[0116] It should be noted that Figure 2 When inputting each character in a sentence into the text feature extraction module, it is necessary to add the first character in front of each character, that is, input the first character, character 1, ..., character n into the text feature extraction module. The text feature extraction module can convert each input character into the initial vector corresponding to each character. The initial vector corresponding to each character can be represented by the first initial vector, 1 initial vector, ..., n initial vector, respectively. The first initial vector is the feature vector corresponding to the first character. Usually, the first initial vector is a preset feature vector. The text feature extraction module can perform fusion feature extraction on the initial vector corresponding to each character to obtain the fusion vector corresponding to each character. The fusion vector corresponding to each character can be represented by the first fusion vector, 1 fusion vector, ..., n fusion vector, respectively. The first fusion vector is the feature vector corresponding to the classification symbol bit output by the text feature extraction module, which can be used to represent the sentence vector of the sentence input into the text feature extraction module, and n is a positive integer.
[0117] It should be noted that the text feature extraction module can perform fusion feature extraction on the initial vectors corresponding to each character to obtain the fusion vectors corresponding to each character. Please refer to the relevant descriptions of implementation methods A1 to A4 below and will not be repeated here.
[0118] Furthermore, when the current text classification model (the text classification model after the model parameters are adjusted when the initial text classification model is trained, that is, the text classification model after the model parameters are adjusted in the last training) is trained for the next time, the first data set can be updated using the second data set, and pseudo samples can be obtained using the second data set. Then, the current text classification model can be trained once using the updated first data set and the pseudo samples. This will be explained in detail below.
[0119] Specifically, when using the second data set to update the first data set and using the second data set to obtain pseudo samples, the second data set can be first input into the current text classification model, and the text classification model outputs the predicted probability of each second text in the second data set, that is, predicts the probability of each second text being a positive or negative sample.
[0120] Specifically, the second sample set can be input into the current text classification model. For each second text in the second sample set, the second text is input into the current text classification model in the form of a sentence. That is, the sentence is input into the current text classification model, and the sentence is converted into a word vector by character. That is, each character in the sentence is converted into a feature vector. Each feature vector is input into a text feature extraction module to obtain a feature vector corresponding to the classification symbol bit of the text feature extraction module. This feature vector can be used as the sentence vector of the second text. The sentence vector of the second text is input into a classifier, and the classifier outputs the predicted probability of the second text. That is, the classifier can output the probability of the second text being a vulgar text or a non-vulgar text. In other words, the classifier can predict the probability of the second text being a positive or negative sample, respectively.
[0121] Furthermore, if Figure 2 As shown, the text classification model can output the probability of each second text in the second data set being a positive or negative sample. For each second text, the difference between the probability of the second text being a positive sample and the probability of the second text being a negative sample can also be calculated to obtain the predicted positive and negative sample probability difference. Second texts with a higher predicted probability difference (i.e., predicted positive and negative sample probability difference) are selected from each second text and used to form pseudo samples using pseudo sample technology; second texts with a lower predicted probability difference are selected from each second text and used to form active learning samples using active learning technology.
[0122] When selecting second texts with a high predicted probability difference from each second text to form a pseudo sample, based on the probability of each second text being a positive or negative sample, second texts with a probability of being a positive sample greater than 0.99 can be selected as positive samples. In other words, positive samples with a probability greater than 0.99 are selected from each second text, and second texts with a probability of being a negative sample greater than 0.8 are selected from each second text as negative samples. In other words, negative samples with a probability greater than 0.8 are selected from each second text. Pseudo samples with predicted labels are formed using the selected positive and negative samples, where the positive samples are labeled as non-vulgar labels and the negative samples are labeled as vulgar labels.
[0123] It should be noted that the thresholds of 0.99 (the second threshold mentioned later) and 0.8 (the third threshold mentioned later) are derived based on manual experience and can be adjusted according to actual applications. Generally speaking, the second threshold is greater than the third threshold. This is because there is a large imbalance in the number of positive and negative samples, which causes the text classification model to predict the probability of positive samples too high and the probability of negative samples too low. Therefore, the second threshold can be set to be greater than the third threshold.
[0124] It is understandable that when selecting a positive sample or a negative sample, it is also possible to select a second text with a probability of being a positive sample equal to 0.99 as a positive sample, or select a second text with a probability of being a negative sample equal to 0.8 as a negative sample.
[0125] When selecting second texts with the lowest predicted probability difference from the second texts to form active learning samples, for each second text, the difference between the probability of the second text being a positive sample and the probability of the second text being a negative sample can be calculated based on the probabilities of the second text being a positive sample and a negative sample. If the difference is less than or equal to 0.02, the second text is selected as the text to be annotated, and the text to be annotated is manually annotated to obtain an annotated text. Each annotated text is used to form an active learning sample.
[0126] For example, for a second text, this second text is a vulgar text, but the current text classification model predicts that the probability of the second text being a positive sample is 0.51, that is, the probability of the second text being a non-vulgar text is 0.51, and predicts that the probability of the second text being a negative sample is 0.49, that is, the probability of the second text being a vulgar text is 0.49. The difference between the probability of the positive sample and the probability of the negative sample is 0.02, indicating that the current text classification model cannot accurately predict whether the second text is a vulgar text, that is, the current text classification model has a high degree of uncertainty in judging that the second text is a vulgar text, and the second text can be selected for manual labeling.
[0127] It should be noted that the threshold of 0.02 (i.e., the first set threshold mentioned later) is also obtained based on manual experience and can be adjusted according to actual applications and is not limited in this embodiment. The second text is manually annotated, that is, the label of the second text is manually annotated.
[0128] Furthermore, the active learning samples can be added to the first dataset to update the first dataset, and the pseudo samples can be deleted from the second dataset to update the second dataset. Figure 2 As shown, the current text classification model is trained once using the updated first data set and the pseudo sample. That is, the current text classification model (i.e., the text classification model after the model parameters are adjusted in the previous training) can be trained using the updated first data set and the pseudo sample. The value of the loss function corresponding to this training is calculated, and the model parameters are adjusted based on the value of the loss function to obtain the text classification model after the model parameters are adjusted in this training. Specifically, see the above-mentioned use of the first data set to train the initial text classification model. The two training methods are similar and will not be described in detail here.
[0129] It should be noted that, in each subsequent training, the updated second data set can be input into the text classification model after the model parameters have been adjusted in the previous training. The text classification model predicts the probability of each second text being a positive or negative sample. Then, based on the probability of each second text being a positive or negative sample, pseudo samples and active learning samples are selected. Then, the active learning samples are added to the first data set to update the first data set, and the pseudo samples are deleted from the second data set to update the second data set. Then, the updated first data set and pseudo samples are used to train the text classification model after the model parameters have been adjusted in the previous training. For details, please refer to the above relevant instructions and will not be repeated here.
[0130] In the present embodiment, the initial text classification model can be trained multiple times to obtain the final text classification model. According to the training method of the text classification model provided by the embodiment of the present application, the classification accuracy of the model can be improved. Specifically, the traditional text classification model is obtained by training with a pre-built training data set, which includes multiple texts marked with labels, and the training data set will not be updated during the model training process. The F1 value of the traditional text classification model is 50.9%, while the text classification model obtained by training with the method provided by the embodiment of the present application, that is, the text classification model obtained by training with active learning samples, pseudo samples and pre-built training data sets in the embodiment of the present application, can reach 64.1%. Wherein, the F1 value is also called F1-Score, which is an indicator that can characterize the model precision and recall rate. The F1 value is directly proportional to the model precision and is directly proportional to the model recall rate. In other words, the precision and recall rate of the text classification model obtained by training with the embodiment of the present application are significantly greater than those of the traditional text classification model.
[0131] Furthermore, an embodiment of the present application also provides a text classification method, which can be executed by any electronic device, which can be a terminal device, or a server or a server cluster, wherein the server cluster includes at least one server, and the server here can be a physical server or the cloud server mentioned above.
[0132] In the embodiment of the present application, the final text classification model can be used to determine the category of the text to be processed, thereby classifying the text to be processed. For example, the category of the text to be processed can be divided into vulgar text or non-vulgar text. The text to be processed in the embodiment of the present application is the target text to be identified mentioned later.
[0133] It should be noted that the text classification method provided in the embodiment of the present application can be applied to any scenario for text classification, including but not limited to binary classification scenarios. The training method of the text classification model mentioned above can be used to train to obtain the final text classification model, and the final text classification model can be used to classify the text. According to actual needs, corresponding processing can be performed based on the category of the text to be processed.
[0134] As an optional application scenario, the text classification method in the embodiment of the present application can be applied to an application with an information recommendation function. Based on this method, the category of the text content in the content to be recommended can be identified, and the category of the text content can be used as the category of the content to be recommended.
[0135] As an example, assuming that the category of text content is vulgar text or non-vulgar text, for any content to be recommended, the text classification model can be used to obtain the probability that the text content in the content to be recommended is vulgar text and the probability that it is non-vulgar text. Based on the probability of vulgar text and the probability of non-vulgar text, the category of the text content can be determined, thereby determining the category of the content to be recommended.
[0136] Furthermore, whether to recommend the content to be recommended can be determined based on the result of the category identification of the content to be recommended. If the category of the content to be recommended is vulgar text, the content to be recommended is filtered out, that is, the content to be recommended is not recommended to the user; if the category of the content to be recommended is non-vulgar text, the content to be recommended is recommended to the user.
[0137] As another optional application scenario, all content uploaded by users to the application can be categorized and labeled as either vulgar or non-vulgar based on the category of the content. When making personalized recommendations for users, content associated with the user's preferences can be selected from the non-vulgar content, or the content can be searched from the non-vulgar content based on the user's search request, and the search results can be provided to the user.
[0138] As an optional implementation, for any piece of content to be recommended, the title of the content can be used as the text to be processed. The title is input into the final text classification model, and the text classification model outputs whether the title is classified as vulgar or non-vulgar. If the title is classified as vulgar, the content to be recommended is labeled as vulgar; if the title is classified as non-vulgar, the content to be recommended is labeled as non-vulgar.
[0139] In actual application, each piece of content to be recommended can be labeled with a corresponding vulgar or non-vulgar label offline or online. When recommending content to users online, for each piece of content to be recommended, if the content is labeled as vulgar, it will be filtered out. If the content is labeled as non-vulgar, it will be recommended to the user.
[0140] like Figure 3 As shown, Figure 3 The following is a schematic diagram of a recommended content display interface provided in this embodiment, wherein video 1 and title 1 are recommended content 1, and video 2 and title 2 are recommended content 2. Wherein, title 1 is input into the final text classification model offline, and the output of the text classification model obtains that the category of title 1 is non-vulgar text, and the content 1 to be recommended consisting of video 1 and title 1 is marked with a non-vulgar label; title 2 is input into the final text classification model offline, and the output of the text classification model obtains that the category of title 2 is non-vulgar text, and the content 2 to be recommended consisting of video 2 and title 2 is marked with a non-vulgar label. When recommending online, the contents 1 and 2 to be recommended can be recommended to the user and displayed on the display interface, and the result is as follows. Figure 3 In the display interface shown, at this time, the contents to be recommended 1 and 2 are respectively regarded as the recommended contents 1 and 2.
[0141] The above specifically describes the text identification method based on deep learning from the perspective of specific embodiments. The following describes the text identification method based on deep learning in the embodiment of the present application in detail from the perspective of method steps. Figure 4A As shown, the method includes step S41 and step S42.
[0142] Step S41: obtaining a target text to be identified, where the target text to be identified includes a text title and text content.
[0143] In the embodiment of the present application, the method for obtaining the target text to be identified is not limited. For example, the target text to be identified can be text captured from the Internet, text uploaded by a user, text stored locally, or even text extracted from other multimedia.
[0144] The target text to be identified may include a text title and text content, and the text content may be understood as the text content corresponding to the text title.
[0145] Step S42: calling a pre-trained text classification model to perform category attribute identification processing on the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs.
[0146] In an embodiment of the present application, the target text to be identified can be input into a pre-trained text classification model, and the text classification model outputs the category attribute to which the target text to be identified belongs. In the embodiment of the present application and the previous or following text, the category attribute can be referred to as a text category, or simply category.
[0147] Among them, step S42 is to call the pre-trained text classification model to perform category attribute identification processing on the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs. Specifically, Figure 4B As shown, it includes steps S421 to S423.
[0148] In step S421 , the target text to be identified is subjected to word and sentence parsing of the text title and text content to obtain the characters of the target text to be identified.
[0149] In the embodiment of the present application, the text classification model can perform word and sentence parsing on the title and content of the target text to be identified, respectively, to obtain the characters of the target text to be identified. If the target text to be identified is Chinese text, any character of the target text to be identified can be a word; if the target text to be identified is English text, any character of the target text to be identified can be an English word or a letter.
[0150] Step S422, convert each character of the target text to a word vector to obtain a word vector for each character. Figure 1 or Figure 2 The initial vector of the character shown.
[0151] Step S423, perform fusion feature extraction on the word vector of each character to obtain the text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector. Figure 1 or Figure 2 The first fused vector is shown.
[0152] In an embodiment of the present application, for each character of the target text to be identified, the text classification model can perform word vector conversion processing on the character to obtain the word vector of the character, and the word vector of the character can express the semantics of the character. Furthermore, the text classification model can perform fusion feature extraction on the word vectors of each character of the target text to be identified, so that the text vector of the target text to be identified obtained after the fusion feature extraction can effectively express the text content of the target text to be identified, and the text classification model can determine the category attribute to which the target text to be identified belongs based on the text vector of the target text to be identified. Because the text classification model performs fusion feature extraction based on the word vectors of each character in the title and the word vectors of each character in the text when classifying the text, so that the extracted text vector can better express the target text to be identified, so that when the model performs text classification based on the text vector, the model can better understand the target text to be identified, and can effectively improve the accuracy of the model in identifying the text category.
[0153] The specific method of fusion feature extraction is not limited and can be implemented in various forms. Several possible implementation methods are provided below, which are respectively recorded as implementation methods A1-A4.
[0154] Implementation A1: The text identification method based on deep learning may further include: performing vector conversion processing on the position of each character in the target text to be identified to obtain the position vector of each character.
[0155] In step S423, the word vectors of each character are subjected to fusion feature extraction to obtain the text vector of the target text to be identified, which may specifically include:
[0156] For each character, a first target vector is obtained by concatenating the character's position vector and the character's word vector; fusion feature extraction is performed on the first target vectors of each character to obtain a text vector of the target text to be identified.
[0157] It should be noted that the text title of the target text to be identified can be spliced before or after the text content. In this case, for any character of the target text to be identified, the position of the character in the target text to be identified can be the position of the character in the spliced text; the text title and the text content can also not be spliced. In this case, for any character of the target text to be identified, the position of the character in the target text to be identified can be the position of the character in the text title or text content to which it belongs.
[0158] In an embodiment of the present application, for each character of the target text to be identified, the text classification model can perform vector conversion processing on the position of the character in the target text to be identified to obtain the position vector of the character, and splice the position vector and word vector of the character to obtain the first target vector of the character.
[0159] Among them, the position vector of the character can be spliced before or after the word vector of the character. Of course, in the actual execution process, the position vector and the word vector can also be not spliced, but the set consisting of the position vector and the word vector can be regarded as the first target vector, which is not limited here.
[0160] The first target vector of each character can be subjected to fusion feature extraction to obtain a text vector of the target text to be identified, so that the text vector contains the position and semantics of each character in the target text to be identified, thereby enabling the text vector to better express the semantics of the target text to be identified.
[0161] Implementation A2: The text identification method based on deep learning may further include: obtaining an attribution vector for each character according to the text title or text content to which each character belongs in the target text to be identified.
[0162] In step S423, the word vectors of each character are subjected to fusion feature extraction to obtain the text vector of the target text to be identified, which may specifically include:
[0163] For each character, a second target vector is obtained by concatenating the character's word vector and the character's attribution vector; fusion feature extraction is performed on the second target vector of each character to obtain a text vector of the target text to be identified.
[0164] In this embodiment of the present application, for each character in the target text to be identified, the text classification model can obtain an attribution vector for the character based on the text title or text content to which the character belongs in the target text to be identified. The attribution vector can reflect whether the character belongs to the text title or text content. The attribution vector of the character is further concatenated with the word vector to obtain a second target vector for the character.
[0165] Among them, the attribution vector of the character can be spliced before or after the word vector of the character. Of course, in the actual execution process, the attribution vector and the word vector can also be not spliced, but the set consisting of the attribution vector and the word vector can be regarded as the second target vector, which is not limited here.
[0166] The second target vector of each character can be subjected to fusion feature extraction to obtain the text vector of the target text to be identified, so that the text vector contains the semantics of each character of the text title in the target text to be identified, and the semantics of each character of the text content in the target text to be identified, that is, the text vector can contain the semantics of the text title and the semantics of the text content, so that the text vector can better express the semantics of the target text to be identified.
[0167] Implementation A3: The text identification method based on deep learning may further include: obtaining the weight of the text title and the weight of the text content.
[0168] In step S423, the word vectors of each character are subjected to fusion feature extraction to obtain the text vector of the target text to be identified, which may specifically include:
[0169] According to the text title or text content to which each character belongs, the character's word vector is weighted using the corresponding weight to obtain a weighted word vector; the weighted word vector of each character is fused with feature extraction to obtain the text vector of the target text to be identified.
[0170] In an embodiment of the present application, the weight of the text title and the weight of the text content may be preset. For example, the weight of the text title may be preset to 0.7, and the weight of the text content may be preset to 0.3.
[0171] During actual execution, the same weight of the text title and the weight of the text content may be set for each target text to be identified; or different weights of the text title and the weight of the text content may be set for different target texts to be identified.
[0172] In a possible implementation, the weight of the text title and the weight of the text content may be determined according to the number of characters included in the text title and the number of characters included in the text content, respectively.
[0173] For example, the text title contains 10 characters and the text content contains 90 characters, and the character ratio between the two is 1:9. It can be determined that the weight of the text title is 0.9 and the weight of the text content is 0.1.
[0174] For each character in the target text to be identified, the text classification model can weight the character's word vector using the corresponding weight based on the text title or text content to which the character belongs in the target text to be identified, thereby obtaining a weighted word vector. In other words, if the character belongs to the text title in the target text to be identified, the word vector of the character is weighted using the weight of the text title; if the character belongs to the text content in the target text to be identified, the word vector of the character is weighted using the weight of the text content.
[0175] Furthermore, the text classification model can perform fusion feature extraction on the weighted word vectors of each character to obtain the text vector of the target text to be identified, so that the text vector contains the semantics of each character of the text title in the target text to be identified, and the semantics of each character of the text content in the target text to be identified, that is, the text vector can contain the semantics of the text title and the semantics of the text content, so that the text vector can better express the semantics of the target text to be identified.
[0176] In implementation A4, in step S423, the word vectors of each character are subjected to fusion feature extraction to obtain the text vector of the target text to be identified. Specifically, the following steps may be performed:
[0177] For each character, the correlation between the character and each character in the characters is determined based on the word vector of the character and the word vector of each character in the characters; for each character, based on the correlations corresponding to the character, the word vectors of each character corresponding to each correlation are weightedly fused to obtain the fusion vector of the character; fusion features are extracted from the fusion vectors of each character to obtain the text vector of the target text to be identified.
[0178] In an embodiment of the present application, for each character of the target text to be identified, the text classification model can determine the correlation between the character and each of the characters in the target text to be identified based on the word vector of the character and the word vector of each of the characters in the target text to be identified, and based on the correlations corresponding to the character, perform weighted fusion on the word vectors of each character corresponding to each correlation to obtain a fusion vector of the character, so that the fusion vector can represent the semantic correlation between the character and each character in the target text to be identified.
[0179] For example, if the target text to be identified contains ten characters, then for each character, the correlation between the character and each of the other nine characters can be determined based on the character's word vector and the word vector of each of the other nine characters. Therefore, the word vector of each of the other nine characters corresponds to a correlation. Each correlation is used as a weight, and the word vectors corresponding to each correlation are weighted and fused using the weights to obtain the fused vector for the character.
[0180] Furthermore, the fusion vectors of each character of the target text to be identified can be subjected to fusion feature extraction to obtain the text vector of the target text to be identified, so that the text vector can represent the semantic correlation between characters in the target text to be identified, thereby enabling the text vector to better express the semantics of the target text to be identified.
[0181] The text classification model is a binary classification model for classifying a first text category attribute and a second text category attribute, and the target text to be identified is text information in the content to be recommended. The method may further include:
[0182] If the category attribute of the text information is the first text category attribute, the content to be recommended is recommended to the user; if the category attribute of the text information is the second text category attribute, the content to be recommended is filtered out.
[0183] In one possible implementation, the text classification model is a binary classification model for classifying vulgar text into non-vulgar text. When a target text to be identified is input into the text classification model, the model can output the classification attribute of the target text to be identified as vulgar text or non-vulgar text. The first text classification attribute is non-vulgar text, and the second text classification attribute is vulgar text.
[0184] In an embodiment of the present application, the target text to be identified is text information in the content to be recommended. For example, when the content to be recommended includes a video, the target text to be identified can be the subtitles in the video; when the content to be recommended is graphic information, the target text to be identified can be the text part in the graphic information, etc.
[0185] In actual application, the text information in the content to be recommended can be input into the text classification model offline or online, and the text classification model outputs the category attributes of the text information in the content to be recommended, and the category attributes of the text information in the content to be recommended are used as the category attributes of the content to be recommended. That is, the text classification model can be used offline or online to determine the category attributes of the content to be recommended.
[0186] After determining the category attribute of the content to be recommended, a corresponding label can be added to the content to be recommended. When the category attribute of the content to be recommended is vulgar text, the content to be recommended can be added with a vulgar label; when the category attribute of the content to be recommended is non-vulgar text, the content to be recommended can be added with a non-vulgar label.
[0187] When recommending content online, if the content is labeled as vulgar, the content can be filtered out; if the content is labeled as non-vulgar, the content can be recommended to the user.
[0188] The embodiment of the present application provides a text identification method based on deep learning. Compared with the prior art, the target text to be identified in the embodiment of the present application includes a text title and text content. The text classification model can be called to perform word and sentence parsing of the text title and text content to obtain each character of the target text to be identified, and each character is converted into a word vector to obtain a word vector of each character. The word vector of each character is subjected to fusion feature extraction to obtain a text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector. Since the text classification model performs fusion feature extraction based on the word vector of each character in the title and the word vector of each character in the text when classifying the text, the extracted text vector can better express the target text to be identified, so that when the model performs text classification based on the text vector, the model can better understand the target text to be identified, and can effectively improve the accuracy of the model in identifying text categories.
[0189] In another possible implementation of the embodiment of the present application, the text classification model is trained in the following manner, which includes steps B1 and B2.
[0190] Step B1: Obtain a labeled dataset and an unlabeled dataset that are annotated with real text category attribute labels.
[0191] Among them, the labeled data set is the first data set mentioned above, and the unlabeled data set is the second data set mentioned above. The labeled data set includes all labeled texts, that is, the first texts marked with labels mentioned above. The labels represent the true category attributes of the first texts. The unlabeled data set includes all unlabeled texts, that is, the second texts without labels mentioned above.
[0192] In an embodiment of the present application, for each labeled text in a labeled dataset, a first labeled text can be obtained through manual annotation, where the label can be a vulgar label, a non-vulgar label, etc. In actual application, a large amount of text can be obtained, and a portion of the text can be manually annotated to obtain the first labeled text to construct a labeled dataset, while the remaining text is constructed as an unlabeled dataset. The method for obtaining text is not limited. For example, text can be obtained from the web, from local storage, or uploaded by users.
[0193] It is understood that any text in the labeled dataset and the unlabeled dataset may include a text title and text content. The text title and text content in any text may be subjected to feature fusion processing according to at least one of Implementations A1 to A4. For details, please refer to the relevant description above and will not be repeated here.
[0194] Step B2: Based on the labeled dataset and the unlabeled dataset, the model parameters of the initial text classification model are adjusted through multiple training operations until the preset end conditions are met, thereby obtaining the final text classification model.
[0195] Among them, the preset end condition can be that the number of training operations reaches the preset number of training operations, or it can be that during the current training operation, the number of difficult-to-classify texts in the unlabeled data set, that is, the number of first target texts is less than or equal to the first preset number, or it can be that during the current training operation, the number of unlabeled texts in the unlabeled data set is less than or equal to the second preset number, etc.
[0196] Specifically, each training operation includes steps B21 to B24.
[0197] In step B21 , each unlabeled text in the unlabeled data set is input into the text classification model based on the last model parameter adjustment to obtain the predicted probability of each unlabeled text corresponding to each text category attribute.
[0198] For each unlabeled text in the unlabeled dataset, the unlabeled text can be input into the current text classification model. The current text classification model is the text classification model after the model parameters are adjusted during the previous training. The text classification model can output the predicted probability of each text category attribute for the unlabeled text. The text category attributes can be two text category attributes, or three or more text category attributes, without limitation.
[0199] As a possible implementation method, the predicted probability of the unlabeled text corresponding to each text category attribute includes the positive sample probability that the unlabeled text is a positive sample and the negative sample probability that the unlabeled text is a negative sample, where the positive sample probability can also be called the first probability and the negative sample probability can also be called the second probability.
[0200] In a possible implementation, when the text is non-vulgar text, the text is a positive sample, and when the text is vulgar text, the text is a negative sample.
[0201] When step B21 is actually executed, for each unlabeled text, the unlabeled text may include a text title and text content. The unlabeled text may be subjected to a word parsing process of the text title and text content to obtain each character of the unlabeled text, and each character may be subjected to a word vector conversion process to obtain a word vector of each character. The word vector of each character may be subjected to a fusion feature extraction process to obtain a text vector of the unlabeled text, so as to obtain a predicted probability of the unlabeled text corresponding to each text category attribute based on the text vector. It is understandable that for any text (including but not limited to the unlabeled text, labeled text, target text to be identified, first target text, second target text, text information in the content to be recommended, etc. mentioned above), the text vector of the text may be obtained in the above manner.
[0202] In actual application, for each character in the unlabeled text, a fusion feature extraction can be performed on the word vector of each character based on at least one of the position vector, the attribution vector, etc. of each character, in combination with the word vector of each character, to obtain the text vector of the unlabeled text. For details, please refer to the relevant description of implementation method A1 and implementation method A2 above. In actual execution, it is also possible to perform a fusion feature extraction on the word vector of each character in the unlabeled text based on the weight of the text title and text content of the unlabeled text to obtain the text vector of the unlabeled text. For details, please refer to the relevant description of implementation method A3 above. It is also possible to directly use implementation method A4 to perform a fusion feature extraction on the word vector of each character in the unlabeled text to obtain the text vector of the unlabeled text. For details, please refer to the relevant description of implementation method A4 above.
[0203] It is understandable that when performing fusion feature extraction on the word vectors of each character in the unlabeled text, at least one of implementation methods A1 to A4 can be adopted, which is not limited in the embodiments of the present application.
[0204] In a possible implementation, the initial text classification model includes a cascaded text feature extraction module and a text category prediction module, and the text feature extraction model is a pre-trained text feature extraction model.
[0205] In an embodiment of the present application, a text feature extraction module may be pre-trained first, and a text category prediction module may be cascaded after the pre-trained text feature extraction module to obtain an initial text classification model. The text feature extraction module is used to extract feature vectors of the text. For example, the text feature extraction module may be a Bert model. The pre-training method of the text feature extraction module can be found in the relevant content above and will not be repeated here. The text category prediction module may be the classifier mentioned above, which may be composed of a cascade of fully connected layers and a Softmax layer.
[0206] In a possible implementation, the text classification model includes a cascaded text feature extraction module and a text category prediction module, wherein the text feature extraction module is a feature extraction module using a Bert model.
[0207] In an embodiment of the present application, the text feature extraction module is a feature extraction module that adopts the Bert model, that is, the text feature extraction module can be a Bert model, and the text category prediction module can be a classifier composed of a cascaded fully connected layer and a Softmax layer.
[0208] In step B21, for any unlabeled text in the unlabeled data set, each unlabeled text in the unlabeled data set is input into the text classification model based on the last model parameter adjustment to obtain the predicted probability of each unlabeled text corresponding to each text category attribute, which may specifically include:
[0209] The unlabeled text is input into the feature extraction module using the Bert model to obtain the feature vector corresponding to the classification symbol bit of the Bert model; the feature vector corresponding to the classification symbol bit of the Bert model is used as the semantic feature of the unlabeled text, and based on the semantic feature, the prediction probability of the unlabeled text corresponding to each text category attribute is obtained through the text category prediction module.
[0210] Among them, in the embodiments of the present application and the embodiments mentioned above or below, the semantic features of any text refer to the text vector of the text, which can also be called a sentence vector.
[0211] In an embodiment of the present application, the unlabeled text is input into a feature extraction module using a Bert model. The feature extraction module using the Bert model can first convert each character in the unlabeled text into a character vector through the conversion field provided by the Bert model, and then input each character vector into the Bert model, and the Bert model outputs a feature vector corresponding to the classification symbol. The feature vector corresponding to the classification symbol can be used as the semantic feature of the unlabeled text, that is, the sentence vector / text vector of the unlabeled text.
[0212] Furthermore, the text vector of the unlabeled text is input into a text category prediction module, which can output a predicted probability for the unlabeled text. The predicted probability for the unlabeled text can include the probability that the unlabeled text is of each text category attribute. When the text classification model is a binary classification model, the predicted probability for the unlabeled text can include the probability that the unlabeled text is a positive sample and / or the probability that the unlabeled text is a negative sample. In practical applications, the text classification model is not limited to a binary classification model.
[0213] It can be seen from the relevant description of the above embodiment that during the first training operation, when each unlabeled text in the unlabeled data set is input into the text classification model after the model parameters are adjusted in the previous training, the text classification model after the model parameters are adjusted in the previous training is obtained after the parameters of the initial text classification model are adjusted based on the labeled data set. The details can be seen from the relevant description of the above embodiment, which will not be repeated here.
[0214] It should be noted that the above is an explanation of the relevant processing of unlabeled text input into the text feature extraction module and the text category prediction module from the perspective of unlabeled text. Labeled text can also be input into the text feature extraction module and the text category prediction module, and the processing method is similar to that of unlabeled text. Please see the above description and will not repeat it here.
[0215] Step B22: for each unlabeled text, if the difference between the predicted probabilities of the unlabeled text is less than or equal to a first set threshold, the unlabeled text is determined as the first target text.
[0216] In the embodiment of the present application, the first target text is the difficult-to-classify text mentioned above. For any unlabeled text, if the unlabeled text is a difficult-to-classify text, it means that in the predicted probability of the unlabeled text output by the current text classification model, the probability that the text belongs to a certain text category attribute is close to the probability that the text belongs to another text category attribute other than the text category attribute. When the text classification model is a two-category model, if the unlabeled text is a difficult-to-classify text, it means that in the predicted probability of the unlabeled text output by the current text classification model, the probability that the second text is a positive sample and the probability that the second text is a negative sample are close, that is, the probability that the unlabeled text is a positive sample and the probability that the unlabeled text is a negative sample are very small.
[0217] For any unlabeled text, the predicted probability of the unlabeled text corresponding to each text category includes a first probability that the unlabeled text is of a first text category attribute and a second probability that the unlabeled text is of a second text category attribute. The first text category attribute can be a non-vulgar text category, i.e., a positive sample, and the second text category attribute can be a vulgar text category, i.e., a negative sample.
[0218] In step B22, if the difference between the predicted probabilities of the unlabeled text is less than or equal to the first set threshold, the unlabeled text is determined as the first target text, which may specifically include:
[0219] If the difference between the first probability and the second probability corresponding to the unlabeled text is less than or equal to the first set threshold, the unlabeled text is determined as the first target text. The first probability is the positive sample probability mentioned above, and the second probability is the negative sample probability mentioned above.
[0220] In an embodiment of the present application, the first set threshold may be a value determined based on manual experience, and the size of the first set threshold is not limited. For example, the size of the first set threshold may be any one of 0.1, 0.05, 0.02, etc.
[0221] For example, when the first set threshold is 0.05, if the positive sample probability of the unlabeled text is 0.51 and the negative sample probability of the unlabeled text is 0.49, since the difference between the positive sample probability and the negative sample probability is 0.02, which is less than the first set threshold of 0.05, it can be determined that this unlabeled sample is a text that is difficult to classify, that is, the first target text.
[0222] Step B23: Acquire each first target text annotated with a real text category attribute label, add each annotated first target text to the labeled dataset, and delete each first target text from the unlabeled dataset.
[0223] In the embodiment of the present application, for the first target text, that is, the difficult-to-classify text, since the current text classification model cannot accurately determine whether the text is a positive sample or a negative sample, the difficult-to-classify text can be manually annotated or model-annotated to obtain the text's true text category label, thereby determining whether the text is a positive sample or a negative sample. Specifically, the method of obtaining the text's true text category label through model annotation is as follows:
[0224] In step B23, for any first target text, the real text category attribute label of the first target text is obtained by annotating in the following manner:
[0225] The pre-trained target classification model is called to perform category attribute identification processing on the first target text to obtain the category attribute to which the first target text belongs; and the real text category attribute label of the first target text is marked according to the category attribute to which the first target text belongs.
[0226] In an embodiment of the present application, a target classification model can be pre-trained to classify text that is difficult to classify. In actual application, a first target text can be input into the target classification model for category attribute identification processing, and the target classification model outputs the category attribute to which the first target text belongs. The target classification model can directly output the category attribute to which the first target text belongs, or the target classification model directly outputs the predicted probability that the first target text belongs to each category attribute.
[0227] Furthermore, if the target classification model directly outputs the category attribute to which the first target text belongs, the output category attribute will be labeled as the real text category attribute label of the first target text; if the target classification model directly outputs the predicted probability that the first target text belongs to each category attribute, the real text category attribute label of the first target text can be labeled according to the category attribute to which the first target text belongs according to the actual scenario needs. For example, the category attribute corresponding to the maximum predicted probability among each predicted probability can be labeled as the real text category attribute label of the first target text, and the category attribute corresponding to the predicted probability greater than a preset threshold among each predicted probability can also be labeled as the real text category attribute label of the first target text, etc.
[0228] In the actual application process, the labeled texts that are difficult to classify can be added to the labeled dataset to update the labeled dataset, so as to facilitate the use of the updated labeled dataset to train the current text classification model. At the same time, the difficult to classify texts can be deleted from the unlabeled dataset to update the unlabeled dataset, ensuring that every text in the unlabeled dataset is an unlabeled text.
[0229] Step B24: Input each labeled text in the labeled data set into the text classification model to obtain the predicted probability of each labeled text corresponding to each text category attribute, determine the value of the loss function based on the predicted probability of each labeled text and the actual text category attribute label, and adjust the model parameters based on the value of the loss function.
[0230] In this embodiment, each labeled text in the labeled dataset is input into the current text classification model, which then outputs a predicted probability for each labeled text. Based on the predicted probability and the label of each labeled text, the loss function corresponding to this training session is calculated, and the loss function value is used to adjust the model parameters.
[0231] Among them, the loss function used in the embodiment of the present application is not limited, and a suitable loss function can be selected according to actual conditions.
[0232] The embodiment of the present application can input each unlabeled text into the current text classification model during each training, and output the predicted probability of each unlabeled text corresponding to each text category. For each unlabeled text, if the difference between the predicted probabilities of the unlabeled text is less than or equal to the first set threshold, the unlabeled text is determined as the first target text, that is, the difficult-to-classify text. The labeled difficult-to-classify text is combined with the original labeled text training model to realize the use of active learning technology. During the model training process, the manually labeled difficult-to-classify text is continuously added. The use of the labeled difficult-to-classify text can more effectively improve the performance of the model and the active learning ability of the model. When the trained model is used to classify text, the accuracy of the model in identifying text categories can be effectively improved.
[0233] Another possible implementation of the embodiment of the present application may further include, for any operation, that is, for any training operation:
[0234] For each unlabeled text, if any predicted probability of the unlabeled text is greater than or equal to the second set threshold corresponding to the predicted probability, the unlabeled text is determined as the second target text, and each second target text is deleted from the unlabeled data set; for each second target text, the text category attribute corresponding to the predicted probability of the second target text that is greater than or equal to the second set threshold is determined as the true text category attribute label of the second target text.
[0235] In an embodiment of the present application, if the unlabeled text is the second target text, that is, the easily categorized text, this indicates that in the predicted probability of the unlabeled text output by the current text classification model, the probability that the text belongs to a certain text category attribute is significantly greater than the probability that the text belongs to other text category attributes other than the text category attribute. When the text classification model is a binary classification model, if the unlabeled text is the easily categorized text, this indicates that in the predicted probability of the unlabeled text output by the current text classification model, the difference between the probability that the unlabeled text is a positive sample and the probability that the unlabeled text is a negative sample is large, and the text classification model can basically determine that the unlabeled text is a positive sample or the unlabeled text is a negative sample.
[0236] Among them, for each easy-to-classify text, if the probability that the easy-to-classify text is a positive sample is greater than the probability that it is a negative sample, it indicates that the easy-to-classify text is a positive sample, and the easy-to-classify text can be marked with a positive sample label; if the probability that the easy-to-classify text is a positive sample is less than the probability that it is a negative sample, it indicates that the easy-to-classify text is a negative sample, and the easy-to-classify text can be marked with a negative sample label.
[0237] As an optional implementation, the positive sample label can be a non-vulgar label, and the negative sample label can be a vulgar label.
[0238] It can be seen from the above embodiments that the text classification model can be a binary classification model, and the predicted probability of the unlabeled text corresponding to each text category attribute includes a first probability that the unlabeled text is a first text category attribute and a second probability that the unlabeled text is a second text category attribute.
[0239] If any predicted probability of the unlabeled text is greater than or equal to a second set threshold corresponding to the predicted probability, the unlabeled text is determined as the second target text, which may specifically include:
[0240] If the first probability corresponding to the unlabeled text is greater than or equal to the second set threshold corresponding to the first text category attribute, or the second probability corresponding to the unlabeled text is greater than or equal to the second set threshold corresponding to the second text category attribute, the unlabeled text is determined as the second target text.
[0241] The second set threshold corresponding to the first text category attribute is greater than the second set threshold corresponding to the second text category attribute.
[0242] In an embodiment of the present application, due to the large imbalance in the number of positive samples and negative samples, the text classification model predicts a higher probability for positive samples and a lower probability for negative samples. Therefore, the second set threshold corresponding to the first text category attribute can be set to be greater than the second set threshold corresponding to the second text category attribute, that is, the second set threshold corresponding to the positive sample is greater than the second set threshold corresponding to the negative sample.
[0243] Furthermore, unlabeled texts whose corresponding positive sample probability is greater than or equal to the second set threshold corresponding to the first text category are selected from each unlabeled text, and unlabeled texts whose corresponding negative sample probability is greater than or equal to the second set threshold corresponding to the second text category are selected from each unlabeled text, so that a sufficient number of positive samples and a sufficient number of negative samples can be selected. When the labeled data set and the positive samples and negative samples selected this time are used to train the current text classification model, the number of samples that need to be manually labeled is reduced, thereby reducing manpower.
[0244] In an embodiment of the present application, for each unlabeled text, when the positive sample probability corresponding to the unlabeled text is greater than or equal to the second set threshold value corresponding to the first text category, it can be determined that the unlabeled text is the easy-to-classify text corresponding to this operation, and the unlabeled text can be determined to be a positive sample, thereby marking the unlabeled text with a positive sample label; when the negative sample probability corresponding to the unlabeled text is greater than or equal to the second set threshold value corresponding to the second text category, it can be determined that the unlabeled text is the easy-to-classify text corresponding to this operation, and the unlabeled text can be determined to be a negative sample, thereby marking the unlabeled text with a negative sample label.
[0245] It should be noted that in each optional embodiment of the present application, the first probability is the positive sample probability, the second probability is the negative sample probability, the non-vulgar text is the first text, the positive sample, and the vulgar text is the second text, the negative sample.
[0246] Step B24: Input each labeled text in the labeled data set into the text classification model to obtain the predicted probability of each labeled text corresponding to each text category attribute, and determine the value of the loss function based on each predicted probability of each labeled text and the actual text category attribute label. Specifically, the loss function may include:
[0247] Input each labeled text in the labeled data set and each second target text determined by this operation into the text classification model to obtain the predicted probability of each labeled text and each second target text corresponding to each text category attribute; determine the value of the loss function based on the predicted probabilities corresponding to each labeled text and each second target text and the true text category attribute label.
[0248] In the embodiment of the present application, the training data set for this operation can be composed of a labeled data set and each easily categorized text determined in this operation. Each labeled text in the labeled data set is a labeled text that is manually annotated with a real text category attribute label. Each easily categorized text determined in this operation can automatically determine the real text category attribute label of the easily categorized text based on the predicted probabilities of the easily categorized text. In other words, each text in the training data set for this operation is a text with a real text category attribute label. Each text in the training data set for this operation can be referred to as a third text.
[0249] In practical applications, each third text in the training dataset is input into the current text classification model, which then outputs the predicted probability of each third text corresponding to each text category attribute. Based on the predicted probabilities and the actual text category attribute labels of each third text, the loss function corresponding to this training session is calculated, and the model parameters are adjusted using the loss function value.
[0250] Specifically, for any operation, the value of the loss function is determined based on the predicted probabilities corresponding to each labeled text and each second target text and the true text category attribute label, which may specifically include:
[0251] Calculate the first loss value based on the real text category attribute labels and predicted probabilities of each labeled text; determine the second loss value based on the real text category attribute labels and predicted probabilities of each second target text determined by this operation; determine the value of the loss function based on the first loss value and the second loss value.
[0252] In the embodiment of the present application, a labeled data set is input into the current text classification model, and the current text classification model outputs the predicted probabilities of each labeled text in the labeled data set, and based on a preset loss function, the first loss value is calculated using the real text category attribute label and each predicted probability of each labeled text; based on each easy-to-classify text determined by this operation (that is, each second target text) is input into the current text classification model, and the current text classification model outputs the predicted probabilities of each easy-to-classify text, and based on a preset loss function, the second loss value is calculated using the real text category attribute label and each predicted probability of each easy-to-classify text. Then, the value of the loss function corresponding to this training is calculated using the first loss value and the second loss value.
[0253] The embodiment of the present application can also determine, during each training, for each unlabeled text, if any predicted probability of the unlabeled text is greater than or equal to the second set threshold value corresponding to the predicted probability, the unlabeled text as the second target text, that is, the easy-to-classify text, and determine the label of each easy-to-classify text based on the predicted probability of each easy-to-classify text, so as to utilize each easy-to-classify text and its respective label training model, thereby realizing the use of pseudo-label technology. During the model training process, the easy-to-classify texts that the model predicts more accurately are continuously added, and the labels of the easy-to-classify texts are equivalent to artificial labels, that is, pseudo-labels. By utilizing the easy-to-classify texts with labels, the number of training samples can be greatly increased, and the human resources required for manual annotation can be reduced, thereby being able to more effectively improve the performance of the model. When the trained model is used to classify texts, the accuracy of the model in identifying text categories can be effectively improved.
[0254] In order to understand the training method of text classification model, we will combine Figure 5 For detailed explanation, Figure 5 The following is a flowchart of a text classification model training method provided in an embodiment of the present application. Figure 5 It may include steps S51 to S58.
[0255] Step S51: Obtain a labeled dataset and an unlabeled dataset annotated with real text category labels.
[0256] Step S52 : input each unlabeled text in the unlabeled data set into the text classification model after the model parameters are adjusted last time, and obtain the predicted probability of each unlabeled text corresponding to each text category.
[0257] Step S53 : For each unlabeled text, if the difference between the prediction probabilities of the unlabeled text is less than or equal to a first set threshold, the unlabeled text is determined as the first target text.
[0258] Step S54: Acquire each first target text annotated with a real text category label, add each annotated first target text to the labeled dataset, and delete each first target text from the unlabeled dataset.
[0259] Step S55: For each unlabeled text, if any predicted probability of the unlabeled text is greater than or equal to a second set threshold corresponding to the predicted probability, the unlabeled text is determined as a second target text, and each second target text is deleted from the unlabeled data set.
[0260] Step S56 : For each second target text, determine the text category corresponding to the predicted probability of the second target text that is greater than or equal to the second set threshold as the true text category label of the second target text.
[0261] In step S57 , each labeled text in the labeled data set and each second target text determined in this operation are input into a text classification model to obtain a predicted probability of each labeled text and each second target text corresponding to each text category.
[0262] Step S58: determining the value of the loss function based on the predicted probabilities corresponding to each labeled text and each second target text and the real text category label, and adjusting the model parameters based on the value of the loss function.
[0263] If the preset training end condition is not met, step S52 and subsequent steps are restarted, that is, steps S52 to S58 are executed in a loop until the preset training end condition is met; if the preset training end condition is met, step S59 is executed to obtain the final text classification model.
[0264] The relevant descriptions of each step from step S51 to step S59 can be found in the relevant descriptions of the above embodiment and will not be repeated here.
[0265] It should be noted that any text category involved in steps S51 to S59 refers to the text category attribute mentioned above.
[0266] The previous article mentioned four fusion feature extraction methods shown in implementation methods A1 to A4. In actual implementation, any fusion feature extraction method in implementation methods A1 to A4 can be used, or at least two of implementation methods A1 to A4 can be combined as the final fusion feature extraction method.
[0267] The following is an example of combining the four implementation methods A1 to A4 as the final fusion feature extraction method. Figure 6 For detailed description. Figure 6 As shown, Figure 6 A flowchart of a text vector determination method provided in an embodiment of the present application. The method includes steps S61 to S69.
[0268] Step S61: obtaining a target text to be identified, where the target text to be identified includes a text title and text content.
[0269] In step S62 , the target text to be identified is subjected to word-sentence parsing of the text title and text content to obtain the characters of the target text to be identified, and each character is subjected to word-vector conversion to obtain a word vector for each character.
[0270] Step S63 , performing vector conversion processing on the position of each character in the target text to be identified, and obtaining the position vector of each character.
[0271] Step S64: Obtain the attribution vector of each character according to the text title or text content to which each character belongs in the target text to be identified.
[0272] Step S65: Obtain the weight of the text title and the weight of the text content.
[0273] Step S66: For each character, the position vector, the belonging vector, and the word vector of the character are concatenated, and the concatenated vectors are weighted using corresponding weights according to the text title or text content to which the character belongs, to obtain a weighted vector.
[0274] Step S67 : for each character, determine the correlation between the character and each of the characters according to the weighted vector of the character and the weighted vector of each of the characters.
[0275] Step S68 : For each character, based on the correlations corresponding to the character, weighted fusion is performed on the word vectors of the characters corresponding to the correlations to obtain a fusion vector of the character.
[0276] Step S69: extract fusion features from the fusion vectors of each character to obtain the text vector of the target text to be identified.
[0277] The relevant contents of steps S61 to S69 can be found in the relevant descriptions of the above implementation methods A1 to A4, which will not be repeated here.
[0278] The above describes the text identification method based on deep learning from the perspective of method steps. The following introduces the text identification device based on deep learning from the perspective of virtual modules, as shown below:
[0279] The present application embodiment provides a text identification device based on deep learning, such as Figure 7As shown, the text identification device 70 based on deep learning may include: a text acquisition module 701 and a text identification module 702, wherein:
[0280] The text acquisition module 701 is used to acquire the target text to be identified, and the target text to be identified includes the text title and text content;
[0281] The text identification module 702 is used to call a pre-trained text classification model to perform category attribute identification processing on the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs. The text identification module 702 is specifically used to:
[0282] Parsing the target text for identification by analyzing the title and content of the target text to obtain the characters of the target text;
[0283] Perform word vector conversion on each character of the target text to be identified to obtain a word vector for each character;
[0284] The word vectors of each character are fused and feature extracted to obtain the text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector.
[0285] In a possible implementation, the device further includes:
[0286] A position vector determination module is used to perform vector conversion processing on the position of each character in the target text to be identified to obtain the position vector of each character;
[0287] When the text identification module 702 performs fusion feature extraction on the word vectors of each character to obtain the text vector of the target text to be identified, it is specifically used to:
[0288] For each character, the first target vector is obtained by concatenating the character's position vector and the character's word vector;
[0289] The first target vector of each character is subjected to fusion feature extraction to obtain the text vector of the target text to be identified.
[0290] In a possible implementation, the method further includes:
[0291] An attribution vector determination module is used to obtain an attribution vector for each character based on the text title or text content to which each character belongs in the target text to be identified;
[0292] When the text identification module 702 performs fusion feature extraction on the word vectors of each character to obtain the text vector of the target text to be identified, it is specifically used to:
[0293] For each character, a second target vector is obtained by concatenating the character's word vector and the character's belonging vector;
[0294] The second target vector of each character is subjected to fusion feature extraction to obtain the text vector of the target text to be identified.
[0295] In a possible implementation, the method further includes:
[0296] The weight acquisition module is used to obtain the weight of the text title and the weight of the text content;
[0297] When the text identification module 702 performs fusion feature extraction on the word vectors of each character to obtain the text vector of the target text to be identified, it is specifically used to:
[0298] According to the text title or text content to which each character belongs, the character's word vector is weighted with the corresponding weight to obtain a weighted word vector;
[0299] The weighted word vectors of each character are fused and feature extracted to obtain the text vector of the target text to be identified.
[0300] In one possible implementation, when the text identification module 702 performs fusion feature extraction on the word vectors of each character to obtain the text vector of the target text to be identified, it is specifically configured to:
[0301] For each character, determining the relevance of the character to each of the characters based on the word vector of the character and the word vector of each of the characters;
[0302] For each character, based on the correlations corresponding to the character, the word vectors of the characters corresponding to the correlations are weightedly fused to obtain the fused vector of the character;
[0303] The fusion feature extraction is performed on the fusion vector of each character to obtain the text vector of the target text to be identified.
[0304] In one possible implementation, the text classification model is trained by a text training module, which is specifically used to:
[0305] Obtain labeled datasets and unlabeled datasets annotated with real text category attribute labels;
[0306] Based on the labeled dataset and the unlabeled dataset, the model parameters of the initial text classification model are adjusted by repeatedly performing the following operations until the preset end conditions are met to obtain the final text classification model:
[0307] Input each unlabeled text in the unlabeled data set into the text classification model based on the last model parameter adjustment to obtain the predicted probability of each unlabeled text corresponding to each text category attribute;
[0308] For each unlabeled text, if the difference between the predicted probabilities of the unlabeled text is less than or equal to a first set threshold, the unlabeled text is determined as the first target text;
[0309] Obtain each first target text annotated with a real text category attribute label, add each annotated first target text to the labeled dataset, and delete each first target text from the unlabeled dataset;
[0310] Each labeled text in the labeled data set is input into the text classification model to obtain the predicted probability of each labeled text corresponding to each text category attribute. The value of the loss function is determined based on the predicted probability of each labeled text and the true text category attribute label, and the model parameters are adjusted based on the value of the loss function.
[0311] In a possible implementation, for any first target text, the real text category attribute label of the first target text is obtained by annotating in the following manner:
[0312] Calling a pre-trained target classification model to perform category attribute identification processing on the first target text to obtain the category attribute to which the first target text belongs;
[0313] According to the category attribute to which the first target text belongs, a real text category attribute label of the first target text is marked.
[0314] In a possible implementation, for any operation, the text training module is further configured to:
[0315] For each unlabeled text, if any predicted probability of the unlabeled text is greater than or equal to a second set threshold corresponding to the predicted probability, the unlabeled text is determined as a second target text, and each second target text is deleted from the unlabeled dataset;
[0316] For each second target text, determining the text category attribute corresponding to the predicted probability of the second target text that is greater than or equal to the second set threshold as the true text category attribute label of the second target text;
[0317] The text training module inputs each labeled text in the labeled data set into the text classification model to obtain the predicted probability of each labeled text corresponding to each text category attribute. The module determines the value of the loss function based on the predicted probability of each labeled text and the actual text category attribute label. Specifically, it is used to:
[0318] Input each labeled text in the labeled data set and each second target text determined in this operation into the text classification model to obtain the predicted probability of each labeled text and each second target text corresponding to each text category attribute;
[0319] The value of the loss function is determined based on the predicted probabilities corresponding to each labeled text and each second target text and the true text category attribute label.
[0320] In one possible implementation, for any operation, when the text training module determines the value of the loss function based on the predicted probabilities corresponding to each labeled text and each second target text and the true text category attribute label, it is specifically configured to:
[0321] Calculate a first loss value based on the true text category attribute label and each predicted probability of each labeled text;
[0322] Determine a second loss value based on the true text category attribute label and each predicted probability of each second target text determined in this operation;
[0323] A value of a loss function is determined based on the first loss value and the second loss value.
[0324] In one possible implementation, the text classification model is a binary classification model for classifying a first text category attribute and a second text category attribute, the target text to be identified is text information in the content to be recommended, and the device further includes:
[0325] The to-be-recommended content processing module is configured to recommend the to-be-recommended content to the user if the category attribute of the text information is the first text category attribute; and to filter out the to-be-recommended content if the category attribute of the text information is the second text category attribute.
[0326] The deep learning-based text identification device of this embodiment can execute the deep learning-based text identification method shown in any of the above embodiments of this application. The implementation principles are similar and will not be repeated here.
[0327] The deep learning-based text identification device can be a computer program (including program code) running in a computer device, for example, the deep learning-based text identification device is an application software; the device can be used to execute the corresponding steps in the deep learning-based text identification method provided in the embodiment of the present application.
[0328] In some embodiments, the deep learning-based text identification device provided in the embodiments of the present application can be implemented in a combination of software and hardware. As an example, the deep learning-based text identification device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the deep learning-based text identification method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0329] In other embodiments, the text identification device based on deep learning provided in the embodiments of the present application can be implemented in software. Figure 7 A deep learning-based text identification device 70 stored in a memory is shown, which can be software in the form of a program and plug-in, and includes a series of modules, including a text acquisition module 701, a text identification module 702, a position vector determination module, an attribution vector determination module, a weight acquisition module, and a content processing module to be recommended; wherein, the text acquisition module 701, the text identification module 702, the position vector determination module, the attribution vector determination module, the weight acquisition module, and the content processing module to be recommended are used to implement the deep learning-based text identification method provided in an embodiment of the present application.
[0330] The embodiment of the present application provides a text identification device based on deep learning. Compared with the prior art, the target text to be identified in the embodiment of the present application includes a text title and text content. The text classification model can be called to perform word and sentence parsing of the text title and text content to obtain each character of the target text to be identified, and each character is converted into a word vector to obtain a word vector of each character. The word vector of each character is fused with feature extraction to obtain a text vector of the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs based on the text vector. Since the text classification model performs fused feature extraction based on the word vectors of each character in the title and the word vectors of each character in the text when classifying the text, the extracted text vector can better express the target text to be identified, so that when the model performs text classification based on the text vector, the model can better understand the target text to be identified, and can effectively improve the accuracy of the model in identifying text categories.
[0331] The above introduces the deep learning-based text identification device of the present application from the perspective of a virtual module. The following introduces the electronic device of the present application from the perspective of a physical device.
[0332] The present application embodiment provides an electronic device, such as Figure 8 As shown, Figure 8 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004. It should be noted that in actual applications, the number of transceivers 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.
[0333] Processor 4001 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0334] The bus 4002 may include a path for transmitting information between the above components. The bus 4002 may be a PCI bus or an EISA bus, etc. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0335] The memory 4003 may be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or an EEPROM, a CD-ROM or other optical disk storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0336] The memory 4003 is used to store the computer program for executing the solution of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the content shown in any of the above method embodiments.
[0337] An embodiment of the present application provides an electronic device. The electronic device in the embodiment of the present application includes: a memory and a processor, wherein a computer program is stored in the memory; when the processor runs the computer program, it executes the deep learning-based text identification method shown in any optional embodiment of the method embodiment.
[0338] The above describes the electronic device of the present application from the perspective of a physical device. The following describes the computer-readable storage medium of the present application from the perspective of a storage medium.
[0339] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the text identification method based on deep learning shown in any optional embodiment of the method embodiment is implemented.
[0340] According to one aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the deep learning-based text identification method provided in various optional implementations of the above-described method embodiment.
[0341] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0342] The above description is only part of the implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A text identification method based on deep learning, characterized in that: include: Obtaining a target text to be identified, wherein the target text to be identified includes a text title and text content; Calling a pre-trained text classification model to perform category attribute identification processing on the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs, including: Performing word and sentence parsing processing on the title and content of the target text to be identified to obtain each character of the target text to be identified; Performing word vector conversion on each character of the target text to be identified to obtain a word vector for each character; Performing fusion feature extraction on the word vectors of the characters to obtain a text vector of the target text to be identified, so as to obtain a category attribute to which the target text to be identified belongs based on the text vector; The text classification model is trained in the following way: Obtain labeled and unlabeled datasets that are annotated with real text category attribute labels; Based on the labeled dataset and the unlabeled dataset, the model parameters of the initial text classification model are adjusted by repeatedly performing the following operations until a preset end condition is met, thereby obtaining the pre-trained text classification model: Inputting each unlabeled text in the unlabeled data set into the text classification model based on the last model parameter adjustment to obtain the predicted probability of each unlabeled text corresponding to each text category attribute; For each of the unlabeled texts, if the difference between the predicted probabilities of the unlabeled texts is less than or equal to a first set threshold, the unlabeled text is determined as a first target text; if any predicted probability of the unlabeled text is greater than or equal to a second set threshold corresponding to the predicted probability, the unlabeled text is determined as a second target text, the text category attribute corresponding to the predicted probability is determined as the true text category attribute label of the second target text, and each second target text is deleted from the unlabeled data set; Acquire each first target text annotated with a real text category attribute label, add each annotated first target text to the labeled dataset, and delete each first target text from the unlabeled dataset; Input each labeled text in the labeled data set and each second target text determined by the operation into the text classification model to obtain the predicted probability of each labeled text and each second target text corresponding to each text category attribute, determine the value of the loss function based on the predicted probabilities corresponding to each labeled text and each second target text and the real text category attribute label, and adjust the model parameters based on the value of the loss function.
2. The method according to claim 1, characterized in that Also includes: Performing vector conversion processing on the position of each character in the target text to be identified to obtain the position vector of each character; The step of performing fusion feature extraction on the word vectors of the characters to obtain the text vector of the target text to be identified includes: For each character, obtain a first target vector by concatenating the position vector of the character and the word vector of the character; Perform fusion feature extraction on the first target vector of each character to obtain a text vector of the target text to be identified.
3. The method according to claim 1, characterized in that Also includes: Obtaining an attribution vector for each character according to the text title or text content to which each character belongs in the target text to be identified; The step of performing fusion feature extraction on the word vectors of the characters to obtain the text vector of the target text to be identified includes: For each character, obtain a second target vector by concatenating the character's word vector and the character's attribution vector; Perform fusion feature extraction on the second target vector of each character to obtain a text vector of the target text to be identified.
4. The method according to claim 1, wherein Also includes: Obtaining the weight of the text title and the weight of the text content; The step of performing fusion feature extraction on the word vectors of the characters to obtain the text vector of the target text to be identified includes: According to the text title or text content to which each character belongs, the word vector of the character is weighted using the corresponding weight to obtain a weighted word vector; The weighted word vectors of the characters are subjected to fusion feature extraction to obtain a text vector of the target text to be identified.
5. The method according to any one of claims 1 to 4, characterized in that The step of performing fusion feature extraction on the word vectors of the characters to obtain the text vector of the target text to be identified includes: For each character, determining the relevance of the character to each of the characters based on the word vector of the character and the word vector of each of the characters; For each character, based on the correlations corresponding to the character, the word vectors of the characters corresponding to the correlations are weightedly fused to obtain the fused vector of the character; The fusion feature extraction is performed on the fusion vector of each character to obtain the text vector of the target text to be identified.
6. The method according to claim 1, characterized in that For any of the first target texts, the real text category attribute label of the first target text is obtained by annotating in the following manner: Calling a pre-trained target classification model to perform category attribute identification processing on the first target text to obtain the category attribute to which the first target text belongs; According to the category attribute to which the first target text belongs, a real text category attribute label of the first target text is marked.
7. The method according to claim 1, characterized in that For any of the operations, determining the value of the loss function based on the predicted probabilities corresponding to the labeled texts and the second target texts and the true text category attribute labels includes: Calculating a first loss value based on the true text category attribute label and each predicted probability of each labeled text; Determining a second loss value based on the true text category attribute labels and the predicted probabilities of each second target text determined in this operation; A value of a loss function is determined based on the first loss value and the second loss value.
8. A text identification device based on deep learning, characterized in that: include: A text acquisition module is used to acquire a target text to be identified, wherein the target text to be identified includes a text title and text content; The text identification module is used to call a pre-trained text classification model to perform category attribute identification processing on the target text to be identified, so as to obtain the category attribute to which the target text to be identified belongs. The text identification module is specifically used to: Performing word and sentence parsing processing on the target text to be identified in terms of the text title and text content to obtain each character of the target text to be identified; performing word vector conversion processing on each character of the target text to be identified to obtain a word vector for each character; performing fusion feature extraction on the word vectors of each character to obtain a text vector of the target text to be identified, and obtaining the category attribute to which the target text to be identified belongs based on the text vector; The text classification model is obtained by training a text training module, and the text training module is used to: Obtain a labeled data set and an unlabeled data set marked with real text category attribute labels; based on the labeled data set and the unlabeled data set, adjust the model parameters of the initial text classification model by repeatedly performing the following operations until the preset end condition is met, and obtain the pre-trained text classification model: input each unlabeled text in the unlabeled data set into the text classification model based on the last model parameter adjustment, and obtain the predicted probability of each unlabeled text corresponding to each text category attribute; for each of the unlabeled texts, if the difference between the predicted probabilities of the unlabeled texts is less than or equal to a first set threshold, then the unlabeled text is determined as the first target text; if any predicted probability of the unlabeled text is greater than or equal to a second set threshold corresponding to the predicted probability, then the unlabeled text is determined as the second target text, and the predicted probability is set as the second target text. The corresponding text category attribute is determined as the real text category attribute label of the second target text, and each second target text is deleted from the unlabeled data set; each first target text annotated with the real text category attribute label is obtained, and each annotated first target text is added to the labeled data set, and each first target text is deleted from the unlabeled data set; each labeled text in the labeled data set and each second target text determined by this operation are input into the text classification model to obtain the predicted probability of each labeled text and each second target text corresponding to each text category attribute, determine the value of the loss function based on the predicted probability and the real text category attribute label corresponding to each labeled text and each second target text, and adjust the model parameters based on the value of the loss function.
9. The device according to claim 8, characterized in that The apparatus further includes a position vector determining module, wherein the position vector determining module is configured to: Performing vector conversion processing on the position of each character in the target text to be identified to obtain the position vector of each character; When the text identification module performs fusion feature extraction on the character word vectors to obtain the text vector of the target text to be identified, it is used to: For each character, obtain a first target vector by concatenating the position vector of the character and the word vector of the character; Perform fusion feature extraction on the first target vector of each character to obtain a text vector of the target text to be identified.
10. The device according to claim 8, characterized in that The apparatus further includes a home vector determination module, wherein the home vector determination module is configured to: Obtaining an attribution vector for each character according to the text title or text content to which each character belongs in the target text to be identified; When the text identification module performs fusion feature extraction on the word vectors of the characters to obtain the text vector of the target text to be identified, it is used to: For each character, obtain a second target vector by concatenating the character's word vector and the character's attribution vector; Perform fusion feature extraction on the second target vector of each character to obtain a text vector of the target text to be identified.
11. The device according to any one of claims 8 to 10, characterized in that: When the text identification module performs fusion feature extraction on the weighted word vectors of the characters to obtain the text vector of the target text to be identified, it is used to: For each character, determining the relevance of the character to each of the characters based on the word vector of the character and the word vector of each of the characters; For each character, based on the correlations corresponding to the character, the word vectors of the characters corresponding to the correlations are weightedly fused to obtain the fused vector of the character; The fusion feature extraction is performed on the fusion vector of each character to obtain the text vector of the target text to be identified.
12. The device according to claim 8, characterized in that For any of the first target texts, the real text category attribute label of the first target text is obtained by annotating in the following manner: Calling a pre-trained target classification model to perform category attribute identification processing on the first target text to obtain the category attribute to which the first target text belongs; According to the category attribute to which the first target text belongs, a real text category attribute label of the first target text is marked.
13. The device according to claim 8, characterized in that For any operation, when determining the value of the loss function based on the predicted probabilities and the true text category attribute labels corresponding to each of the labeled texts and each of the second target texts, the text training module is used to: Calculating a first loss value based on the true text category attribute label and each predicted probability of each labeled text; Determining a second loss value based on the true text category attribute labels and the predicted probabilities of each second target text determined in this operation; A value of a loss function is determined based on the first loss value and the second loss value.
14. An electronic device, characterized in that: The electronic device includes a memory and a processor, wherein the memory stores a computer program; and the processor executes the method according to any one of claims 1 to 7 when running the computer program.
15. A computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Semi-supervised multi-label classification method based on dependency degree
CN109754000A
Method and device for training business model and determining text classification categories
CN111737474A