Processing method, device, equipment and storage medium for text category recognition model

Through the main category and subcategory identification network in the text category recognition model, combined with the target loss function training, the problem of inaccurate prediction results in multi-level classification of text is solved, and higher classification accuracy is achieved.

CN114357151BActive Publication Date: 2025-08-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110912638.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-10
Publication Date
2025-08-15
Estimated Expiration
2041-08-10

AI Technical Summary

Technical Problem

In the prior art, in multi-level text classification, especially when identifying the main category and subordinate subcategory to which the text belongs, the prediction results are not accurate enough.

Method used

The main category identification network and subcategory identification network in the text category identification model are constructed by combining the label data of the sample text, and the target loss function is constructed, and the model is trained to improve the prediction accuracy of the main category and subcategory.

Benefits of technology

The high-accuracy upper-level category prediction results are used as prior knowledge to improve the accuracy of multi-level classification of text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114357151B_ABST
    Figure CN114357151B_ABST
Patent Text Reader

Abstract

The present application relates to a processing method, apparatus, device and storage medium for a text category recognition model, and also to a text category recognition method, apparatus, device and storage medium, and relates to natural language processing technology in the field of artificial intelligence technology. The processing method of the text category recognition model includes: obtaining a main category prediction result corresponding to the sample text through a main category recognition network in the text category recognition model, obtaining a subcategory prediction result corresponding to the sample text based on the main category prediction result through a subcategory recognition network in the text category recognition model, and then constructing a target loss based on the main category label and the main category prediction result corresponding to the sample text, as well as the subcategory label and the subcategory prediction result corresponding to the main category label corresponding to the sample text, and training the text category recognition model according to the target loss. The use of this method can improve the accuracy of multi-level text classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for processing a text category recognition model, and also to a method, apparatus, device and storage medium for text category recognition. Background Art

[0002] Text classification, a classic problem in the field of Natural Language Processing (NLP), is currently widely used. Generally speaking, text classification refers to the process of identifying the category to which a text belongs, that is, classifying the text into one or more categories. The objects to be classified can be short texts such as sentences, titles, comments, etc., or long texts such as articles.

[0003] In some scenarios, it's necessary to classify text into a main category and its subcategories. For example, identifying a text as belonging to the main category "application" and the subcategory "mini-program" is necessary. Currently, the common approach is to split this text classification task into several basic multi-classification tasks corresponding to the main category, and then directly predict the subcategories based on the input text. However, the inventors have found that this approach yields inaccurate predictions. Summary of the Invention

[0004] Based on this, it is necessary to provide a processing method, device, equipment and storage medium for a text category recognition model that can improve the accuracy of multi-level text classification, as well as a text category recognition method, device, equipment and storage medium to address the above technical problems.

[0005] A method for processing a text category recognition model, the method comprising:

[0006] Acquire a sample text and label data corresponding to the sample text, wherein the label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label;

[0007] Performing category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text;

[0008] Performing category recognition on the sample text based on the main category prediction result through the subcategory recognition network in the text category recognition model to obtain a subcategory prediction result corresponding to the sample text;

[0009] Constructing a target loss based on the main category label corresponding to the sample text and the main category prediction result, and the subcategory label corresponding to the sample text and the subcategory prediction result;

[0010] After updating the model parameters of the text category recognition model according to the target loss, return to the step of obtaining the sample text and the label data corresponding to the sample text to continue training until the training is completed, and obtain a text category recognition model for identifying text categories.

[0011] A device for processing a text category recognition model, the device comprising:

[0012] An acquisition module, configured to acquire a sample text and label data corresponding to the sample text, wherein the label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label;

[0013] A main category recognition module is used to perform category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text;

[0014] a subcategory identification module, configured to perform category identification on the sample text based on the main category prediction result through a subcategory identification network in the text category identification model, and obtain a subcategory prediction result corresponding to the sample text;

[0015] A loss construction module, configured to construct a target loss based on the main category tag corresponding to the sample text and the main category prediction result, and the subcategory tag corresponding to the sample text and the subcategory prediction result;

[0016] A training module is used to update the model parameters of the text category recognition model according to the target loss, and then return to the step of obtaining the sample text and the label data corresponding to the sample text to continue training until the training is completed, thereby obtaining a text category recognition model for identifying text categories.

[0017] In one embodiment, the main category identification module is also used to: perform semantic encoding on the sample text through the semantic encoding layer of the main category identification network to obtain a semantic encoding vector; and convert the semantic encoding vector into a prediction probability corresponding to a predetermined main category through the normalization layer of the main category identification network as the main category prediction result.

[0018] In one embodiment, the subcategory identification module is further used to: determine the subcategory semantic vector corresponding to the sample text based on the main category prediction result and the semantic encoding vector corresponding to the sample text through the information fusion layer of the subcategory identification network; and convert the subcategory semantic vector into a prediction probability corresponding to a predetermined subcategory as the subcategory prediction result through the normalization layer of the subcategory identification network.

[0019] In one embodiment, the subcategory identification module is further used to: determine candidate main categories based on the main category prediction results; fuse the semantic representation vectors corresponding to each of the candidate main categories to obtain a main category semantic vector; and concatenate the main category semantic vector with the semantic encoding vector corresponding to the sample text to obtain a subcategory semantic vector corresponding to the sample text.

[0020] In one embodiment, the subcategory identification module is further used to: determine the semantic representation vector corresponding to each of the candidate main categories; determine the prediction probability corresponding to each of the candidate main categories based on the main category prediction result; and weightedly sum the semantic representation vectors corresponding to each of the candidate main categories according to the prediction probability corresponding to each of the candidate main categories to obtain the main category semantic vector.

[0021] In one embodiment, the subcategory identification module is further used to: convert the semantic encoding vector corresponding to the sample text into the prediction probability of the corresponding predetermined subcategory through the normalization layer of the subcategory identification network; adjust the prediction probability corresponding to the predetermined subcategory belonging to the corresponding predetermined main category according to the prediction probability corresponding to each predetermined main category in the main category prediction result through the information correction layer of the subcategory identification network, and use the adjusted prediction probability of the corresponding predetermined subcategory as the subcategory prediction result.

[0022] In one embodiment, the loss construction module is further used to: construct a main category classification loss based on the main category label corresponding to the sample text and the main category prediction result, and construct a subcategory classification loss based on the subcategory label corresponding to the sample text and the subcategory prediction result; after fusing the main category classification loss with the subcategory classification loss, a target loss is obtained.

[0023] In one embodiment, the loss construction module is further used to: construct a main category classification loss based on the main category tag corresponding to the sample text and the main category prediction result, and construct a subcategory classification loss based on the subcategory tag corresponding to the sample text and the subcategory prediction result; extract the prediction probability corresponding to the main category tag from the main category prediction result, extract the prediction probability corresponding to the subcategory tag from the subcategory prediction result, and construct a hinge loss based on the prediction probability corresponding to the main category tag and the prediction probability corresponding to the subcategory tag; after fusing the main category classification loss, the subcategory classification loss and the hinge loss, a target loss is obtained, and the hinge loss is used to make the prediction probability of each predetermined subcategory in the main category prediction result output by the updated text category recognition model less than the prediction probability corresponding to the predetermined main category to which it belongs.

[0024] In one embodiment, the subcategory tag subordinate to the main category tag includes a first subcategory tag subordinate to the main category tag and a second subcategory tag subordinate to the first subcategory tag; the subcategory identification module is further used to: perform category identification on the sample text based on the main category prediction result through the first subcategory identification network connected to the main category identification network in the text category identification model, and obtain a first subcategory prediction result corresponding to the sample text; perform category identification on the sample text based on the first subcategory prediction result through the second subcategory identification network connected to the first subcategory identification network in the text category identification model, and obtain a second subcategory prediction result corresponding to the sample text; the loss construction module is further used to: construct the target loss based on the main category tag corresponding to the sample text and the main category prediction result, the first subcategory tag corresponding to the sample text and the first subcategory prediction result, and the second subcategory tag corresponding to the sample text and the second subcategory prediction result.

[0025] In one embodiment, the processing device of the text category recognition model further includes an input module and a determination module, and the acquisition module is further used to: acquire the text to be recognized; the input module is used to: input the text to be recognized into the trained text category recognition model; the main category recognition module is further used to: perform category recognition on the text to be recognized through the main category recognition network in the trained text category recognition model, and obtain a main category prediction result corresponding to the text to be recognized; the subcategory recognition module is further used to: perform category recognition on the text to be recognized based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, and obtain a subcategory prediction result corresponding to the text to be recognized; the determination module is used to: determine the main category and / or subcategory corresponding to the text to be recognized based on the subcategory prediction result.

[0026] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the processing method of the above-mentioned text category recognition model when executing the computer program.

[0027] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the processing method of the above-mentioned text category recognition model.

[0028] A computer program includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps of the processing method of the above-mentioned text category recognition model.

[0029] The processing method, apparatus, computer device, and storage medium of the above-mentioned text category recognition model obtain the main category prediction result corresponding to the sample text through the main category recognition network in the text category recognition model. Since the higher the category system, the more sample data it corresponds to and the lower the classification difficulty, the main category prediction result obtained is often more accurate. Therefore, when predicting subcategories, the subcategory recognition network in the text category recognition model uses the main category prediction result as prior knowledge, and the subcategory prediction result obtained by predicting the sample text is more accurate. Subsequently, a target loss is constructed based on the main category label and the main category prediction result corresponding to the sample text, as well as the subcategory label and the subcategory prediction result subordinate to the main category label corresponding to the sample text. The text category recognition model trained according to the target loss has a higher accuracy in identifying the text category. In other words, the prediction result of the highly accurate upper-level category is used as prior knowledge to influence the prediction result of the lower-level category, thereby improving the accuracy of the text category recognition model for multi-level text classification.

[0030] A method for identifying text categories, the method comprising:

[0031] Get the text to be recognized;

[0032] Performing category recognition on the text to be recognized using the main category recognition network in the trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized;

[0033] Using the subcategory recognition network in the trained text category recognition model, the text to be recognized is subjected to category recognition based on the main category prediction result, thereby obtaining a subcategory prediction result corresponding to the text to be recognized;

[0034] A target category corresponding to the to-be-recognized text is determined according to the subcategory prediction result, where the target category includes at least one of a main category and a subcategory.

[0035] A device for identifying text categories, the device comprising:

[0036] An acquisition module is used to obtain the text to be recognized;

[0037] A main category recognition module is used to perform category recognition on the text to be recognized using the main category recognition network in the trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized;

[0038] A subcategory recognition module, configured to perform category recognition on the text to be recognized based on the main category prediction result using the subcategory recognition network in the trained text category recognition model, and obtain a subcategory prediction result corresponding to the text to be recognized;

[0039] A determination module is configured to determine a target category corresponding to the to-be-recognized text according to the subcategory prediction result, wherein the target category includes at least one of a main category and a subcategory.

[0040] In one embodiment, the acquisition module is also used to: acquire the uploaded target video; extract the video title text corresponding to the target video as the text to be identified; the text category identification device also includes a generation module, and the generation module is used to: generate video semantic features corresponding to the target video according to the target category corresponding to the video title text.

[0041] In one embodiment, the acquisition module is further used to: obtain an object search request; extract input text for searching the target object from the object search request as the text to be identified; the text category identification device also includes a search module and a return module, the generation module is used to: search for a target object matching the target category according to the target category corresponding to the input text; the return module is used to: return the target object in response to the object search request.

[0042] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned text category recognition method when executing the computer program.

[0043] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned text category identification method.

[0044] A computer program includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps of the above-mentioned text category recognition method.

[0045] The above-mentioned text category recognition method, device, computer equipment and storage medium obtain the main category prediction result corresponding to the text to be recognized through the main category recognition network in the trained text category recognition model, obtain the subcategory prediction result corresponding to the text to be recognized based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, and determine the target category corresponding to the text to be recognized based on the subcategory prediction result. Since the trained text category recognition model uses the high-accuracy prediction result of the upper-level category as prior knowledge when classifying the text, it affects the prediction result of the lower-level category, thereby improving the accuracy of multi-level text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1This is a diagram of an application environment of a method for processing a text category recognition model in one embodiment;

[0047] Figure 2 A flowchart of a method for processing a text category recognition model in one embodiment;

[0048] Figure 3 A schematic diagram of sample text and its label data in one embodiment;

[0049] Figure 4 Schematic diagram of a framework of a text category recognition model in one embodiment;

[0050] Figure 5 Schematic diagram of a framework of a text category recognition model in another embodiment;

[0051] Figure 6 Schematic diagram of a framework of a text category recognition model in another embodiment;

[0052] Figure 7 is a flowchart of a method for processing a text category recognition model in another embodiment;

[0053] Figure 8 A flowchart of a method for identifying text categories in one embodiment;

[0054] Figure 9 is a structural block diagram of a processing device for a text category recognition model in one embodiment;

[0055] Figure 10 is a structural block diagram of a text category identification device in one embodiment;

[0056] Figure 11 is a diagram of the internal structure of a computer device in one embodiment;

[0057] Figure 12 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0059] The processing method of the text category recognition model and the text category recognition method provided in the embodiments of the present application relate to artificial intelligence (AI) technology. Artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.

[0060] 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.

[0061] The processing method of the text category recognition model provided in the embodiment of the present application mainly relates to the machine learning technology (Machine Learning, ML) of artificial intelligence. Machine learning is a multi-disciplinary interdisciplinary subject involving multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and formulaic learning.

[0062] For example, in an embodiment of the present application, a text category recognition model is trained using sample text and label data corresponding to the sample text. The label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category. During the training process, the main category prediction result of the main category recognition network in the text category recognition model affects the subcategory prediction result of the subcategory recognition network in the text category recognition model, and finally a text category recognition model for recognizing the main category and / or subcategory of the text is obtained.

[0063] The processing method of the text category recognition model provided in the embodiment of the present application also involves blockchain technology. Blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database. It is a string of data blocks generated by cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.

[0064] For example, an embodiment of the present application stores the sample text and the label data corresponding to the sample text on one of the nodes of the blockchain network, and the computer device obtains the sample text and the label data corresponding to the sample text through the blockchain network.

[0065] The text category identification method provided in the embodiment of the present application mainly relates to the natural language processing (NLP) technology of artificial intelligence. Natural language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can realize effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology generally includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.

[0066] The text category identification method provided in the embodiment of the present application mainly relates to the text preprocessing technology in the field of natural language processing technology. Text preprocessing includes sentence classification, part-of-speech tagging, word segmentation, etc. For example, in the embodiment of the present application, the main category prediction result of the text to be identified is obtained by the main category recognition network in the trained text category recognition model, and the subcategory prediction result of the text to be identified is obtained based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, and the main category and / or subcategory corresponding to the text to be identified is determined according to the subcategory prediction result.

[0067] The processing method of the text category recognition model provided in this application can be applied to Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. Terminal 102 may be, but is not limited to, various smartphones, tablet computers, laptop computers, desktop computers, portable wearable devices, etc. Server 104 may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0068] In one embodiment, the terminal 102 obtains sample text and label data corresponding to the sample text, the label data including a main category label corresponding to the sample text and a subcategory label subordinate to the main category label, and sends the sample text and the label data corresponding to the sample text to the server 104. The server 104 performs category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text. The server 104 performs category recognition on the sample text based on the main category prediction result through the subcategory recognition network in the text category recognition model to obtain a subcategory prediction result corresponding to the sample text. A target loss is constructed based on the main category label and the main category prediction result corresponding to the sample text, and the subcategory label and the subcategory prediction result corresponding to the sample text. After updating the model parameters of the text category recognition model according to the target loss, the server returns to the step of obtaining the sample text and the label data corresponding to the sample text to continue training until the training is completed, thereby obtaining a text category recognition model for identifying text categories.

[0069] The processing method of the text category recognition model provided in the embodiment of the present application may be executed by the processing device of the text category recognition model provided in the embodiment of the present application, or a computer device integrated with the processing device of the text category recognition model, wherein the processing device of the text category recognition model may be implemented in hardware or software. The computer device may be Figure 1 The terminal 102 or server 104 shown in .

[0070] The processing method of the text category recognition model provided in the embodiment of the present application can be applied to the training scenario of the text category recognition model. The text category recognition model is used to identify the category to which the text belongs, such as identifying the coarse-grained category, fine-grained category or multi-level category to which the text belongs. Multi-level categories are more than one category, and there is a subordinate relationship between more than one category, such as identifying the main category and subcategory to which the text belongs. The subcategory is subordinate to the main category. For example, if the main category is "application", the subcategory can be "mini program". The subcategory can be a single subcategory subordinate to the main category, or it can be more than one subcategory that has a subordinate relationship with each other. For example, if the main category is "application", the first subcategory can be a "mini program", and the second subcategory can be a "order mini program", and the second subcategory is subordinate to the first subcategory.

[0071] In one embodiment, a computer device obtains sample text and label data corresponding to the sample text, the label data including a main category label corresponding to the sample text and a subcategory label subordinate to the main category label; performs category recognition on the sample text through a main category recognition network in a text category recognition model to obtain a main category prediction result corresponding to the sample text; performs category recognition on the sample text based on the main category prediction result through a subcategory recognition network in the text category recognition model to obtain a subcategory prediction result corresponding to the sample text; constructs a target loss based on the main category label and the main category prediction result corresponding to the sample text, and the subcategory label and the subcategory prediction result corresponding to the sample text; after updating the model parameters of the text category recognition model according to the target loss, returns to the step of obtaining the sample text and the label data corresponding to the sample text to continue training until the training is completed, thereby obtaining a text category recognition model for identifying text categories.

[0072] It can be understood that the text category recognition model is trained by using sample texts from different application scenarios and their corresponding label data to obtain a text category recognition model that can recognize the main categories and / or subcategories of texts in multiple application scenarios.

[0073] The text category recognition method provided by this application can also be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 via a network.

[0074] In one embodiment, the terminal 102 obtains the text to be recognized and sends the text to be recognized to the server 104. The server 104 performs category recognition on the text to be recognized through the main category recognition network in the trained text category recognition model, and obtains the main category prediction result corresponding to the text to be recognized. The server 104 performs category recognition on the text to be recognized based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, and obtains the subcategory prediction result corresponding to the text to be recognized. The target category corresponding to the text to be recognized is determined according to the subcategory prediction result, and the target category includes at least one of the main category and the subcategory.

[0075] The text category identification method provided in the embodiment of the present application may be executed by the text category identification device provided in the embodiment of the present application, or a computer device integrated with the text category identification device, wherein the text category identification device may be implemented in hardware or software. The computer device may be Figure 1 The terminal 102 or server 104 shown in .

[0076] The text category recognition method provided in the embodiments of this application can be applied to classification scenarios, search scenarios, and the like. Classification scenarios involve identifying categories of objects, such as text classification, video classification, product classification, and article classification. Search scenarios involve classifying input text used to search for objects, thereby finding objects corresponding to the input text in corresponding categories.

[0077] For example, a computer device extracts the video title text of a video, and determines the target category corresponding to the video title text through the trained text category recognition model provided by the embodiment of the present application. The target category includes a main category and / or a subcategory, and the subcategory is at least one subcategory that has a subordinate relationship with each other, thereby performing coarse-grained classification, fine-grained classification, or multi-level classification on the video.

[0078] For another example, a computer device extracts the product description text of a product and determines the target category corresponding to the product description text through the trained text category recognition model provided in the embodiment of the present application. The target category includes a main category and / or a subcategory, and a subcategory is at least one subcategory that has a subordinate relationship with each other, thereby performing coarse-grained classification, fine-grained classification, or multi-level classification on the product.

[0079] For another example, a computer device obtains an object search request, extracts input text from the object search request, and determines the target category corresponding to the input text through the trained text category recognition model provided in an embodiment of the present application. The target category includes a main category and / or a subcategory, and a subcategory is at least one subcategory that has a subordinate relationship with each other, thereby inputting an object corresponding to the text under the corresponding category.

[0080] In one embodiment, a computer device obtains a text to be recognized; performs category recognition on the text to be recognized through a main category recognition network in a trained text category recognition model, and obtains a main category prediction result corresponding to the text to be recognized; performs category recognition on the text to be recognized based on the main category prediction result through a subcategory recognition network in the trained text category recognition model, and obtains a subcategory prediction result corresponding to the text to be recognized; and determines a target category corresponding to the text to be recognized based on the subcategory prediction result, wherein the target category includes at least one of a main category and a subcategory.

[0081] In one embodiment, Figure 2 As shown, a method for processing a text category recognition model is provided. This embodiment mainly applies this method to the above Figure 1 Taking the computer device (terminal 102 or server 104) in the example as an example, the following steps are included:

[0082] Step S202 : obtaining a sample text and label data corresponding to the sample text, wherein the label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label.

[0083] The sample text is the text data used to train the text category recognition model in the embodiment of the present application. The text category recognition model is used to identify the category to which the text belongs, such as the coarse-grained category, fine-grained category, or multi-level category to which the text belongs. A multi-level category is more than one category, and there is a subordinate relationship between the more than one category. For example, the main category and subcategory to which the text belongs can be identified, and the subcategory is subordinate to the main category; for another example, the main category, the first subcategory, and the second subcategory to which the text belongs can be identified, and the second subcategory is subordinate to the first subcategory.

[0084] The main category tag is used to identify the main category to which the sample text belongs, and the subcategory tag is used to identify the subcategory to which the sample text belongs. A subcategory tag can be a single subcategory tag subordinate to the main category tag, for example, if the main category tag is "applications," the subcategory tag can be "mini-programs." Subcategory tags can also be multiple subcategory tags with a subordinate relationship, for example, if the main category tag is "applications," the first subcategory tag is "mini-programs," and the second subcategory tag is "order mini-programs," with the second subcategory tag subordinate to the first subcategory tag.

[0085] In one embodiment, the computer device obtains sample text from the application scenario of the text category recognition model. For example, the text category recognition model is used to classify videos according to the video title text of the video, and the computer device obtains the video title text as the sample text. Figure 3 , Figure 3A schematic diagram of sample text and its label data in one embodiment is shown. As can be seen, taking the sample text "Scan and order instantly" as an example, the label data includes a main category label corresponding to the sample text and a single subcategory label subordinate to the main category label, and the main category label is an application and the subcategory label is a mini-program.

[0086] Step S204 : performing category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text.

[0087] The main category identification network is a network structure within the text category identification model, used to identify the main category to which a text belongs. The main category prediction result can be the predicted probability of a sample text corresponding to each predetermined main category, the predicted target main category to which the sample text belongs, or candidate main categories selected based on the predicted probability of the sample text corresponding to each predetermined main category.

[0088] In one embodiment, a computer device inputs a sample text into a main category recognition network in a text category recognition model, performs category recognition on the sample text through the main category recognition network, and obtains a main category prediction result corresponding to the sample text.

[0089] In one embodiment, a computer device performs semantic encoding on a sample text through a semantic encoding layer of a main category recognition network to obtain a semantic encoding vector, and obtains a main category prediction result corresponding to the semantic encoding vector through a normalization layer of the main category recognition network.

[0090] The semantic encoding vector is the result of expressing the text in digital form. For example, if the sample text is represented digitally as "[0 0 0 1 0 0 0 0 0 0 0...]," then "[0 0 0 1 0 0 0 0 0 0 0...]" is the semantic encoding vector of the sample text. It should be understood that the vector representation used to convert the sample text is not limited here; as long as the sample text can be digitally represented, it will be sufficient. For example, the sample text can be converted into a high-dimensional sparse vector or a low-dimensional dense vector.

[0091] In one embodiment, the semantic coding layer may adopt a general semantic coding network structure, such as a CNN (Convolutional Neural Networks) network structure, an LSTM (Long Short-Term Memory) network structure, a network structure combining LSTM and Attention (attention mechanism), and the like.

[0092] In one embodiment, the normalization layer may use a general normalization function, such as a Softmax function.

[0093] In one embodiment, referring to Figure 4 , Figure 4 Figure 2 shows a schematic diagram of the framework of a text category recognition model in one embodiment. As can be seen, the computer device inputs sample text into the semantic encoding layer of the main category recognition network, obtains a semantic encoding vector corresponding to the sample text through the semantic encoding layer, inputs the semantic encoding vector into the normalization layer of the main category recognition network, and obtains the main category prediction result corresponding to the semantic encoding vector through the normalization layer.

[0094] In one embodiment, the computer device converts the semantic coding vector into the prediction probability corresponding to each predetermined main category through a normalization layer, and determines the main category prediction result based on the prediction probability of the semantic coding vector corresponding to each predetermined main category.

[0095] In one embodiment, after the computer device obtains the predicted probability of the semantic coding vector corresponding to each predetermined main category through the normalization layer, the predicted probability of the semantic coding vector corresponding to each predetermined main category is used as the main category prediction result. In other embodiments, the computer device predicts the target main category to which the sample text belongs based on the predicted probability of the semantic coding vector corresponding to each predetermined main category, and uses the predicted target main category as the main category prediction result; or, the computer device selects a candidate main category based on the predicted probability of the semantic coding vector corresponding to each predetermined main category, and uses the selected candidate main category as the main category prediction result. Optionally, the computer device sorts the predetermined main categories from high to low according to the predicted probability of the sample text corresponding to each predetermined main category, and selects a specified number of predetermined main categories that are ranked at the top from the sorted results as candidate main categories.

[0096] Step S206 , using the subcategory recognition network in the text category recognition model, the sample text is subjected to category recognition based on the main category prediction result to obtain a subcategory prediction result corresponding to the sample text.

[0097] The subcategory identification network is a network structure within the text category identification model, used to identify the subcategory to which a text belongs. Optionally, the subcategory identification network is connected to the main category identification network. The subcategory prediction result can be the predicted probability of the sample text corresponding to each predetermined subcategory, the predicted target subcategory to which the sample text belongs, or candidate subcategories selected based on the predicted probability of the sample text corresponding to each predetermined subcategory, etc.

[0098] In this application, a computer device transmits the main category prediction result output by the main category recognition network to the subcategory recognition network, and the main category prediction result affects the subcategory prediction result. The inventors consider that in multi-level classification, the higher the category, the coarser the classification granularity and the greater the amount of training data. Therefore, the classification difficulty of the upper-level categories is lower than that of the lower-level categories, and the classification accuracy of the upper-level categories is higher than that of the lower-level categories. Therefore, for the classification task of the lower-level categories, the classification results of the high-accuracy upper-level categories can be used as prior knowledge to improve the classification accuracy of the lower-level categories.

[0099] In one embodiment, the computer device transmits the main category prediction result to the subcategory recognition network in the text category recognition model, and through the subcategory recognition network, the sample text is classified based on the main category prediction result to obtain the subcategory prediction result corresponding to the sample text.

[0100] In one embodiment, the computer device transmits the semantic encoding vector and the main category prediction result corresponding to the sample text to the subcategory recognition network in the text category recognition model. The subcategory recognition network performs category recognition on the semantic encoding vector based on the main category prediction result to obtain the subcategory prediction result corresponding to the sample text. Figure 4 , it can be seen that the computer device obtains the sub-category prediction result corresponding to the semantic encoding vector based on the main category prediction result through the normalization layer of the sub-category recognition network.

[0101] In one embodiment, a computer device performs category recognition on a sample text using a subcategory recognition network to obtain an original subcategory prediction result. The original subcategory recognition result is adjusted using the main category prediction result to obtain a subcategory prediction result corresponding to the sample text. The original subcategory prediction result can be the predicted probability of the sample text corresponding to each predetermined subcategory, or the target subcategory to which the predicted sample text belongs, or a candidate subcategory selected based on the predicted probability of the sample text corresponding to each predetermined subcategory, etc. For example, the computer device obtains the target main category or candidate main category corresponding to the sample text from the main category prediction result, increases the predicted probability corresponding to the predetermined subcategories subordinate to the target main category or candidate main category, and decreases the predicted probability corresponding to the remaining predetermined subcategories.

[0102] In one embodiment, a computer device determines a subcategory semantic vector corresponding to the sample text based on a semantic encoding vector corresponding to the sample text and a main category prediction result through a subcategory recognition network, and obtains a subcategory prediction result corresponding to the sample text based on the subcategory semantic vector. For example, the computer device obtains a target main category or candidate main category corresponding to the sample text from the main category prediction result, determines a semantic representation vector corresponding to the target main category or candidate main category, and fuses the semantic representation vector corresponding to the sample text with the semantic representation vector corresponding to the target main category or the semantic representation vector corresponding to the candidate main category to obtain a subcategory semantic vector corresponding to the sample text. When obtaining a subcategory prediction result corresponding to the sample text based on the subcategory semantic vector, the portion of the semantic representation vector corresponding to the target main category or the semantic representation vector corresponding to the candidate main category in the subcategory semantic vector can increase attention to a predetermined subcategory corresponding to the target main category or the candidate main category.

[0103] Step S208: construct a target loss based on the main category label and the main category prediction result corresponding to the sample text, and the subcategory label and the subcategory prediction result corresponding to the sample text.

[0104] In one embodiment, step S208 includes: constructing a main category classification loss based on the main category label and the main category prediction result corresponding to the sample text, and constructing a subcategory classification loss based on the subcategory label and the subcategory prediction result corresponding to the sample text; and fusing the main category classification loss with the subcategory classification loss to obtain the target loss.

[0105] The main category classification loss describes the degree to which the main category prediction result matches the main category label, and the subcategory classification loss describes the degree to which the subcategory prediction result matches the subcategory label. Computers can use common loss functions to construct the main category classification loss and subcategory classification loss. The following uses the negative logarithmic loss function as an example to illustrate this.

[0106] In one embodiment, the computer device constructs the main category classification loss based on the difference between the main category label corresponding to the sample text and the main category prediction result, which can be expressed by the following formula:

[0107]

[0108] Among them, loss1 is the main category classification loss; y i is the value of the sample text corresponding to the i-th main category. If the i-th main category is the main category marked by the main category label, the value is 1, otherwise it is 0; i is the predicted probability of the sample text corresponding to the i-th main category; n is the number of main categories.

[0109] The computer device constructs the subcategory classification loss based on the difference between the subcategory label corresponding to the sample text and the subcategory prediction result, which can be expressed by the following formula:

[0110]

[0111] Among them, loss2 is the sub-category classification loss; y j is the value of the sample text corresponding to the i-th subcategory. If the j-th subcategory is the subcategory marked by the subcategory label, the value is 1, otherwise it is 0; a j is the predicted probability of the sample text corresponding to the jth subcategory; m is the number of subcategories.

[0112] The computer device fuses the main category classification loss with the subcategory classification loss to obtain the target loss, which can be expressed by the following formula:

[0113] loss=λ1loss1+λ2loss2

[0114] Among them, loss is the target loss; loss1 is the main category classification loss; loss2 is the subcategory classification loss; λ1 is the weight corresponding to the main category classification loss; λ2 is the weight corresponding to the subcategory classification loss.

[0115] In step S210, after updating the model parameters of the text category recognition model according to the target loss, the process returns to the step of obtaining sample text and label data corresponding to the sample text to continue training until the training is completed, thereby obtaining a text category recognition model for identifying text categories.

[0116] In one embodiment, the computer device updates the model parameters of the text category recognition model based on the target loss. In another embodiment, the computer device updates the model parameters of the main category recognition network based on the main category classification loss, and updates the model parameters of the subcategory recognition network based on the subcategory classification loss.

[0117] In one embodiment, the training ends when the number of training times reaches a specified number, or the change in the target loss is less than a specified threshold.

[0118] In the processing method of the above-mentioned text category recognition model, the main category prediction result corresponding to the sample text is obtained through the main category recognition network in the text category recognition model. Since the higher the category system, the more sample data it corresponds to and the lower the classification difficulty, the main category prediction result obtained is often more accurate. Therefore, when predicting the subcategory, the subcategory recognition network in the text category recognition model uses the main category prediction result as prior knowledge, and the subcategory prediction result obtained by predicting the sample text is more accurate. Subsequently, based on the main category label and the main category prediction result corresponding to the sample text, as well as the subcategory label and the subcategory prediction result corresponding to the main category label and the subcategory prediction result corresponding to the sample text, a target loss is constructed. The text category recognition model obtained by training according to the target loss has a higher accuracy in identifying the category of the text. In other words, the prediction result of the high-accuracy upper-level category is used as prior knowledge to influence the prediction result of the lower-level category, thereby improving the accuracy of the text category recognition model for multi-level text classification.

[0119] In one embodiment, the sample text is subjected to category recognition through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text, including: semantic encoding of the sample text through the semantic encoding layer of the main category recognition network to obtain a semantic encoding vector; and conversion of the semantic encoding vector into a prediction probability corresponding to a predetermined main category as the main category prediction result through the normalization layer of the main category recognition network.

[0120] In one embodiment, a computer device inputs a sample text into a main category recognition network in a text category recognition model, performs semantic encoding on the sample text through the semantic encoding layer of the main category recognition network to obtain a semantic encoding vector, and converts the semantic encoding vector into a prediction probability corresponding to each predetermined main category through the normalization layer of the main category recognition network as the main category prediction result corresponding to the sample text.

[0121] In this embodiment, the predicted probability of the sample text corresponding to each predetermined main category is transmitted to the subcategory recognition network as the main category prediction result, so that when the computer device performs category recognition on the sample text through the subcategory recognition network, it can use multiple methods to influence the subcategory prediction result.

[0122] In one embodiment, a subcategory recognition network in a text category recognition model is used to perform category recognition on a sample text based on a main category prediction result to obtain a subcategory prediction result corresponding to the sample text, including: determining a subcategory semantic vector corresponding to the sample text based on a semantic encoding vector corresponding to the main category prediction result and the sample text through an information fusion layer of the subcategory recognition network; and converting the subcategory semantic vector into a prediction probability corresponding to a predetermined subcategory as a subcategory prediction result through a normalization layer of the subcategory recognition network.

[0123] In one embodiment, referring to Figure 5 , Figure 5 Figure 2 shows a schematic diagram of the framework of a text category recognition model in one embodiment. As can be seen, the computer device transmits the semantic encoding vector corresponding to the sample text and the main category prediction result to the subcategory recognition network. The information fusion layer of the subcategory recognition network determines the subcategory semantic vector corresponding to the sample text based on the semantic encoding vector corresponding to the sample text and the main category prediction result. The subcategory semantic vector is then input into the normalization layer of the subcategory recognition network. The normalization layer converts the semantic encoding vector into prediction probabilities corresponding to each predetermined subcategory, which are then used as the subcategory prediction result.

[0124] In one embodiment, a computer device obtains a target main category or candidate main category from the main category prediction result, determines a semantic representation vector corresponding to the target main category or candidate main category, and fuses the semantic representation vector corresponding to the sample text with the semantic representation vector corresponding to the target main category or the semantic representation vector corresponding to the candidate main category to obtain a subcategory semantic vector corresponding to the sample text. Optionally, when the main category prediction result output by the main category recognition network is a predicted probability of the sample text corresponding to each predetermined main category, the computer device determines the target main category to which the sample text belongs based on the predicted probability of the sample text corresponding to each predetermined main category, or selects a candidate main category based on the predicted probability of the sample text corresponding to each predetermined main category.

[0125] In one embodiment, a computer device performs semantic encoding on a target main category or candidate main category using a trained semantic encoding model to obtain a semantic representation vector corresponding to the target main category or candidate main category. Optionally, the semantic encoding model may employ a general semantic encoding network structure, such as a word2vec network structure trained using general corpus data.

[0126] In one embodiment, the computer device concatenates the semantic representation vector corresponding to the sample text with the semantic representation vector corresponding to the target main category or the semantic representation vector corresponding to the candidate main category to obtain the subcategory semantic vector corresponding to the sample text.

[0127] In one embodiment, the splicing method can be Concat splicing, Hadamard product, etc. Assuming that the semantic representation vector corresponding to the target main category is A, the semantic encoding vector corresponding to the sample text is B, and the subcategory semantic vector is C, Concat splicing can be expressed as: C = [AB], and Hadamard product can be expressed as: C = [A*B]. It can be understood that the computer device first converts the semantic representation vector corresponding to the target main category or the semantic representation vector corresponding to the candidate main category and the semantic encoding vector corresponding to the sample text to the same vector dimension, and then splices the semantic representation vector corresponding to the target main category or the semantic representation vector corresponding to the candidate main category with the semantic encoding vector corresponding to the sample text.

[0128] In this embodiment, the sub-category semantic vector corresponding to the sample text is determined based on the semantic encoding vector corresponding to the sample text and the main category prediction result. In this way, the computer device obtains the sub-category prediction result corresponding to the sample text based on the sub-category semantic vector. The relevant part of the main category prediction result in the sub-category semantic vector can affect the sub-category prediction result.

[0129] In one embodiment, based on the main category prediction result and the semantic encoding vector corresponding to the sample text, the subcategory semantic vector corresponding to the sample text is determined, including: determining the candidate main category according to the main category prediction result; fusing the semantic representation vectors corresponding to each candidate main category to obtain the main category semantic vector; and splicing the main category semantic vector with the semantic encoding vector corresponding to the sample text to obtain the subcategory semantic vector corresponding to the sample text.

[0130] In one embodiment, a computer device selects candidate main categories from each predetermined subcategory according to the predicted probability of the sample text corresponding to each predetermined main category through the information fusion layer of the subcategory identification network, fuses the semantic representation vectors corresponding to each candidate main category to obtain a main category semantic vector, and concatenates the main category semantic vector with the semantic encoding vector corresponding to the sample text to obtain a subcategory semantic vector corresponding to the sample text.

[0131] In one embodiment, the computer device sorts the predetermined main categories from high to low according to the predicted probability of the sample text corresponding to each predetermined main category, and selects a specified number of predetermined main categories with the highest ranking from the sorting results as candidate main categories.

[0132] In one embodiment, the computer device concatenates the semantic representation vectors corresponding to the candidate main categories to obtain the main category semantic vector.

[0133] In this embodiment, the semantic representation vectors corresponding to the candidate main categories are fused to obtain the main category semantic vector, and the main category semantic vector is spliced with the semantic encoding vector corresponding to the sample text to obtain the subcategory semantic vector corresponding to the sample text. In this way, the computer device obtains the subcategory prediction result corresponding to the sample text based on the subcategory semantic vector. The relevant part of the main category semantic vector in the subcategory semantic vector can enhance the attention to the predetermined subcategories corresponding to each candidate main category.

[0134] In one embodiment, the semantic representation vectors corresponding to the candidate main categories are integrated to obtain the main category semantic vector, including: determining the semantic representation vector corresponding to each candidate main category; determining the prediction probability corresponding to each candidate main category based on the main category prediction result; and weighted summing the semantic representation vectors corresponding to each candidate main category according to the prediction probability corresponding to each candidate main category to obtain the main category semantic vector.

[0135] Specifically, considering that the prediction probabilities of the sample text corresponding to each predetermined main category are different, the computer device first performs weighted summation of the semantic representation vectors corresponding to each candidate main category according to the prediction probability corresponding to each candidate main category to obtain the main category semantic vector.

[0136] In one embodiment, the computer device determines the weight corresponding to each candidate main category based on the predicted probability corresponding to each candidate main category, and weightedly sums the semantic representation vectors corresponding to each candidate main category according to the weight corresponding to each candidate main category to obtain the main category semantic vector. For example, the computer device sorts each candidate main category in descending order according to the predicted probability corresponding to each candidate main category, and assigns each candidate main category a weight corresponding to the ranking in the sorting result, such as the higher the ranking, the higher the weight. For another example, the computer device determines the weight corresponding to each candidate main category based on the proportional relationship between the predicted probabilities corresponding to each candidate main category. For another example, the computer device uses the predicted probability corresponding to each candidate main category as the weight.

[0137] In this embodiment, according to the prediction probability corresponding to each candidate main category, the semantic representation vectors corresponding to each candidate main category are weighted and summed to obtain the main category semantic vector. The main category semantic vector is spliced with the semantic encoding vector corresponding to the sample text to obtain the sub-category semantic vector corresponding to the sample text. In this way, the computer device obtains the sub-category prediction result corresponding to the sample text based on the sub-category semantic vector. The relevant part of the main category semantic vector in the sub-category semantic vector can enhance the attention to the predetermined sub-category corresponding to each candidate main category to varying degrees.

[0138] In one embodiment, a subcategory recognition network in a text category recognition model is used to perform category recognition on a sample text based on a main category prediction result to obtain a subcategory prediction result corresponding to the sample text, including: converting a semantic encoding vector corresponding to the sample text into a prediction probability corresponding to a predetermined subcategory through a normalization layer of the subcategory recognition network; adjusting the prediction probability corresponding to a predetermined subcategory belonging to the corresponding predetermined main category according to the prediction probability corresponding to each predetermined main category in the main category prediction result through an information correction layer of the subcategory recognition network, and using the adjusted prediction probability of the corresponding predetermined subcategory as the subcategory prediction result.

[0139] In one embodiment, referring to Figure 6 , Figure 6 A schematic diagram of the framework of a text category recognition model in one embodiment is shown in FIG. As can be seen, the computer device transmits the semantic encoding vector corresponding to the sample text and the main category prediction result to the subcategory recognition network. The normalization layer of the subcategory recognition network converts the semantic encoding vector corresponding to the sample text into prediction probabilities corresponding to each predetermined subcategory. The information correction layer of the subcategory recognition network adjusts the prediction probabilities corresponding to the predetermined subcategories subordinate to the corresponding predetermined main category based on the prediction probabilities corresponding to each predetermined main category in the main category prediction result. The adjusted prediction probabilities of the corresponding predetermined subcategories are used as the subcategory prediction results.

[0140] In one embodiment, a computer device determines the weight corresponding to each predetermined main category based on the prediction probability corresponding to each predetermined main category in the main category prediction result, and adjusts the prediction probability corresponding to the predetermined sub-category subordinate to the corresponding predetermined main category according to the weight corresponding to each predetermined main category to obtain a sub-category prediction result.

[0141] In one embodiment, the computer device ranks the predetermined main categories in descending order based on the predicted probabilities corresponding to the predetermined main categories, and assigns a weight to each predetermined main category corresponding to the ranking in the ranking result, such that the higher the ranking, the higher the weight. In other embodiments, the computer device determines the weight corresponding to each predetermined main category based on the proportional relationship between the predicted probabilities corresponding to the predetermined main categories. Alternatively, the computer device uses the predicted probabilities corresponding to the predetermined main categories as weights.

[0142] In one embodiment, for each predetermined main category, the weight corresponding to the predetermined main category is multiplied by the predicted probability corresponding to the predetermined sub-category belonging to the predetermined main category to obtain a sub-category prediction result.

[0143] In one embodiment, the computer device obtains the target main category or candidate main category corresponding to the sample text from the main category prediction results, increases the prediction probability corresponding to the predetermined subcategories subordinate to the target main category or candidate main category, and decreases the prediction probability corresponding to the remaining predetermined subcategories.

[0144] In one embodiment, for predetermined subcategories subordinate to candidate main categories, a computer device determines the degree of increase corresponding to each candidate main category according to the predicted probability corresponding to each candidate main category, and increases the predicted probability corresponding to the predetermined subcategories subordinate to the corresponding candidate main category according to the degree of increase corresponding to each candidate main category. The degree of increase corresponding to the candidate main category is proportional to the predicted probability corresponding to the candidate main category.

[0145] In one embodiment, for the remaining predetermined subcategories, the computer device determines the total reduction degree corresponding to each of the remaining predetermined subcategories, determines a mean reduction degree based on the total reduction degree and the number of remaining predetermined subcategories, and reduces the predicted probability corresponding to each of the remaining predetermined subcategories by the mean reduction degree. In another embodiment, the computer device determines the reduction degree corresponding to each predetermined main category based on the total reduction degree and the predicted probability corresponding to the predetermined main category to which each of the remaining predetermined subcategories belongs, and reduces the predicted probability corresponding to each of the remaining predetermined subcategories by the reduction degree corresponding to each predetermined main category, with the reduction degree corresponding to each predetermined main category being inversely proportional to the predicted probability corresponding to the predetermined main category.

[0146] In this embodiment, the prediction probabilities corresponding to the predetermined subcategories belonging to the corresponding predetermined main categories are adjusted according to the prediction probabilities corresponding to each predetermined main category in the main category prediction results. This can increase the attention paid to the predetermined subcategories corresponding to the predetermined main categories with high hit possibilities, and reduce the attention paid to the predetermined subcategories corresponding to the predetermined main categories with low hit possibilities.

[0147] In one embodiment, a target loss is constructed based on the main category tag and the main category prediction result corresponding to the sample text, and the subcategory tag and the subcategory prediction result corresponding to the sample text, including: constructing a main category classification loss based on the main category tag and the main category prediction result corresponding to the sample text, and constructing a subcategory classification loss based on the subcategory tag and the subcategory prediction result corresponding to the sample text; extracting the prediction probability corresponding to the main category tag from the main category prediction result, extracting the prediction probability corresponding to the subcategory tag from the subcategory prediction result, and constructing a hinge loss based on the prediction probability corresponding to the main category tag and the prediction probability corresponding to the subcategory tag; after fusing the main category classification loss, the subcategory classification loss and the hinge loss, a target loss is obtained, and the hinge loss is used to make the prediction probability of each predetermined subcategory in the main category prediction result output by the updated text category recognition model less than the prediction probability corresponding to the predetermined main category to which it belongs.

[0148] The inventors have considered that in multi-level classification, the higher the category, the coarser the classification granularity, and the fewer the classification categories, the predicted probability that the sample text belongs to the classification category should be greater than the predicted probability that the sample text belongs to the lower category, and of course the lower category is subordinate to the classification category. For example, the predicted probability that the sample text belongs to the classification category "application" should be greater than the predicted probability that the sample text belongs to the lower category "applet" of "application". For the above considerations, the computer device extracts the predicted probability corresponding to the main category marked by the main category target label from the main category prediction result as the predicted probability corresponding to the main category target label, and extracts the predicted probability corresponding to the subcategory marked by the subcategory target label as the predicted probability corresponding to the subcategory target label. According to the predicted probability corresponding to the main category target label and the predicted probability corresponding to the subcategory target label, the hinge loss is constructed, and the main category classification loss, the subcategory classification loss and the hinge loss are integrated to obtain the target loss.

[0149] In one embodiment, the hinge loss can be expressed by the following formula:

[0150] loss * =max(0,α+score2-score1)

[0151] Among them, loss * is the hinge loss; α is a constant; score2 is the predicted probability of the sample text corresponding to the subcategory labeled with the subcategory label, and score1 is the predicted probability of the sample text corresponding to the main category labeled with the main category label.

[0152] The target loss can be expressed by the following formula:

[0153] loss=λ1loss1+λ2loss2+λ3loss *

[0154] Among them, loss is the target loss; loss1 is the main category classification loss; loss2 is the subcategory classification loss; loss * is the hinge loss; λ1 is the weight corresponding to the main category classification loss; λ2 is the weight corresponding to the subcategory classification loss; λ3 is the weight corresponding to the hinge loss.

[0155] In this embodiment, hinge loss is added to the target loss. Hinge loss is a loss constructed based on the characteristics of multi-level classification, which helps to improve the training effect.

[0156] In one embodiment, the subcategory tag subordinate to the main category tag includes a first subcategory tag subordinate to the main category tag and a second subcategory tag subordinate to the first subcategory tag; performing category recognition on the sample text based on the main category prediction result through the subcategory recognition network in the text category recognition model to obtain the subcategory prediction result corresponding to the sample text, including: performing category recognition on the sample text based on the main category prediction result through the first subcategory recognition network connected to the main category recognition network in the text category recognition model to obtain the first subcategory prediction result corresponding to the sample text; performing category recognition on the sample text based on the main category prediction result through the text category recognition network; The second subcategory recognition network connected to the first subcategory recognition network in the model performs category recognition on the sample text based on the first subcategory prediction result to obtain a second subcategory prediction result corresponding to the sample text; based on the main category label and the main category prediction result corresponding to the sample text, and the subcategory label and the subcategory prediction result corresponding to the sample text, a target loss is constructed, including: based on the main category label and the main category prediction result corresponding to the sample text, the first subcategory label and the first subcategory prediction result corresponding to the sample text, and the second subcategory label and the second subcategory prediction result corresponding to the sample text, a target loss is constructed.

[0157] This embodiment is applicable to training a text category recognition model for multi-level text classification. Multi-level classification involves classifying text into more than one category, with subordinate relationships between these categories. For example, it identifies a main category to which a text belongs and more than one subcategory, with subordinate relationships between these subcategories. This embodiment uses the example of training a text category recognition model for classifying text into a main category, a first subcategory, and a second subcategory.

[0158] In one embodiment, a computer device performs category recognition on a sample text based on a main category prediction result through a first subcategory recognition network connected to a main category recognition network in a text category recognition model, and obtains a first subcategory prediction result corresponding to the sample text; performs category recognition on the sample text based on the first subcategory prediction result or the main category prediction result through a second subcategory recognition network connected to the first subcategory recognition network in the text category recognition model, and obtains a second subcategory prediction result corresponding to the sample text; constructs a target loss based on the difference between the main category label corresponding to the sample text and the main category prediction result, the difference between the first subcategory label corresponding to the sample text and the first subcategory prediction result, and the difference between the second subcategory label corresponding to the sample text and the second subcategory prediction result; and updates the model parameters of the text category recognition model according to the target loss.

[0159] In one embodiment, a computer device constructs a hinge loss based on at least two of the prediction probabilities corresponding to the main category target tag, the prediction probabilities corresponding to the first subcategory target tag, and the prediction probabilities corresponding to the second subcategory target tag, and constructs a target loss based on the difference between the main category target tag corresponding to the sample text and the main category prediction result, the difference between the first subcategory target tag corresponding to the sample text and the first subcategory prediction result, the difference between the second subcategory target tag corresponding to the sample text and the second subcategory prediction result, and the hinge loss.

[0160] In this embodiment, a text category recognition model for multi-level classification of text is trained. Since the sub-category recognition network recognizes the category of the sample text based on the main category prediction results or the upper-level sub-category recognition results, the trained text category recognition model can use the highly accurate upper-level category prediction results as prior knowledge to influence the lower-level category prediction results when performing multi-level classification of text, thereby improving the accuracy of multi-level classification of text.

[0161] In one embodiment, the method further includes: obtaining text to be recognized; inputting the text to be recognized into a trained text category recognition model; performing category recognition on the text to be recognized through a main category recognition network in the trained text category recognition model, and obtaining a main category prediction result corresponding to the text to be recognized; performing category recognition on the text to be recognized based on the main category prediction result through a subcategory recognition network in the trained text category recognition model, and obtaining a subcategory prediction result corresponding to the text to be recognized; and determining the main category and / or subcategory corresponding to the text to be recognized based on the subcategory prediction result.

[0162] The text to be recognized is the text to be identified into the category through the trained text category recognition model.

[0163] In one embodiment, a computer device inputs the text to be recognized into a trained text category recognition model, and performs category recognition on the text to be recognized through the main category recognition network in the trained text category recognition model, obtaining the predicted probability of the text to be recognized corresponding to each predetermined main category as the main category prediction result, and performs category recognition on the text to be recognized based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, obtaining the predicted probability of the text to be recognized corresponding to each predetermined subcategory as the subcategory prediction result, and determining the main category and / or subcategory corresponding to the text to be recognized based on the subcategory prediction result. Optionally, the computer device selects the predetermined subcategory with the highest prediction probability as the subcategory corresponding to the text to be recognized based on the subcategory prediction result.

[0164] In one embodiment, a computer device can obtain corresponding category prediction results from each level of the category recognition network in a trained text category recognition model, and determine the main category and subcategory corresponding to the text to be recognized based on the category prediction results corresponding to each level of the category recognition network. The computer device can also obtain the final subcategory and, based on the final subcategory, trace back to the source to determine the main category and subcategory corresponding to the text to be recognized.

[0165] In this embodiment, when the trained text category recognition model classifies text, it can use the prediction results of the high-accuracy upper-level categories as prior knowledge to influence the prediction results of the lower-level categories, thereby improving the accuracy of text classification.

[0166] In one embodiment, referring to Figure 7 , provides a processing method for a text category recognition model, comprising the following steps:

[0167] Step S702 : Acquire sample text and label data corresponding to the sample text. The label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label.

[0168] In step S704, the sample text is semantically encoded through the semantic encoding layer of the main category recognition network to obtain a semantic encoding vector; and the semantic encoding vector is converted into a prediction probability corresponding to the predetermined main category through the normalization layer of the main category recognition network as the main category prediction result.

[0169] Step S706: Determine candidate main categories based on the main category prediction results through the information fusion layer of the sub-category recognition network; determine the semantic representation vector corresponding to each candidate main category; determine the prediction probability corresponding to each candidate main category based on the main category prediction results; and perform weighted summation of the semantic representation vectors corresponding to each candidate main category according to the prediction probability corresponding to each candidate main category to obtain the main category semantic vector.

[0170] In step S708, the main category semantic vector is concatenated with the semantic encoding vector corresponding to the sample text to obtain the subcategory semantic vector corresponding to the sample text; the subcategory semantic vector is converted into the prediction probability corresponding to the predetermined subcategory through the normalization layer of the subcategory recognition network as the subcategory prediction result.

[0171] Step S710: Based on the main category tag and the main category prediction result corresponding to the sample text, the main category classification loss is constructed; based on the subcategory tag and the subcategory prediction result corresponding to the sample text, the subcategory classification loss is constructed; from the main category prediction result, the prediction probability corresponding to the main category tag is extracted; from the subcategory prediction result, the prediction probability corresponding to the subcategory tag is extracted; and based on the prediction probability corresponding to the main category tag and the prediction probability corresponding to the subcategory tag, the hinge loss is constructed.

[0172] The hinge loss is used to ensure that, in the main category prediction result output by the updated text category recognition model, the prediction probability of each predetermined subcategory is less than the prediction probability corresponding to the predetermined main category to which it belongs.

[0173] In step S712, the main category classification loss, the subcategory classification loss, and the hinge loss are integrated to obtain the target loss.

[0174] Step S714, after updating the model parameters of the text category recognition model according to the target loss, returns to the step of obtaining sample text and label data corresponding to the sample text to continue training until the training is completed, and a text category recognition model for identifying text categories is obtained.

[0175] The processing method of the above-mentioned text category recognition model obtains the main category prediction result corresponding to the sample text through the main category recognition network in the text category recognition model. Since the higher the category system, the more sample data it corresponds to and the lower the classification difficulty, the main category prediction result obtained is often more accurate. Then, when predicting the subcategory, the subcategory recognition network in the text category recognition model uses the main category prediction result as prior knowledge, and the subcategory prediction result obtained by predicting the sample text is more accurate. Then, based on the main category label and the main category prediction result corresponding to the sample text, the subcategory label and the subcategory prediction result corresponding to the main category label and the subcategory prediction result corresponding to the sample text, and the prediction probability corresponding to the main category label and the prediction probability corresponding to the subcategory label, the target loss is constructed. The text category recognition model obtained by training according to the target loss has a higher accuracy in identifying the category of the text. In other words, the prediction result of the upper-level category with high accuracy is used as prior knowledge to influence the prediction result of the lower-level category, thereby improving the accuracy of the text category recognition model for multi-level text classification.

[0176] In one embodiment, Figure 8 As shown, a text category recognition method is provided. This embodiment mainly applies this method to the above Figure 1 Taking the computer device (terminal 102 or server 104) in the example as an example, the following steps are included:

[0177] Step S802: Obtain the text to be recognized.

[0178] Among them, the text to be recognized is the text to be classified by the text category recognition model trained in the embodiment of this application.

[0179] In one embodiment, a computer device obtains text to be recognized from an application scenario of a text category recognition model. For example, if a text category recognition model is used to classify a video based on its title text, the computer device obtains the video title text as the text to be recognized. For another example, if a text category recognition model is used to classify input text to search for objects corresponding to the input text within a corresponding category, the computer device uses the input text as the text to be recognized.

[0180] Step S804 : performing category recognition on the text to be recognized through the main category recognition network in the trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized.

[0181] In one embodiment, the main category prediction result is the predicted probability that the to-be-recognized text corresponds to each predetermined main category.

[0182] Regarding the specific implementation of step S804, reference may be made to the specific implementation of step S204 in the above embodiment, which will not be repeated here.

[0183] Step S806 , using the subcategory recognition network in the trained text category recognition model, the text to be recognized is subjected to category recognition based on the main category prediction result, and a subcategory prediction result corresponding to the text to be recognized is obtained.

[0184] In one embodiment, the subcategory prediction result is the predicted probability that the to-be-recognized text corresponds to each predetermined subcategory.

[0185] Regarding the specific implementation of step S806, reference may be made to the specific implementation of step S206 in the above embodiment, which will not be repeated here.

[0186] Step S808 : determining a target category corresponding to the text to be recognized based on the subcategory prediction result, where the target category includes at least one of a main category and a subcategory.

[0187] In one embodiment, the computer device selects a predetermined subcategory with the highest prediction probability as the subcategory corresponding to the text to be recognized based on the subcategory prediction result.

[0188] In one embodiment, a computer device can obtain corresponding category prediction results from each level of the category recognition network in a trained text category recognition model, and determine the main category and subcategory corresponding to the text to be recognized based on the category prediction results corresponding to each level of the category recognition network. The computer device can also obtain the final subcategory and, based on the final subcategory, trace back to the source to determine the main category and subcategory corresponding to the text to be recognized.

[0189] In the above-mentioned text category recognition method, the main category prediction result corresponding to the text to be recognized is obtained through the main category recognition network in the trained text category recognition model. The subcategory prediction result corresponding to the text to be recognized is obtained based on the main category prediction result through the subcategory recognition network in the trained text category recognition model. The target category corresponding to the text to be recognized is determined according to the subcategory prediction result. Since the trained text category recognition model uses the high-accuracy prediction result of the upper-level category as prior knowledge when classifying the text, it affects the prediction result of the lower-level category, thereby improving the accuracy of multi-level text classification.

[0190] In one embodiment, obtaining the text to be recognized includes: obtaining an uploaded target video; extracting the video title text corresponding to the target video as the text to be recognized; after determining the target category corresponding to the text to be recognized based on the subcategory prediction result, the method also includes: generating video semantic features corresponding to the target video based on the target category corresponding to the video title text.

[0191] Video semantic features are data that describe the semantic properties of a video. The category to which a video belongs is one of the characteristic dimensions of video semantic features. Video semantic features can be applied in video search scenarios. For example, by matching the input text used for video search with the video semantic features corresponding to each video, the video corresponding to the input text is identified, i.e., the search results corresponding to the input text are found.

[0192] In one embodiment, a computer device extracts the video title text corresponding to the uploaded target video, determines the target category corresponding to the video title text through the text category recognition model trained in this application, and generates video semantic features corresponding to the target video based on the target category corresponding to the video title text.

[0193] The text category recognition model trained in this application is suitable for video classification scenarios, and can perform coarse-grained classification, fine-grained classification, or multi-level classification on videos, and improve classification accuracy.

[0194] In one embodiment, obtaining text to be recognized includes: obtaining an object search request; extracting input text for searching a target object from the object search request as text to be recognized; after determining a target category corresponding to the text to be recognized based on a subcategory prediction result, the method further includes: searching for a target object that matches the target category based on the target category corresponding to the input text; and returning the target object in response to the object search request.

[0195] In one embodiment, a computer device extracts input text for searching a target object from an object search request, determines a target category corresponding to the input text through a text category recognition model trained in the present application, and searches for the target object corresponding to the input text among the objects belonging to the target category, that is, the search result corresponding to the input text.

[0196] The text category recognition model trained in this application is suitable for search scenarios and can improve search efficiency in search scenarios.

[0197] It should be understood that although Figure 2 、 7 The steps in the flowchart of -8 are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2 、 7 -At least part of the steps in 8 may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0198] In one embodiment, Figure 9 As shown, a processing device for a text category recognition model is provided. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device. The device specifically includes: an acquisition module 902, a main category recognition module 904, a subcategory recognition module 906, a loss construction module 908 and a training module 910, wherein:

[0199] An acquisition module 902 is configured to acquire sample text and label data corresponding to the sample text, wherein the label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label;

[0200] The main category identification module 904 is used to perform category identification on the sample text through the main category identification network in the text category identification model to obtain the main category prediction result corresponding to the sample text;

[0201] The subcategory identification module 906 is configured to perform category identification on the sample text based on the main category prediction result through the subcategory identification network in the text category identification model, and obtain the subcategory prediction result corresponding to the sample text;

[0202] A loss construction module 908 is configured to construct a target loss based on the main category label and the main category prediction result corresponding to the sample text, and the subcategory label and the subcategory prediction result corresponding to the sample text;

[0203] The training module 910 is used to update the model parameters of the text category recognition model according to the target loss, and then return to the step of obtaining sample text and label data corresponding to the sample text to continue training until the training is completed, thereby obtaining a text category recognition model for identifying text categories.

[0204] In one embodiment, the main category identification module 904 is also used to: perform semantic encoding on the sample text through the semantic encoding layer of the main category identification network to obtain a semantic encoding vector; and convert the semantic encoding vector into a prediction probability corresponding to a predetermined main category through the normalization layer of the main category identification network as the main category prediction result.

[0205] In one embodiment, the subcategory identification module 906 is further used to: determine the subcategory semantic vector corresponding to the sample text based on the main category prediction result and the semantic encoding vector corresponding to the sample text through the information fusion layer of the subcategory identification network; and convert the subcategory semantic vector into a prediction probability corresponding to a predetermined subcategory as a subcategory prediction result through the normalization layer of the subcategory identification network.

[0206] In one embodiment, the subcategory identification module 906 is further used to: determine candidate main categories based on the main category prediction results; fuse the semantic representation vectors corresponding to each candidate main category to obtain a main category semantic vector; and concatenate the main category semantic vector with the semantic encoding vector corresponding to the sample text to obtain a subcategory semantic vector corresponding to the sample text.

[0207] In one embodiment, the subcategory identification module 906 is further used to: determine the semantic representation vector corresponding to each candidate main category; determine the prediction probability corresponding to each candidate main category based on the main category prediction result; and weightedly sum the semantic representation vectors corresponding to each candidate main category according to the prediction probability corresponding to each candidate main category to obtain the main category semantic vector.

[0208] In one embodiment, the subcategory identification module 906 is further used to: convert the semantic coding vector corresponding to the sample text into the prediction probability of the corresponding predetermined subcategory through the normalization layer of the subcategory identification network; adjust the prediction probability corresponding to the predetermined subcategory belonging to the corresponding predetermined main category according to the prediction probability corresponding to each predetermined main category in the main category prediction result through the information correction layer of the subcategory identification network, and use the adjusted prediction probability of the corresponding predetermined subcategory as the subcategory prediction result.

[0209] In one embodiment, the loss construction module 908 is further used to: construct a main category classification loss based on the main category target label and the main category prediction result corresponding to the sample text, and construct a subcategory classification loss based on the subcategory target label and the subcategory prediction result corresponding to the sample text; after fusing the main category classification loss with the subcategory classification loss, a target loss is obtained.

[0210] In one embodiment, the loss construction module 908 is further used to: construct a main category classification loss based on the main category tag and the main category prediction result corresponding to the sample text, and construct a subcategory classification loss based on the subcategory tag and the subcategory prediction result corresponding to the sample text; extract the prediction probability corresponding to the main category tag from the main category prediction result, extract the prediction probability corresponding to the subcategory tag from the subcategory prediction result, and construct a hinge loss based on the prediction probability corresponding to the main category tag and the prediction probability corresponding to the subcategory tag; after fusing the main category classification loss, the subcategory classification loss and the hinge loss, a target loss is obtained. The hinge loss is used to make the prediction probability of each predetermined subcategory in the main category prediction result output by the updated text category recognition model less than the prediction probability corresponding to the predetermined main category to which it belongs.

[0211] In one embodiment, the subcategory tag subordinate to the main category tag includes a first subcategory tag subordinate to the main category tag and a second subcategory tag subordinate to the first subcategory tag; the subcategory identification module 906 is further used to: perform category identification on the sample text based on the main category prediction result through the first subcategory identification network connected to the main category identification network in the text category identification model, and obtain a first subcategory prediction result corresponding to the sample text; perform category identification on the sample text based on the first subcategory prediction result through the second subcategory identification network connected to the first subcategory identification network in the text category identification model, and obtain a second subcategory prediction result corresponding to the sample text; the loss construction module 908 is further used to: construct a target loss based on the main category tag and the main category prediction result corresponding to the sample text, the first subcategory tag and the first subcategory prediction result corresponding to the sample text, and the second subcategory tag and the second subcategory prediction result corresponding to the sample text.

[0212] In one embodiment, the processing device of the text category recognition model also includes an input module and a determination module, and the acquisition module 902 is further used to: obtain the text to be recognized; the input module is used to: input the text to be recognized into the trained text category recognition model; the main category recognition module 904 is further used to: perform category recognition on the text to be recognized through the main category recognition network in the trained text category recognition model, and obtain the main category prediction result corresponding to the text to be recognized; the subcategory recognition module 906 is further used to: perform category recognition on the text to be recognized based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, and obtain the subcategory prediction result corresponding to the text to be recognized; the determination module is used to: determine the main category and / or subcategory corresponding to the text to be recognized according to the subcategory prediction result.

[0213] For the specific definition of the processing device of the text category recognition model, please refer to the definition of the processing method of the text category recognition model above, which will not be repeated here. The various modules in the processing device of the above-mentioned text category recognition model can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0214] In the processing device of the above-mentioned text category recognition model, the main category prediction result corresponding to the sample text is obtained through the main category recognition network in the text category recognition model. Since the higher the category system, the more sample data it corresponds to and the lower the classification difficulty, the main category prediction result obtained is often more accurate. Therefore, when predicting the subcategory, the subcategory recognition network in the text category recognition model uses the main category prediction result as prior knowledge, and the subcategory prediction result obtained by predicting the sample text is more accurate. Subsequently, based on the main category label and the main category prediction result corresponding to the sample text, as well as the subcategory label and the subcategory prediction result corresponding to the main category label and the subcategory prediction result corresponding to the sample text, a target loss is constructed. The text category recognition model obtained by training according to the target loss has a higher accuracy in identifying the category of the text. In other words, the prediction result of the high-accuracy upper-level category is used as prior knowledge to influence the prediction result of the lower-level category, thereby improving the accuracy of the text category recognition model for multi-level text classification.

[0215] In one embodiment, Figure 10 As shown, a text category recognition device is provided. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device. The device specifically includes: an acquisition module 1002, a main category recognition module 1004, a subcategory recognition module 1006 and a determination module 1008, wherein:

[0216] An acquisition module 1002 is used to acquire the text to be recognized;

[0217] The main category recognition module 1004 is used to perform category recognition on the text to be recognized using the main category recognition network in the trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized;

[0218] The subcategory recognition module 1006 is configured to perform category recognition on the text to be recognized based on the main category prediction result using the subcategory recognition network in the trained text category recognition model, and obtain the subcategory prediction result corresponding to the text to be recognized;

[0219] The determination module 1008 is configured to determine a target category corresponding to the to-be-recognized text according to the subcategory prediction result, where the target category includes at least one of a main category and a subcategory.

[0220] In one embodiment, the acquisition module 1002 is also used to: acquire the uploaded target video; extract the video title text corresponding to the target video as the text to be identified; the text category identification device also includes a generation module, which is used to: generate video semantic features corresponding to the target video according to the target category corresponding to the video title text.

[0221] In one embodiment, the acquisition module 1002 is also used to: obtain an object search request; extract the input text for searching the target object from the object search request as the text to be identified; the text category identification device also includes a search module and a return module, the generation module is used to: search for the target object matching the target category according to the target category corresponding to the input text; the return module is used to: return the target object in response to the object search request.

[0222] For the specific definition of the text category identification device, please refer to the definition of the text category identification method above, which will not be repeated here. The various modules in the above-mentioned text category identification device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0223] In the above-mentioned text category recognition device, the main category prediction result corresponding to the text to be recognized is obtained through the main category recognition network in the trained text category recognition model, and the subcategory prediction result corresponding to the text to be recognized is obtained based on the main category prediction result through the subcategory recognition network in the trained text category recognition model. The target category corresponding to the text to be recognized is determined according to the subcategory prediction result. Since the trained text category recognition model uses the high-accuracy prediction result of the upper-level category as prior knowledge when classifying the text, it affects the prediction result of the lower-level category, thereby improving the accuracy of multi-level text classification.

[0224] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 11 As shown. The computer device includes a processor, a memory and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store processing data and / or image generation data of a text category recognition model. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for processing a text category recognition model and / or a text category recognition method is implemented.

[0225] In one embodiment, a computer device is provided. The computer device can be a terminal or a face acquisition device. The internal structure diagram thereof can be as follows: Figure 12 As shown. The computer device includes a processor, a memory, a communication interface and an image acquisition device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, it implements a method for processing a text category recognition model and / or a text category recognition method.

[0226] Those skilled in the art will understand that Figure 11 and Figure 12The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0227] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.

[0228] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.

[0229] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including 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 steps of each of the above-described method embodiments.

[0230] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0231] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0232] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. A method for processing a text category recognition model, characterized in that: The method comprises: Acquire a sample text and label data corresponding to the sample text, wherein the label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label; Performing category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text; Performing category recognition on the sample text based on the main category prediction result using a subcategory recognition network in the text category recognition model to obtain a subcategory prediction result corresponding to the sample text, including: converting the semantic encoding vector corresponding to the sample text into a prediction probability corresponding to a predetermined subcategory using a normalization layer of the subcategory recognition network; adjusting the prediction probabilities corresponding to predetermined subcategories subordinate to the corresponding predetermined main category based on the prediction probabilities corresponding to each predetermined main category in the main category prediction result using an information correction layer of the subcategory recognition network, and using the adjusted prediction probabilities of the corresponding predetermined subcategories as the subcategory prediction result; Constructing a target loss based on the main category label corresponding to the sample text and the main category prediction result, and the subcategory label corresponding to the sample text and the subcategory prediction result; After updating the model parameters of the text category recognition model according to the target loss, return to the step of obtaining the sample text and the label data corresponding to the sample text to continue training until the training is completed, and obtain a text category recognition model for identifying text categories.

2. The method according to claim 1, characterized in that The method of performing category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text includes: Performing semantic encoding on the sample text through the semantic encoding layer of the main category recognition network to obtain a semantic encoding vector; The semantic encoding vector is converted into a prediction probability corresponding to a predetermined main category through a normalization layer of the main category recognition network as the main category prediction result.

3. The method according to claim 1, characterized in that The step of performing category recognition on the sample text based on the main category prediction result by using the subcategory recognition network in the text category recognition model to obtain a subcategory prediction result corresponding to the sample text includes: Determining, through the information fusion layer of the subcategory identification network, a subcategory semantic vector corresponding to the sample text based on the main category prediction result and the semantic encoding vector corresponding to the sample text; The subcategory semantic vector is converted into a prediction probability corresponding to a predetermined subcategory through a normalization layer of the subcategory identification network as the subcategory prediction result.

4. The method according to claim 3, characterized in that The determining of the subcategory semantic vector corresponding to the sample text based on the main category prediction result and the semantic coding vector corresponding to the sample text includes: Determining a candidate main category according to the main category prediction result; Fusing the semantic representation vectors corresponding to the candidate main categories to obtain a main category semantic vector; After concatenating the main category semantic vector and the semantic encoding vector corresponding to the sample text, a subcategory semantic vector corresponding to the sample text is obtained.

5. The method according to claim 4, characterized in that The fusing of the semantic representation vectors corresponding to the candidate main categories to obtain the main category semantic vector includes: Determining a semantic representation vector corresponding to each candidate main category; Determining the prediction probability corresponding to each candidate main category according to the main category prediction result; According to the prediction probability corresponding to each candidate main category, the semantic representation vectors corresponding to each candidate main category are weighted and summed to obtain the main category semantic vector.

6. The method according to claim 1, characterized in that The constructing a target loss based on the main category label corresponding to the sample text and the main category prediction result, and the subcategory label corresponding to the sample text and the subcategory prediction result includes: Based on the main category label corresponding to the sample text and the main category prediction result, a main category classification loss is constructed; based on the subcategory label corresponding to the sample text and the subcategory prediction result, a subcategory classification loss is constructed; After fusing the main category classification loss with the subcategory classification loss, the target loss is obtained.

7. The method according to claim 1, characterized in that The constructing a target loss based on the main category label corresponding to the sample text and the main category prediction result, and the subcategory label corresponding to the sample text and the subcategory prediction result includes: Based on the main category label corresponding to the sample text and the main category prediction result, a main category classification loss is constructed; based on the subcategory label corresponding to the sample text and the subcategory prediction result, a subcategory classification loss is constructed; Extracting the predicted probability corresponding to the main category tag from the main category prediction result, extracting the predicted probability corresponding to the subcategory tag from the subcategory prediction result, and constructing the hinge loss based on the predicted probability corresponding to the main category tag and the predicted probability corresponding to the subcategory tag; After fusing the main category classification loss, the subcategory classification loss and the hinge loss, a target loss is obtained. The hinge loss is used to ensure that the prediction probability of each predetermined subcategory in the main category prediction result output by the updated text category recognition model is less than the prediction probability corresponding to the predetermined main category to which it belongs.

8. The method according to claim 1, characterized in that The subcategory tag subordinate to the main category tag includes a first subcategory tag subordinate to the main category tag and a second subcategory tag subordinate to the first subcategory tag; The step of performing category recognition on the sample text based on the main category prediction result by using the subcategory recognition network in the text category recognition model to obtain a subcategory prediction result corresponding to the sample text includes: performing category recognition on the sample text based on the main category prediction result through a first subcategory recognition network connected to the main category recognition network in the text category recognition model to obtain a first subcategory prediction result corresponding to the sample text; performing category recognition on the sample text based on the first subcategory prediction result using a second subcategory recognition network in the text category recognition model that is connected to the first subcategory recognition network, to obtain a second subcategory prediction result corresponding to the sample text; The constructing a target loss based on the main category label corresponding to the sample text and the main category prediction result, and the subcategory label corresponding to the sample text and the subcategory prediction result includes: The target loss is constructed based on the main category label corresponding to the sample text and the main category prediction result, the first subcategory label corresponding to the sample text and the first subcategory prediction result, and the second subcategory label corresponding to the sample text and the second subcategory prediction result.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: Get the text to be recognized; Input the text to be recognized into a trained text category recognition model; Performing category recognition on the text to be recognized using the main category recognition network in the trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized; Using the subcategory recognition network in the trained text category recognition model, the text to be recognized is subjected to category recognition based on the main category prediction result, thereby obtaining a subcategory prediction result corresponding to the text to be recognized; The main category and / or subcategory corresponding to the text to be recognized is determined according to the subcategory prediction result.

10. A method for identifying text categories, characterized in that: The method comprises: Get the text to be recognized; Performing category recognition on the text to be recognized using a main category recognition network in a trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized; the text category recognition model is obtained by the processing method of the text category recognition model according to any one of claims 1 to 9; Using the subcategory recognition network in the trained text category recognition model, the text to be recognized is subjected to category recognition based on the main category prediction result, thereby obtaining a subcategory prediction result corresponding to the text to be recognized; A target category corresponding to the to-be-recognized text is determined according to the subcategory prediction result, where the target category includes at least one of a main category and a subcategory.

11. The method according to claim 10, characterized in that The step of obtaining the text to be recognized includes: Get the uploaded target video; Extracting the video title text corresponding to the target video as the text to be recognized; After determining the target category corresponding to the to-be-recognized text according to the subcategory prediction result, the method further includes: According to the target category corresponding to the video title text, a video semantic feature corresponding to the target video is generated.

12. The method according to claim 10, characterized in that The step of obtaining the text to be recognized includes: Get object search request; extracting input text for searching a target object from the object search request as the text to be recognized; After determining the target category corresponding to the to-be-recognized text according to the subcategory prediction result, the method further includes: According to the target category corresponding to the input text, searching for a target object that matches the target category; In response to the object search request, the target object is returned.

13. A processing device for a text category recognition model, characterized in that: The device comprises: An acquisition module, configured to acquire a sample text and label data corresponding to the sample text, wherein the label data includes a main category label corresponding to the sample text and a subcategory label subordinate to the main category label; A main category recognition module is used to perform category recognition on the sample text through the main category recognition network in the text category recognition model to obtain a main category prediction result corresponding to the sample text; A subcategory identification module is configured to perform category identification on the sample text based on the main category prediction result using the subcategory identification network in the text category identification model to obtain a subcategory prediction result corresponding to the sample text, including: converting the semantic encoding vector corresponding to the sample text into a prediction probability corresponding to a predetermined subcategory using the normalization layer of the subcategory identification network; adjusting the prediction probability corresponding to a predetermined subcategory belonging to the corresponding predetermined main category based on the prediction probability corresponding to each predetermined main category in the main category prediction result using the information correction layer of the subcategory identification network, and using the adjusted prediction probability of the corresponding predetermined subcategory as the subcategory prediction result; A loss construction module, configured to construct a target loss based on the main category tag corresponding to the sample text and the main category prediction result, and the subcategory tag corresponding to the sample text and the subcategory prediction result; A training module is used to update the model parameters of the text category recognition model according to the target loss, and then return to the step of obtaining the sample text and the label data corresponding to the sample text to continue training until the training is completed, thereby obtaining a text category recognition model for identifying text categories.

14. The processing device for a text category recognition model according to claim 13, characterized in that: The main category identification module is further configured to perform semantic encoding on the sample text through the semantic encoding layer of the main category identification network to obtain a semantic encoding vector; The semantic encoding vector is converted into a prediction probability corresponding to a predetermined main category through a normalization layer of the main category recognition network as the main category prediction result.

15. The processing device for a text category recognition model according to claim 13, characterized in that: The subcategory identification module is further used to determine the subcategory semantic vector corresponding to the sample text based on the main category prediction result and the semantic encoding vector corresponding to the sample text through the information fusion layer of the subcategory identification network; and convert the subcategory semantic vector into a prediction probability corresponding to a predetermined subcategory as the subcategory prediction result through the normalization layer of the subcategory identification network.

16. The processing device for a text category recognition model according to claim 15, characterized in that: The subcategory identification module is further configured to determine candidate main categories based on the main category prediction result; and to fuse the semantic representation vectors corresponding to the candidate main categories to obtain a main category semantic vector. After concatenating the main category semantic vector and the semantic encoding vector corresponding to the sample text, a subcategory semantic vector corresponding to the sample text is obtained.

17. The processing device for a text category recognition model according to claim 16, characterized in that: The subcategory identification module is further configured to determine a semantic representation vector corresponding to each candidate main category; Determining the prediction probability corresponding to each candidate main category according to the main category prediction result; According to the prediction probability corresponding to each candidate main category, the semantic representation vectors corresponding to each candidate main category are weighted and summed to obtain the main category semantic vector.

18. The processing device for a text category recognition model according to claim 13, characterized in that: The loss construction module is further configured to construct a main category classification loss based on the main category label corresponding to the sample text and the main category prediction result, and to construct a subcategory classification loss based on the subcategory label corresponding to the sample text and the subcategory prediction result; After fusing the main category classification loss with the subcategory classification loss, the target loss is obtained.

19. The processing device for a text category recognition model according to claim 13, characterized in that: The loss construction module is further configured to construct a main category classification loss based on the main category label corresponding to the sample text and the main category prediction result, and to construct a subcategory classification loss based on the subcategory label corresponding to the sample text and the subcategory prediction result; From the main category prediction result, the prediction probability corresponding to the main category tag is extracted, and from the sub-category prediction result, the prediction probability corresponding to the sub-category tag is extracted, and the hinge loss is constructed according to the prediction probability corresponding to the main category tag and the prediction probability corresponding to the sub-category tag; after fusing the main category classification loss, the sub-category classification loss and the hinge loss, the target loss is obtained, and the hinge loss is used to ensure that the prediction probability belonging to each predetermined sub-category in the main category prediction result output by the updated text category recognition model is less than the prediction probability corresponding to the predetermined main category to which it belongs.

20. The processing device for a text category recognition model according to claim 13, characterized in that: The subcategory tag subordinate to the main category tag includes a first subcategory tag subordinate to the main category tag and a second subcategory tag subordinate to the first subcategory tag; The subcategory identification module is further configured to perform category identification on the sample text based on the main category prediction result through a first subcategory identification network connected to the main category identification network in the text category identification model, to obtain a first subcategory prediction result corresponding to the sample text; performing category recognition on the sample text based on the first subcategory prediction result using a second subcategory recognition network in the text category recognition model that is connected to the first subcategory recognition network, to obtain a second subcategory prediction result corresponding to the sample text; The loss construction module is further used to construct the target loss based on the main category tag corresponding to the sample text and the main category prediction result, the first subcategory tag corresponding to the sample text and the first subcategory prediction result, and the second subcategory tag corresponding to the sample text and the second subcategory prediction result.

21. The processing device for a text category recognition model according to any one of claims 13 to 20, characterized in that: The device further includes an input module and a determination module, and the acquisition module is further used to acquire the text to be recognized; The input module is used to input the text to be recognized into a trained text category recognition model; The main category recognition module is further configured to perform category recognition on the text to be recognized using the main category recognition network in the trained text category recognition model to obtain a main category prediction result corresponding to the text to be recognized; The subcategory recognition module is further configured to perform category recognition on the text to be recognized based on the main category prediction result through the subcategory recognition network in the trained text category recognition model, and obtain a subcategory prediction result corresponding to the text to be recognized; The determination module is used to determine the main category and / or subcategory corresponding to the text to be recognized according to the subcategory prediction result.

22. A text category recognition device, characterized in that: The device comprises: An acquisition module is used to obtain the text to be recognized; a main category recognition module, configured to perform category recognition on the text to be recognized using a main category recognition network in a trained text category recognition model, and obtain a main category prediction result corresponding to the text to be recognized; the text category recognition model is obtained by the processing device of the text category recognition model according to any one of claims 13 to 21; A subcategory recognition module, configured to perform category recognition on the text to be recognized based on the main category prediction result using the subcategory recognition network in the trained text category recognition model, and obtain a subcategory prediction result corresponding to the text to be recognized; A determination module is configured to determine a target category corresponding to the to-be-recognized text according to the subcategory prediction result, wherein the target category includes at least one of a main category and a subcategory.

23. The text category recognition device according to claim 22, characterized in that: The acquisition module is further configured to acquire an uploaded target video; extract the video title text corresponding to the target video as the text to be recognized; The device further includes a generation module, which is configured to generate video semantic features corresponding to the target video according to the target category corresponding to the video title text.

24. The text category recognition device according to claim 22, characterized in that: The acquisition module is further configured to acquire an object search request; extract an input text for searching a target object from the object search request as the text to be recognized; The device also includes a search module and a return module; The search module is used to search for a target object that matches the target category according to the target category corresponding to the input text; The returning module is configured to return the target object in response to the object search request.

25. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 12 is implemented.

26. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.

27. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • Content classification method and device, computer equipment and storage medium

    CN110737801A

  • System of text classification model and training method thereof

    CN111309919A

  • Classification processing and data searching method and device, electronic equipment and intelligent loudspeaker box

    CN112241490A