Classification method, device, computer equipment and storage medium
By obtaining the similarity matching between class semantic features and text semantic features, the problem of insufficient classification accuracy of text information in the prior art is solved, and a more accurate and rich classification method is achieved.
Patent Information
- Application Number
- CN202111136661.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-27
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2041-09-27
AI Technical Summary
The accuracy of text information classification in the prior art is poor.
By obtaining the class semantic features of multiple categories, extracting the text semantic features of the text information to be classified, and calculating the similarity between the two, and determining the category to which the text information belongs based on the similarity.
The accuracy of text information classification is improved, especially in multi-grained classification, ensuring the accuracy and richness of classification.
Smart Images

Figure CN114281936B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a classification method, apparatus, computer equipment, and storage medium. Background Art
[0002] With the development of computer technology, the amount of text information on the internet is increasing, making it crucial to classify this information. Related technologies typically train a classification model based on sample text and its corresponding category labels. Subsequently, any text message can be directly classified based on this classification model to determine its category. However, this classification method suffers from limited accuracy. Summary of the Invention
[0003] The embodiments of the present application provide a classification method, apparatus, computer device, and storage medium that can improve classification accuracy. The technical solution is as follows:
[0004] In one aspect, a classification method is provided, comprising:
[0005] Acquire multiple first category semantic features, where the first category semantic features are obtained by semantically extracting category information of the first category;
[0006] Performing semantic extraction on the text information to be classified to obtain text semantic features of the text information, and respectively obtaining similarities between the text semantic features and the semantic features of each category;
[0007] Based on the similarities corresponding to the plurality of first categories, a first target category to which the text information belongs is determined from the plurality of first categories.
[0008] In another aspect, a classification device is provided, comprising:
[0009] an acquisition module, configured to acquire a plurality of first category semantic features, wherein the first category semantic features are obtained by semantically extracting category information of the first category;
[0010] The acquisition module is further configured to perform semantic extraction on the text information to be classified, obtain text semantic features of the text information, and respectively obtain similarities between the text semantic features and the semantic features of each category;
[0011] The determination module is configured to determine, from a plurality of first categories, a first target category to which the text information belongs based on similarities corresponding to the plurality of first categories.
[0012] In a possible implementation, each of the first categories is a subcategory of a second category, and at least two of the first categories belong to different second categories; the apparatus further includes:
[0013] a classification module, configured to classify the text semantic features based on the plurality of second categories to obtain category labels corresponding to the plurality of second categories, wherein the category labels corresponding to the second categories indicate a possibility that the text information belongs to the second category;
[0014] The determination module is further configured to determine, from among a plurality of second categories, a second target category to which the text information belongs based on category labels corresponding to the plurality of second categories.
[0015] In another possible implementation, each of the first categories is a subcategory of a second category, and the determination module is further configured to determine the second category to which the first target category belongs as the second target category to which the text information belongs.
[0016] In another possible implementation, the acquisition module is used to obtain category semantic features of multiple first categories based on a classification model; perform semantic extraction on the text information based on the classification model to obtain the text semantic features, and respectively obtain the similarity between the text semantic features and each category semantic feature.
[0017] In another possible implementation, the classification model includes a first classification sub-model and a second classification sub-model; and the acquisition module includes:
[0018] an acquiring unit, configured to acquire, based on the first classification sub-model, category semantic features of a plurality of the first categories;
[0019] an extraction unit, configured to perform semantic extraction on the text information based on the second classification sub-model to obtain the text semantic features;
[0020] The acquisition unit is further configured to respectively acquire the similarity between the text semantic feature and each category semantic feature based on the first classification sub-model.
[0021] In another possible implementation, each of the first categories is a subcategory of a second category, and at least two of the first categories belong to different second categories; and the apparatus further includes:
[0022] a classification module, configured to classify the text semantic features based on the second classification sub-model to obtain a plurality of category labels corresponding to the second categories, wherein the category labels corresponding to the second categories indicate a possibility that the text information belongs to the second category;
[0023] The determination module is configured to determine, from a plurality of second categories, the second target category to which the text information belongs based on category labels corresponding to the plurality of second categories.
[0024] In another possible implementation, the apparatus further includes:
[0025] The acquisition module is further configured to acquire sample text information and a corresponding first sample label, where the first sample label indicates a first category to which the sample text information belongs;
[0026] The acquisition module is further configured to acquire a plurality of semantic features of sample categories of the first category based on the classification model;
[0027] an extraction module, configured to perform semantic extraction on the sample text information based on the classification model, obtain sample text semantic features of the sample text information, and respectively obtain predicted similarities between the sample text semantic features and the semantic features of each sample category;
[0028] A training module is used to train the classification model based on the first sample label and the predicted similarities corresponding to multiple first categories.
[0029] In another possible implementation, each of the first categories is a subcategory of a second category, and at least two of the first categories belong to different second categories. The acquisition module is further configured to acquire a second sample label corresponding to the sample text information, where the second sample label indicates the second category to which the sample text information belongs.
[0030] The training module includes:
[0031] a classification unit, configured to classify the semantic features of the sample text based on the classification model to obtain a plurality of predicted category labels corresponding to the second category, wherein the predicted category labels corresponding to the second category indicate a probability that the sample text information is predicted to belong to the second category;
[0032] A training unit is used to train the classification model based on the first sample label, the predicted similarities corresponding to multiple first categories, the second sample label and the predicted category labels corresponding to multiple second categories.
[0033] In another possible implementation, the training unit is used to determine a first loss value based on the first sample label and the predicted similarities corresponding to multiple first categories; determine a second loss value based on the second sample label and the predicted category labels corresponding to multiple second categories; perform weighted fusion on the first loss value and the second loss value to obtain a first loss sum value; and train the classification model based on the first loss sum value.
[0034] In another possible implementation, the training unit is used to determine the target prediction similarity corresponding to the first category to which the sample text information belongs based on the first sample label and the prediction similarities corresponding to multiple first categories; determine the target prediction category label corresponding to the second category to which the sample text information belongs based on the second sample label and the prediction category labels corresponding to multiple second categories; and train the classification model based on the first sample label, the prediction similarities corresponding to multiple first categories, the second sample label, the prediction category labels corresponding to multiple second categories, the target prediction similarity and the target prediction category label.
[0035] In another possible implementation, the training unit is used to determine a first loss value based on the first sample label and the prediction similarities corresponding to multiple first categories; determine a second loss value based on the second sample label and the prediction category labels corresponding to multiple second categories; determine a third loss value based on the target prediction similarity and the target prediction category label; perform weighted fusion on the first loss value, the second loss value and the third loss value to obtain a second loss sum value; and train the classification model based on the second loss sum value.
[0036] In another possible implementation, the text information is used to describe a multimedia resource, and the determination module is further configured to determine the first target category to which the text information belongs as the category to which the multimedia resource belongs.
[0037] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the operations performed by the classification method described in the above aspects.
[0038] On the other hand, a computer-readable storage medium is provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor to implement the operations performed by the classification method described in the above aspects.
[0039] On the other hand, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the operations performed by the classification method as described in the above aspects are implemented.
[0040] The beneficial effects of the technical solutions provided in the embodiments of the present application include at least:
[0041] The method, apparatus, computer device, and storage medium provided in the embodiments of the present application introduce category information for representing categories when classifying text information, characterize each category with the category semantic features of each category information, perform similarity matching between the category semantic features of each category and the text semantic features of the text information, and determine the category to which the text information belongs based on the obtained similarity. That is, in the process of classifying text information, the category information used for classification is enriched, and classification is performed in a similarity matching manner, thereby improving classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0043] Figure 1 This is a schematic diagram of the structure of an implementation environment provided by an embodiment of the present application;
[0044] Figure 2 This is a flow chart of a classification method provided in an embodiment of the present application;
[0045] Figure 3 This is a flow chart of a classification method provided in an embodiment of the present application;
[0046] Figure 4 This is a flowchart of obtaining text semantic features of text information provided by an embodiment of the present application;
[0047] Figure 5 This is a flow chart of a classification method provided in an embodiment of the present application;
[0048] Figure 6 This is a structural diagram of a classification model provided in an embodiment of the present application;
[0049] Figure 7 This is a flow chart of a classification method provided in an embodiment of the present application;
[0050] Figure 8 This is a structural diagram of a classification device provided in an embodiment of the present application;
[0051] Figure 9 This is a structural diagram of a classification device provided in an embodiment of the present application;
[0052] Figure 10 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application;
[0053] Figure 11 This is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0055] As used herein, the terms "first," "second," "third," and the like may be used to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are used solely to distinguish one concept from another. For example, a first category may be referred to as a second category, and similarly, a second category may be referred to as a first category without departing from the scope of this application.
[0056] As used herein, the terms "at least one," "a plurality," "each," and "any" include one, two, or more, "a plurality" include two or more, "each" refers to each of the corresponding plurality, and "any" refers to any one of the plurality. For example, a plurality of first categories includes three first categories, and "each" refers to each of the three first categories. "Any" refers to any one of the three first categories, which may be the first first category, the second first category, or the third first category.
[0057] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0058] 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.
[0059] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0060] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.
[0061] The solution provided in the embodiment of the present application is based on natural language processing and machine learning using artificial intelligence, and can train a classification model, and use the trained classification model to achieve the classification of text information.
[0062] In some embodiments, the computer program involved in the embodiments of the present application can be deployed and executed on a computer device, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected through a communication network. Multiple computer devices distributed at multiple locations and interconnected through a communication network can constitute a blockchain system.
[0063] The classification method provided in the embodiment of the present application can be executed by a computer device. Optionally, the computer device is a terminal or a server. Optionally, the server is an independent physical server, or a server cluster or distributed system composed 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 (Content Delivery Network), and big data and artificial intelligence platforms. Optionally, the terminal is a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, smart voice interaction device, smart home appliance and car terminal, etc., but is not limited to this.
[0064] In one possible implementation, the computer device is provided as a server. Figure 1 This is a schematic diagram of an implementation environment provided by an embodiment of the present application. Figure 1 , the implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a wireless or wired network.
[0065] In a possible implementation, the server 102 provides a text information sharing service. The server 102 is used to classify text information and manage the text information according to the categories to which the text information belongs.
[0066] Terminal 101 interacts with server 102 and sends an information viewing request to server 102. Server 102 sends multiple text messages and the category to which each text message belongs to terminal 101. Terminal 101 receives the multiple text messages and the category to which each text message belongs, and displays the multiple text messages according to the categories to which they belong.
[0067] In one possible implementation, a target application provided by server 102 is installed on terminal 101. Terminal 101 can use this target application to implement functions such as data transmission and message exchange. Optionally, the target application is a target application in the operating system of terminal 101, or a target application provided by a third party. For example, the target application is a video sharing application that has a video sharing function. Of course, the video sharing application can also have other functions, such as review functions, shopping functions, navigation functions, game functions, etc.
[0068] The server 102 is configured to classify the text information of the multimedia resources in the target application, determine the category to which each piece of text information belongs, determine the category to which each piece of text information belongs as the category to which the corresponding multimedia resource belongs, and classify and manage the multimedia resources based on the category to which the multimedia resources belong. The terminal 101 is configured to log in to the target application based on a user identifier, send a resource acquisition request to the server 102 through the target application, receive the resource acquisition request, and based on the resource acquisition request, send multiple multimedia resources and the category to which each multimedia resource belongs to the terminal 101. The terminal 101 receives the multiple multimedia resources and the category to which each multimedia resource belongs, and classifies and displays the multiple multimedia resources based on the target application and the categories to which the multiple multimedia resources belong.
[0069] Figure 2 This is a flow chart of a classification method provided by an embodiment of the present application, which is executed by a computer device, such as Figure 2 As shown, the method includes:
[0070] 201. A computer device obtains a plurality of first category semantic features, where the category semantic features are obtained by semantically extracting category information of the first category.
[0071] The category information of each first category is used to describe the corresponding first category. For example, the category information is the category name of the first category, or is a brief introduction to the first category. The category semantic features of each first category are used to characterize the corresponding category information. The category information of each first category is used to describe the corresponding first category, and each category semantic feature can characterize the corresponding first category.
[0072] 202. The computer device performs semantic extraction on the text information to be classified to obtain text semantic features of the text information, and respectively obtains similarities between the text semantic features and the semantic features of each category.
[0073] The text information is any text information to be classified. For example, the text information is information describing a multimedia resource, such as a video. For example, the text information may include the title or description of the video. Another example is the content of a news article. Text semantic features are used to characterize the text information, and these text semantic features can indicate the meaning expressed by the text information.
[0074] The similarity between a text semantic feature and each category semantic feature indicates the degree of similarity between the text semantic feature and each category semantic feature, and can also indicate the likelihood that the text information belongs to the first category corresponding to each category semantic feature. For any category semantic feature, the greater the similarity between the text semantic feature and the category semantic feature, the greater the likelihood that the text information belongs to the first category corresponding to the category semantic feature; the smaller the similarity between the text semantic feature and the category semantic feature, the smaller the likelihood that the text information belongs to the first category corresponding to the category semantic feature.
[0075] 203. The computer device determines, from the multiple first categories, a first target category to which the text information belongs based on similarities corresponding to the multiple first categories.
[0076] The first target category is a category included in the plurality of first categories. Based on the similarities corresponding to the plurality of first categories, the first target category to which the text information belongs is selected from the plurality of first categories, where the similarity corresponding to the first target category is greater than the similarities corresponding to other first categories in the plurality of first categories except the first target category.
[0077] The method provided in the embodiment of the present application introduces category information for representing categories when classifying text information, represents each category with the category semantic features of each category information, performs similarity matching between the category semantic features of each category and the text semantic features of the text information, and determines the category to which the text information belongs based on the obtained similarity. That is, in the process of classifying text information, the category information used for classification is enriched, and classification is performed in a similarity matching manner, thereby improving classification accuracy.
[0078] exist Figure 2 On the basis of the illustrated embodiment, categories belonging to different granularity levels are divided, and each first category belongs to a subcategory of the second category. When classifying text information, it is also possible to determine the category to which the text information belongs at different granularity levels. The classification process is detailed in the following embodiment.
[0079] Figure 3 This is a flow chart of a classification method provided in an embodiment of the present application, which is executed by a computer device, such as Figure 3 As shown, the method includes:
[0080] 301. A computer device obtains a plurality of first category semantic features, where the category semantic features are obtained by semantically extracting category information of the first category.
[0081] In an embodiment of the present application, each first category corresponds to category information, and the category information is used to describe the corresponding first category, and the category information of different first categories is different. Semantic extraction is performed on the information of each first category to obtain the category semantic features of each first category, that is, the category semantic features of different first categories are different. The category semantic features can be represented in any form, for example, the category semantic features are represented in the form of a feature vector, and the vector dimension of the category semantic features of each first category is d, and the value of the vector dimension d is 200-500.
[0082] In one possible implementation, the category semantic features of multiple first categories are obtained based on the category information of multiple first categories when classifying text information. Then, step 301 includes: the computer device obtains the category information of multiple first categories, performs semantic extraction on the category information of each first category respectively, and obtains the category semantic features of each first category.
[0083] In an embodiment of the present application, each time text information is classified, the computer device obtains category information of multiple first categories and then obtains category semantic features of each first category, so as to subsequently classify the text information based on the multiple category semantic features.
[0084] In one possible implementation, the multiple first category category semantic features are obtained based on multiple first category category information before classifying the text information, and step 301 includes: the computer device obtains multiple first category category semantic features from a feature library.
[0085] In an embodiment of the present application, a feature library is used to store the category semantic features of the first category. Before classifying text information, based on multiple types of category information of the first category, the category semantic features of each first category are obtained and stored in the feature library. This allows the multiple category semantic features to be directly obtained from the feature library when classifying any text information subsequently, without having to perform semantic extraction on the multiple types of category information of the first category each time.
[0086] 302. The computer device performs semantic extraction on the text information to be classified to obtain text semantic features of the text information.
[0087] The text semantic feature can be represented in any form. For example, the text semantic feature can be represented in the form of a feature vector, such as an m-dimensional feature vector.
[0088] In one possible implementation, the text semantic features of the text information are obtained by word segmentation processing, that is, step 302 includes: a computer device performs word segmentation on the text information to obtain multiple words contained in the text information, performs semantic extraction on the multiple words to obtain word features of each word, and updates the word features of each word based on the word features of the multiple words, and the updated word features of the multiple words constitute the text semantic features of the text information.
[0089] In an embodiment of the present application, word segmentation processing is used to obtain the word features of each word, and based on the word features of multiple words, the word features of each word are updated to enhance the association between the word features of multiple words, thereby ensuring the accuracy of the text semantic features composed of the updated word features of multiple words.
[0090] In one possible implementation, the text semantic features of the text information are obtained by extracting features character by character, that is, step 302 includes: the computer device performs semantic extraction on each character according to the arrangement order of multiple characters contained in the text information to obtain the character features of each character, and updates each character feature based on the character features of the multiple characters, and the updated character features of each character constitute the text semantic features of the text information.
[0091] In the embodiment of the present application, a character-by-character feature extraction method is adopted to obtain the character features of each character, and based on the character features of multiple characters, the character features of each character are updated to enhance the association between the character features of multiple characters, thereby ensuring the accuracy of the text semantic features composed of the updated character features of multiple characters. The text semantic features of text information are obtained by extracting features character by character, such as Figure 4 As shown, the text information 401 includes a starting character, a text character and an ending character, wherein the starting character indicates the starting position of the text information, and the ending character includes the ending position of the text information. The character features of each character are first obtained, and then, based on the character features of multiple characters, the character features of each character are updated so that the character features of each character after the update incorporate the character features of other characters. Then, the updated character features of multiple characters constitute the text semantic features 402 of the text information 401.
[0092] 303. The computer device obtains the similarity between the text semantic feature and the semantic feature of each category.
[0093] In an embodiment of the present application, after obtaining the text semantic features of the text information and the category semantic features of each first category, the similarity between the text semantic features and each category semantic feature can be obtained respectively based on the text semantic features and each category semantic feature.
[0094] In one possible implementation, both the text semantic feature and the category semantic feature are represented in the form of feature vectors. The text semantic feature is the text semantic feature vector, and the category semantic feature is the category semantic feature vector. Then, step 303 includes the following two methods:
[0095] The first method: the computer device obtains the product of the text semantic feature vector and the semantic feature vector of each category respectively, and determines the products corresponding to the multiple category semantic feature vectors as the similarity between the text semantic feature vector and the semantic feature vector of each category.
[0096] Among them, for any category semantic feature vector, the scalar product of the text semantic feature vector and the category semantic feature vector is determined as the similarity between the text semantic feature vector and the category semantic feature vector. According to the above method, the scalar product of the text semantic feature vector and each category semantic feature vector is obtained to obtain the similarity between the text semantic feature vector and each category semantic feature vector.
[0097] The second method: multiple categories of semantic feature vectors are used to form a feature matrix, and the first product of the text semantic feature vector and the feature matrix, as well as the modulus of the text semantic feature vector and the modulus of the feature matrix, are determined. The second product of the modulus of the text semantic feature vector and the modulus of the feature matrix is determined, and the ratio between the first product and the second product is determined. The numerical value of each dimension in the ratio is determined as the similarity corresponding to the corresponding category semantic feature vector.
[0098] Among them, the ratio includes numerical values of multiple dimensions, and the ratio can be expressed in the form of a vector. The number of the multiple dimensions is the same as the number of the multiple categories of semantic feature vectors, that is, the number of the multiple dimensions is the number of the multiple first categories. After the multiple categories of semantic feature vectors are formed into a feature matrix, according to the positions of the multiple categories of semantic feature vectors in the feature matrix, the numerical value of each dimension in the ratio is determined as the similarity between the corresponding category semantic feature vector and the text semantic feature vector, and the similarity between each category semantic feature vector and the text semantic feature vector can be obtained.
[0099] Optionally, the text semantic feature vector, the feature matrix, and the ratio between the first product and the second product satisfy the following relationship:
[0100]
[0101] Among them, L1emb is used to represent the text semantic feature vector, f 12-cls-emb Used to represent the feature matrix, ||L1emb|| is used to represent the modulus of the text semantic feature vector, ||f12clsemb|| is used to represent the modulus of the feature matrix, L1emb*f 12-cls-emb is used to represent the first product, ||L1emb||*||f12clsemb|| is used to represent the second product, and Logits is used to represent the ratio between the first product and the second product.
[0102] 304. The computer device determines, from the multiple first categories, a first target category to which the text information belongs based on similarities corresponding to the multiple first categories.
[0103] After determining the similarities corresponding to the multiple first categories, the likelihood that the text message belongs to each first category is determined. Based on the similarities corresponding to the multiple first categories, a first target category to which the text message belongs can be selected from the multiple first categories, where the similarity corresponding to the first target category is greater than the similarities corresponding to the other first categories in the multiple first categories except the first target category.
[0104] In a possible implementation, step 304 includes: based on similarities corresponding to the multiple first categories, selecting at least one first category with the greatest similarity from the multiple first categories, and determining the first target category to which the text information belongs.
[0105] Since the greater the similarity corresponding to any first category, the greater the possibility that the text information belongs to the first category, the at least one first category with the greatest similarity among multiple first categories has a greater possibility that the text information belongs to the at least one first category. Therefore, the at least one first category is determined as the first target category to which the text information belongs.
[0106] 305. The computer device classifies the text semantic features based on the multiple second categories to obtain category labels corresponding to the multiple second categories.
[0107] In an embodiment of the present application, each first category is a subcategory of a second category, and the second categories to which at least two first categories belong are different, that is, the second categories to which the multiple first categories belong include multiple categories. The first category and the second category have different granularity levels, the second category is a coarse-grained category, and the first category is a fine-grained category. For example, any second category is a game, and the multiple first categories belonging to the second category include mini-games, terminal games, mobile games, etc. For another example, any second category is a dance, and the multiple first categories belonging to the second category include square dance, social dance, street dance, etc. The category label corresponding to any second category indicates the possibility that the text information belongs to the second category. The category label can be expressed in any form. For example, the category label is expressed in the form of a numerical value, and the numerical value is equivalent to the probability that the text information belongs to the second category.
[0108] Since the text semantic feature can represent the text information and reflect the meaning expressed by the text information, the text semantic feature is classified based on the multiple second categories to determine the possibility that the text semantic feature belongs to each second category, that is, to obtain the category labels corresponding to the multiple second categories.
[0109] In a possible implementation, step 305 includes: the computer device performs feature transformation on the text semantic feature based on multiple second categories to obtain category label features.
[0110] The category label feature includes category labels of multiple dimensions, each dimension corresponding to a second category, and the number of the multiple dimensions is equal to the number of the multiple second categories. Based on the category labels of the multiple dimensions included in the category label vector, the category label corresponding to each second category can be determined.
[0111] For example, the text semantic feature is represented in the form of a vector, which is also a text semantic feature vector. The category label feature is also represented in the form of a vector, which is also a category label feature vector. The category label feature vector is obtained by performing feature transformation on the text semantic feature vector. The value of each dimension in the category label feature vector is a category label corresponding to a second category.
[0112] 306. The computer device determines, from the plurality of second categories, a second target category to which the text information belongs based on category labels corresponding to the plurality of second categories.
[0113] The second target category is a category included in the multiple second categories. After determining the category labels corresponding to the multiple second categories, the likelihood that the text information belongs to each second category can be determined. Based on the category labels corresponding to the multiple second categories, the second target category to which the text information belongs is determined from the multiple second categories, the likelihood that the text information belongs to the second target category, and the likelihood that the text information belongs to other second categories within the multiple second categories other than the second target category are determined.
[0114] In a possible implementation, step 306 includes: based on category labels corresponding to the multiple second categories, selecting at least one second category with the greatest probability from the multiple second categories, and determining the second target category to which the text information belongs.
[0115] Since the greater the probability indicated by the category label corresponding to any second category, the greater the possibility that the text information belongs to the second category, at least one second category with the greatest probability among the multiple second categories is determined as the second target category to which the text information belongs.
[0116] In one possible implementation, the first target category is a subcategory of the second target category.
[0117] For example, the text information is a video title of a video, and the first target category and the second target category to which the text information belongs are shown in Table 1.
[0118] Table 1
[0119] Video title Second target category First target category Video Title 1 game Mini Games Video Title 2 dance Square Dance Video Title 3 game Mobile Games Video Title 4 science and technology cell phone
[0120] It should be noted that the embodiment of the present application is only illustrated by taking the example of first executing steps 303-304 and then executing steps 305-306. In another embodiment, after step 302, steps 305-306 can be executed first and then steps 303-304, or, when executing steps 303-304, steps 305-306 can be executed synchronously. This application does not limit the order of executing the steps.
[0121] It should be noted that the embodiment of the present application determines the second target category to which the text information belongs by classifying the text semantic features of the text information. In another embodiment, there is no need to perform steps 305-306, and other methods can be used to determine the second target category to which the text information belongs.
[0122] In a possible implementation, the process of determining the second target category to which the text information belongs includes: determining the second category to which the first target category belongs as the second target category to which the text information belongs.
[0123] In an embodiment of the present application, each first category is a subcategory of a second category. If the text information belongs to the first target category, then the second category to which the first target category belongs is also the category to which the text information belongs. Therefore, the second category to which the first target category belongs is determined as the second target category to which the text information belongs.
[0124] Optionally, the process of determining the second category to which the first target category belongs includes: based on the first target category, querying the subordinate relationship between the first category and the second category, and determining the second category to which the first target category belongs.
[0125] The subordinate relationship between the first category and the second category includes multiple first categories and the second category to which each first category belongs. The first target category is a first category. Based on the first target category, the subordinate relationship can be queried to determine the second category to which the first target category belongs.
[0126] It should be noted that the text information in the embodiment of the present application is any text information to be classified. In one possible implementation, the text information is used to describe multimedia resources, that is, the text information is the text information of the multimedia resources. Then, after step 306, the method further includes: determining the first target category and the second target category to which the text information belongs as the category to which the multimedia resource belongs.
[0127] The embodiment of the present application classifies the text information of multimedia resources to determine the category of the multimedia resources, thereby realizing a method of classifying multimedia resources. Since the text information can represent the content contained in the multimedia resources, classifying the multimedia resources based on the text information also ensures the accuracy of the classification.
[0128] The method provided in the embodiment of the present application introduces category information for representing categories when classifying text information, represents each category with the category semantic features of each category information, performs similarity matching between the category semantic features of each category and the text semantic features of the text information, and determines the category to which the text information belongs based on the obtained similarity. That is, in the process of classifying text information, the category information used for classification is enriched, and classification is performed in a similarity matching manner, thereby improving classification accuracy.
[0129] In addition, categories belonging to different granularity levels are divided. By determining the categories to which text information belongs at multiple granularity levels, the categories to which text information belongs are enriched, thereby ensuring the accuracy of classification.
[0130] exist Figure 2 On the basis of the illustrated embodiment, categories belonging to different granularity levels are divided, and each first category belongs to a subcategory of the second category. The category to which the text information belongs at different granularity levels can also be determined based on the classification model. The classification process is detailed in the following embodiment.
[0131] Figure 5 This is a flow chart of a classification method provided in an embodiment of the present application, which is executed by a computer device, such as Figure 5 As shown, the method includes:
[0132] 501. The computer device performs semantic extraction on the text information based on the second classification sub-model in the classification model to obtain text semantic features.
[0133] In an embodiment of the present application, a classification model is used to classify text information. The classification model corresponds to multiple first categories and multiple second categories, each first category is a subcategory of a second category, and at least two first categories belong to different second categories. The classification model includes a first classification sub-model and a second classification sub-model. The first classification sub-model is used to classify text information into the first category, and the second classification sub-model is used to classify text information into the second category.
[0134] In one possible implementation, the first classification sub-model includes a first encoding layer and a first normalization layer, and the second classification sub-model includes a second encoding layer and a second normalization layer.
[0135] Among them, the first encoding layer and the second encoding layer can both be arbitrary encoders, for example, the first encoder is CNN (Convolutional Neural Networks), LSTM (Long Short Term Memory), LSTM Attention (Long Short Term Memory Attention, long short-term memory network with attention mechanism), etc., and the second encoder is BERT (Bidirectional Encoder Representations from Transformers). The first normalization layer and the second normalization layer are used to transform features. The first normalization layer and the second normalization layer can be arbitrary networks. For example, the first normalization layer and the second normalization layer are both Softmax (logistic regression).
[0136] In one possible implementation, step 501 includes: performing semantic extraction on the text information based on the second encoding layer in the second classification sub-model to obtain the semantic features of the text.
[0137] Optionally, the text information and the text semantic features satisfy the following relationship:
[0138] embed=Bert(text)
[0139] Among them, embed is used to represent text semantic features, Bert(·) is used to represent the second encoding layer, and text is used to represent text information.
[0140] The step 501 is similar to the above step 302 and will not be described again here.
[0141] 502. The computer device classifies the text semantic features based on the second classification sub-model to obtain category labels corresponding to multiple second categories. The category labels corresponding to the second categories indicate the possibility that the text information belongs to the second category.
[0142] In one possible implementation, the second classification sub-model includes a second normalization layer, and step 502 includes: classifying the text semantic features based on the second normalization layer in the second classification sub-model to obtain category labels corresponding to multiple second categories.
[0143] Optionally, the category labels corresponding to the multiple second categories constitute a category label vector, and the category label vector and the text semantic features satisfy the following relationship:
[0144] Logits1=Classify1(embed)
[0145] Among them, Logits1 is used to represent the category label vector, Classify1(·) is used to represent the second normalization layer, and embed is used to represent the text semantic features.
[0146] The step 502 is similar to the above step 305 and will not be described again here.
[0147] 503. The computer device determines, from the plurality of second categories, a second target category to which the text information belongs based on category labels corresponding to the plurality of second categories.
[0148] In one possible implementation, step 503 includes: the computer device determines, from the plurality of second categories, the second target category to which the text information belongs based on the second classification sub-model and category labels corresponding to the plurality of second categories.
[0149] It should be noted that in the embodiment of the present application, after obtaining the category labels corresponding to the multiple second categories based on the second classification sub-model, the second target category to which the text information belongs can also be determined from the multiple second categories based on the second classification sub-model. In another embodiment, the second classification sub-model is not required, and other methods can be adopted to determine the second target category to which the text information belongs from the multiple second categories based on the category labels corresponding to the multiple second categories. This application is not limited to this.
[0150] The step 503 is similar to the above step 306 and will not be described again here.
[0151] 504. The computer device obtains multiple first category semantic features based on the first classification sub-model in the classification model.
[0152] In one possible implementation, step 504 includes: the computer device obtains category information of multiple first categories, and based on the first classification sub-model, performs semantic extraction on the category information of each first category to obtain category semantic features of each first category.
[0153] In a possible implementation, the first classification sub-model includes multiple category semantic features of the first category.
[0154] The step 504 is similar to the above step 301 and will not be described again here.
[0155] 505. The computer device obtains the similarity between the text semantic feature and the semantic feature of each category based on the first classification sub-model.
[0156] The text semantic features are extracted based on the second classification sub-model. In an embodiment of the present application, after obtaining the text semantic features of the text information based on the second classification sub-model, the text semantic features are classified based on the second classification sub-model, and the text features can also be transferred to the first classification sub-model, and the similarity between the text semantic features and the semantic features of each category is obtained based on the first classification sub-model.
[0157] The step 505 is similar to the above step 303 and will not be described again here.
[0158] 506. The computer device determines, from the multiple first categories, a first target category to which the text information belongs based on the similarities corresponding to the multiple first categories.
[0159] In one possible implementation, step 506 includes: the computer device determines, from the multiple first categories, a first target category to which the text information belongs based on the first classification sub-model and similarities corresponding to the multiple first categories.
[0160] It should be noted that in the embodiment of the present application, after obtaining the similarities corresponding to multiple first categories based on the first classification sub-model, the first target category to which the text information belongs can also be determined from the multiple first categories based on the first classification sub-model. In another embodiment, the first classification sub-model is not required, and other methods can be adopted to determine the first target category to which the text information belongs from the multiple first categories based on the similarities corresponding to the multiple first categories. This application is not limited to this.
[0161] The step 506 is similar to the above step 304 and will not be described again here.
[0162] It should be noted that the embodiment of the present application is described by taking the example of first executing steps 501-503 and then executing steps 504-505. In another embodiment, step 504 can be executed first, then step 501, and then step 505 and steps 502-503. This application does not limit the order of executing the steps.
[0163] It should be noted that the embodiment of the present application is described by taking the classification model including the first classification sub-model and the second classification sub-model as an example. In another embodiment, there is no need to distinguish between the first classification sub-model and the second classification sub-model. The classification model can replace the above-mentioned first classification sub-model and the second classification sub-model, and directly based on the classification model, the first target category and the second target category to which the text information belongs can be obtained according to the above-mentioned steps 501-505.
[0164] It should be noted that the embodiment of the present application classifies text information based on the first classification sub-model and the second classification sub-model to determine the category to which the text information belongs at different granularity levels. In another embodiment, there is no need to perform the above steps 502-503, and there is no need to distinguish between the first classification sub-model and the second classification sub-model. The classification model can replace the above first classification sub-model and the second classification sub-model, and directly based on the classification model, according to the above steps 501, 504-506, determine the first target category to which the text information belongs.
[0165] It should be noted that the embodiment of the present application determines the first target category and the second target category to which the text information belongs respectively, while in another embodiment, after determining the second target category to which the text information belongs, multiple subcategories corresponding to the second target category are determined, that is, multiple first categories corresponding to the second target category are determined, and then according to steps 504-506, the first target category to which the text information belongs is determined from the multiple first categories corresponding to the second target category. This process does not need to involve other subcategories of the second category.
[0166] The method provided in the embodiment of the present application introduces category information for representing categories when classifying text information, represents each category with the category semantic features of each category information, performs similarity matching between the category semantic features of each category and the text semantic features of the text information, and determines the category to which the text information belongs based on the obtained similarity. That is, in the process of classifying text information, the category information used for classification is enriched, and classification is performed in a similarity matching manner, thereby improving classification accuracy.
[0167] Furthermore, a hierarchical classification model based on a similarity matching mechanism is provided. Text information is classified based on the classification model to obtain the categories to which the text information belongs at various granularity levels, thereby ensuring the accuracy of the classification.
[0168] Based on the above Figure 5 In the embodiment shown, the present application provides a structural diagram of a classification model, such as Figure 6 As shown, the classification model includes a first classification sub-model 601 and a second classification sub-model 602. The first classification sub-model 601 includes a first encoding layer, a matching layer and a first normalization layer, and the second classification sub-model 602 includes a second encoding layer and a second normalization layer. The process of classifying text information based on the classification model is as follows. Figure 5 As shown;
[0169] Based on the second encoding layer, semantic extraction is performed on the text information to obtain text semantic features of the text information. Based on the second normalization layer, the text semantic features are classified to obtain category labels corresponding to each second category. Based on the category labels corresponding to multiple second categories, the second target category to which the text information belongs is determined.
[0170] Based on the first encoding layer, semantic extraction is performed on the category information of each first category to obtain the category semantic features of each first category; based on the matching layer, the category semantic features of each first category and the text semantic features, the similarity between the text semantic features and the semantic features of each category is obtained; based on the second normalization layer, the similarities corresponding to multiple first categories are normalized to obtain the probability that the text information belongs to each first category; based on the probabilities corresponding to the multiple first categories, the first target category to which the text information belongs is determined from the multiple first categories.
[0171] Based on the above Figure 3 or Figure 6 The embodiment shown is applied to a video classification scenario and provides a video classification process, which includes:
[0172] Step 1: Obtain text information of multiple videos, where the text information includes video titles.
[0173] Since the video title can best represent the content of the video, the videos are classified according to their text information.
[0174] Step 2: Follow the above steps Figure 3 or Figure 6 In the illustrated embodiment, the text information of each video is classified to obtain the category to which the text information of each video belongs.
[0175] Step 3: Determine the category to which the text information of each video belongs as the category to which each video belongs, and classify and store the multiple videos based on the categories to which the multiple videos belong.
[0176] Based on the above Figure 3 or Figure 6 The illustrated embodiment, applied in an e-commerce scenario, provides a process for item classification, which includes:
[0177] Step 1: The merchant sends the item information of the item to be put on the shelf to the e-commerce server through the e-commerce application installed on the merchant terminal.
[0178] The e-commerce server provides services for the e-commerce application. The item information of the item includes an image of the item and text information of the item, and the text information includes a title and a brief introduction of the item.
[0179] Step 2: The e-commerce server receives the item information and Figure 3 or Figure 6 In the illustrated embodiment, the category to which the text information of the item belongs is determined, the category is determined as the category to which the item information belongs, and the item information is classified and stored according to the category.
[0180] Step 3: When a user views items of any category through an e-commerce application installed on a user terminal, the user sends an item acquisition request to the e-commerce server. The item acquisition request carries the category. The e-commerce server receives the item acquisition request, queries for item information belonging to the category carried in the item acquisition request, and sends the retrieved item information to the user terminal.
[0181] Step 4: The user terminal receives the item information sent by the e-commerce server and displays the item information belonging to the category for the user to query.
[0182] It should be noted that this application only uses video classification and e-commerce scenarios as examples for illustration. In another embodiment, the classification method provided by this application can also be applied to a variety of other scenarios, such as search scenarios, medical scenarios, etc. In the search scenario, the method provided by the embodiment of this application can be used to classify search content; in the medical scenario, the method provided by the embodiment of this application can be used to classify medical records and implement classified management of medical records.
[0183] exist Figure 5 On the basis of the illustrated embodiment, before obtaining the first target category and the second target category to which the text information belongs based on the classification model, the classification model needs to be trained. The process of training the classification model is detailed in the following embodiment.
[0184] Figure 7 This is a flow chart of a classification method provided in an embodiment of the present application, which is executed by a computer device, such as Figure 7 As shown, the method includes:
[0185] 701. A computer device obtains sample text information and a corresponding first sample label and second sample label, where the first sample label indicates a first category to which the sample text information belongs, and the second sample label indicates a second category to which the sample text information belongs.
[0186] The sample text information is arbitrary text information. The first sample tag indicates the first category to which the sample text information belongs, and the second sample tag indicates the second category to which the sample text information belongs. For example, if the sample text information describes the content of a game, the first sample tag indicates that the sample text information belongs to the game category, and the second sample tag indicates that the sample text information belongs to a subcategory of the game category, namely, the mini-game category.
[0187] 702. The computer device obtains multiple semantic features of sample categories of the first category based on the classification model.
[0188] The sample category semantic feature is used to represent the first category, the classification model is a classification model to be trained, and the sample category semantic feature obtained based on the classification model may be inaccurate.
[0189] In one possible implementation, step 702 includes: the computer device obtains category information of multiple first categories, and based on the classification model, performs semantic extraction on the category information of each first category to obtain sample category semantic features of each first category.
[0190] The step 702 is similar to the above step 301 and will not be described again here.
[0191] 703. The computer device performs semantic extraction on the sample text information based on the classification model to obtain the sample text semantic features of the sample text information, and respectively obtains the predicted similarity between the sample text semantic features and the semantic features of each sample category.
[0192] The predicted similarity is obtained based on the classification model, which is a model to be trained. The predicted similarity can reflect the accuracy of the classification model.
[0193] The step 703 is similar to the above steps 302-303 and will not be described again here.
[0194] 704. The computer device classifies the semantic features of the sample text based on the classification model to obtain a plurality of predicted category labels corresponding to the second categories. The predicted category labels corresponding to the second categories indicate the possibility of predicting that the sample text information belongs to the second category.
[0195] The predicted category label is obtained based on a classification model, which is a model to be trained. The predicted category label can reflect the accuracy of the classification model.
[0196] The step 704 is similar to the above step 305 and will not be described again here.
[0197] 705. The computer device trains the classification model based on the first sample label, the predicted similarities corresponding to the multiple first categories, the second sample label, and the predicted category labels corresponding to the multiple second categories.
[0198] Since the first sample label indicates the first category to which the sample text information belongs, the predicted similarities corresponding to the multiple first categories are obtained based on the classification model, and the first sample label and the predicted similarities corresponding to the multiple first categories can reflect the accuracy of the classification model. Since the second sample label indicates the second category to which the sample text information belongs, the predicted similarities corresponding to the multiple second categories are obtained based on the classification model, and the second sample label and the predicted category labels corresponding to the multiple second categories can reflect the accuracy of the classification model. Therefore, based on the first sample label, the predicted similarities corresponding to the multiple first categories, the second sample label, and the predicted category labels corresponding to the multiple second categories, the classification model is trained to improve the accuracy of the classification model.
[0199] In one possible implementation, step 705 includes: determining a first loss value based on the first sample label and the predicted similarities corresponding to multiple first categories, determining a second loss value based on the second sample label and the predicted category labels corresponding to multiple second categories, performing weighted fusion on the first loss value and the second loss value to obtain a first loss sum value, and training the classification model based on the first loss sum value.
[0200] The first loss value can reflect the difference between the first category to which the sample text information actually belongs and the first category to which the sample text information is predicted based on the model. The second loss value can reflect the difference between the second category to which the sample text information actually belongs and the second category to which the sample text information is predicted based on the model. Both the first loss value and the second loss value can reflect the accuracy of the classification model. By weightedly fusing the first loss value and the second loss value to adjust the degree of influence of different losses on the classification model, the classification model is trained based on the first loss sum value obtained by weighted fusion to improve the accuracy of the classification model.
[0201] Optionally, the process of determining the first loss value includes: determining the true similarity corresponding to each first category based on the first sample label, and determining the first loss value based on the difference between the true similarities corresponding to multiple first categories and the predicted similarities corresponding to multiple first categories.
[0202] For the true similarity and predicted similarity corresponding to any first category, the difference between the true similarity and the predicted similarity can reflect the accuracy of the classification model. Based on the difference between the true similarities corresponding to multiple first categories and the predicted similarities corresponding to multiple first categories, a first loss value is determined so that the accuracy of the classification model can be subsequently improved based on the first loss value.
[0203] For example, based on the first sample label, it is determined that the true similarity of the first category to which the sample text information belongs is 1, and the true similarities of other first categories are 0.
[0204] Optionally, the true similarities corresponding to the multiple first categories, the predicted similarities corresponding to the multiple first categories, and the first loss value satisfy the following relationship:
[0205]
[0206] Among them, Loss cls1 is the first loss value, i is used to represent the sequence number of multiple first categories, n is used to represent the total number of multiple first categories, y i Used to represent the true similarity corresponding to the first category in the i-th category, a i Used to indicate the predicted similarity corresponding to the first category in the i-th category.
[0207] Optionally, the process of determining the second loss value includes: determining the true category label corresponding to each second category based on the second sample label, and determining the second loss value based on the difference between the true category labels corresponding to multiple second categories and the predicted category labels corresponding to multiple second categories.
[0208] Among them, the true category label and the predicted category label can be expressed in any form. For example, the true category label and the predicted category label are both identified in numerical form. Based on the second sample label, the true category label of the second category to which the sample text information belongs is determined to be 1, and the true category labels of other second categories are 0.
[0209] For the true category label and the predicted category label corresponding to any second category, the difference between the true category label and the predicted category label can reflect the accuracy of the classification model. Based on the difference between the true category labels corresponding to multiple second categories and the predicted category labels corresponding to multiple second categories, the second loss value is determined so that the accuracy of the classification model can be subsequently improved based on the second loss value.
[0210] Optionally, the true category labels corresponding to the multiple second categories, the predicted category labels corresponding to the multiple second categories, and the second loss values satisfy the following relationship:
[0211]
[0212] Among them, Loss cls2 is the second loss value, j is used to represent the sequence number of multiple second categories, m is used to represent the total number of multiple second categories, y j Used to represent the true category label corresponding to the second category in the jth, a j Used to indicate the predicted category label corresponding to the second category in the jth order.
[0213] In one possible implementation, step 705 includes: determining the target prediction similarity corresponding to the first category to which the sample text information belongs based on the first sample label and the prediction similarities corresponding to multiple first categories, determining the target prediction category label corresponding to the second category to which the sample text information belongs based on the second sample label and the prediction category labels corresponding to multiple second categories, and training the classification model based on the first sample label, the prediction similarities corresponding to multiple first categories, the second sample label, the prediction category labels corresponding to multiple second categories, the target prediction similarity and the target prediction category label.
[0214] Since the first sample label indicates the first category to which the sample text information belongs, and the second sample label indicates the second category to which the sample text information belongs, after obtaining the predicted similarities corresponding to multiple first categories and the predicted category labels corresponding to multiple second categories, based on the first sample label and the predicted similarities corresponding to the multiple first categories, the target predicted similarities corresponding to the first category to which the sample text information belongs can be determined from the predicted similarities corresponding to the multiple first categories; based on the second sample label and the predicted category labels corresponding to the multiple second categories, the target predicted category label corresponding to the second category to which the sample text information belongs can be determined from the predicted category labels corresponding to the multiple second categories.
[0215] In an embodiment of the present application, for any text information, the probability that the text information belongs to the second category is greater than that the text information belongs to the first category of the subcategory of the second category. Therefore, the classification model is trained based on the target prediction similarity and the target prediction category label, and the accuracy of the classification model is improved by constraining the hierarchical relationship of categories at different granularity levels, thereby ensuring the accuracy of the classification model.
[0216] Optionally, the classification model is trained based on the first sample label, the predicted similarities corresponding to multiple first categories, the second sample label, the predicted category labels corresponding to multiple second categories, the target predicted similarity and the target predicted category label, including: determining a first loss value based on the first sample label and the predicted similarities corresponding to multiple first categories, determining a second loss value based on the second sample label and the predicted category labels corresponding to multiple second categories, determining a third loss value based on the target predicted similarity and the target predicted category label, performing weighted fusion on the first loss value, the second loss value and the third loss value to obtain a second loss sum value, and training the classification model based on the second loss sum value.
[0217] Among them, the third loss value represents the difference between the predicted values of the categories to which the sample text information belongs at different granularity levels, which can reflect the accuracy of the classification model.
[0218] Since the first loss value, the second loss value and the third loss value can all reflect the accuracy of the classification model, the first loss value, the second loss value and the third loss value are weightedly fused to adjust the degree of influence of different losses on the classification model. The classification model is trained based on the second loss sum value obtained by weighted fusion to improve the accuracy of the classification model.
[0219] Optionally, the method of determining the third loss value includes: determining the third loss value based on the difference between the target prediction similarity and the target prediction category label.
[0220] Optionally, the target prediction similarity, the target prediction category label, and the third loss value satisfy the following relationship:
[0221]
[0222] Among them, Loss h is the third loss value, i is used to represent the ordinal number of multiple first categories, n is used to represent the total number of multiple first categories, L2_Score is used to represent the target prediction similarity, L1_Score is used to represent the target prediction category label, λ is the harmonic hyperparameter, and the harmonic hyperparameter λ is a constant.
[0223] Optionally, the first loss value, the second loss value, the third loss value, and the second loss sum value satisfy the following relationship:
[0224] Loss=λ1Loss cls1 +λ2Loss cls2 +λ3Loss h
[0225] Among them, Loss is the second loss and value, Loss cls1 is the first loss value, Loss cls2 Is the second loss value, Loss h is the third loss value, λ1, λ2 and λ3 are the harmonic difference parameters of the first loss value, the second loss value and the third loss value respectively, and are all constants.
[0226] It should be noted that the embodiment of the present application uses a single iteration of the classification model training as an example to illustrate the training process of the classification model. In another embodiment, the classification model can be iterated multiple times according to the above steps 701-705. In one possible implementation, if the number of iterations is greater than the round threshold, the training of the classification model is stopped; or if the loss sum value of the current iteration is less than the loss threshold, the training of the classification model is stopped. The round threshold and the loss threshold are both arbitrary values.
[0227] It should be noted that the embodiment of the present application trains the classification model based on the first sample label, the predicted similarities corresponding to multiple first categories, the second sample label and the predicted category labels corresponding to multiple second categories. In another embodiment, there is no need to execute steps 701, 704-705, and other methods can be adopted to obtain sample text information and the corresponding first sample label, and train the classification model based on the first sample label and the predicted similarities corresponding to multiple first categories.
[0228] The method provided in the embodiment of the present application provides a hierarchical classification model based on a similarity matching mechanism. The classification model can classify text information into categories of different granularity levels. By introducing sample category semantic features for representing categories and combining multiple granularity level classification methods based on the classification model, the classification model is trained, thereby enriching the information for training the classification model and improving the accuracy of the classification model.
[0229] Moreover, since the probability that text information belongs to a category at an upper granularity level is greater than the probability that the text information belongs to a category at a lower granularity level, that is, there is a constraint relationship between the categories to which text information belongs at different granularity levels, therefore, when training the classification model, the upper and lower level constraint relationship between categories at different granularity levels is introduced to improve the accuracy of the classification model.
[0230] Figure 8 This is a structural diagram of a classification device provided in an embodiment of the present application. Figure 8 As shown, the device includes:
[0231] An acquisition module 801 is configured to acquire a plurality of first category semantic features, where the first category semantic features are obtained by semantically extracting category information of the first category.
[0232] The acquisition module 801 is further used to perform semantic extraction on the text information to be classified, obtain text semantic features of the text information, and respectively obtain the similarity between the text semantic features and the semantic features of each category;
[0233] The determination module 802 is configured to determine the first target category to which the text information belongs from the plurality of first categories based on the similarities corresponding to the plurality of first categories.
[0234] In one possible implementation, each first category is a subcategory of a second category, and at least two first categories belong to different second categories; Figure 9 As shown, the device also includes:
[0235] A classification module 803 is configured to classify the text semantic features based on the plurality of second categories to obtain category labels corresponding to the plurality of second categories, wherein the category labels corresponding to the second categories indicate the possibility that the text information belongs to the second category;
[0236] The determination module 802 is further configured to determine, from the plurality of second categories, the second target category to which the text information belongs based on category labels corresponding to the plurality of second categories.
[0237] In another possible implementation, each first category is a subcategory of the second category, and the determination module 802 is further configured to determine the second category to which the first target category belongs as the second target category to which the text information belongs.
[0238] In another possible implementation, the acquisition module 801 is used to obtain category semantic features of multiple first categories based on a classification model; perform semantic extraction on text information based on the classification model to obtain text semantic features, and obtain the similarity between the text semantic features and each category semantic feature respectively.
[0239] In another possible implementation, the classification model includes a first classification sub-model and a second classification sub-model; Figure 9 As shown, the acquisition module 801 includes:
[0240] An acquiring unit 8011 is configured to acquire, based on the first classification sub-model, a plurality of first category semantic features;
[0241] An extraction unit 8012 is configured to perform semantic extraction on the text information based on the second classification sub-model to obtain text semantic features;
[0242] The acquisition unit 8011 is further configured to respectively acquire the similarity between the text semantic feature and the semantic feature of each category based on the first classification sub-model.
[0243] In another possible implementation, each first category is a subcategory of a second category, and at least two first categories belong to different second categories; Figure 9 As shown, the device also includes:
[0244] A classification module 803 is configured to classify the text semantic features based on the second classification sub-model to obtain category labels corresponding to a plurality of second categories, wherein the category labels corresponding to the second categories indicate the possibility that the text information belongs to the second category;
[0245] The determination module 802 is configured to determine the second target category to which the text information belongs from the plurality of second categories based on category labels corresponding to the plurality of second categories.
[0246] In another possible implementation, Figure 9 As shown, the device also includes:
[0247] The acquisition module 801 is further configured to acquire sample text information and a corresponding first sample label, where the first sample label indicates a first category to which the sample text information belongs;
[0248] The acquisition module 801 is further configured to acquire a plurality of first category sample category semantic features based on the classification model;
[0249] An extraction module 804 is configured to perform semantic extraction on the sample text information based on the classification model to obtain the sample text semantic features of the sample text information, and to obtain the predicted similarity between the sample text semantic features and the semantic features of each sample category;
[0250] The training module 805 is configured to train the classification model based on the first sample label and the predicted similarities corresponding to the plurality of first categories.
[0251] In another possible implementation, each first category is a subcategory of a second category, and at least two first categories belong to different second categories. The acquisition module 801 is further configured to acquire a second sample label corresponding to the sample text information, where the second sample label indicates the second category to which the sample text information belongs.
[0252] like Figure 9 As shown, the training module 805 includes:
[0253] A classification unit 8051 is configured to classify the semantic features of the sample text based on the classification model to obtain a plurality of predicted category labels corresponding to the second category, wherein the predicted category labels corresponding to the second category indicate the likelihood that the sample text information belongs to the second category;
[0254] The training unit 8052 is used to train the classification model based on the first sample label, the predicted similarities corresponding to the multiple first categories, the second sample label and the predicted category labels corresponding to the multiple second categories.
[0255] In another possible implementation, the training unit 8052 is used to determine a first loss value based on the first sample label and the predicted similarities corresponding to multiple first categories; determine a second loss value based on the second sample label and the predicted category labels corresponding to multiple second categories; perform weighted fusion on the first loss value and the second loss value to obtain a first loss sum value; and train the classification model based on the first loss sum value.
[0256] In another possible implementation, the training unit 8052 is used to determine the target prediction similarity corresponding to the first category to which the sample text information belongs based on the first sample label and the prediction similarities corresponding to multiple first categories; determine the target prediction category label corresponding to the second category to which the sample text information belongs based on the second sample label and the prediction category labels corresponding to multiple second categories; and train the classification model based on the first sample label, the prediction similarities corresponding to multiple first categories, the second sample label, the prediction category labels corresponding to multiple second categories, the target prediction similarity and the target prediction category label.
[0257] In another possible implementation, the training unit 8052 is used to determine a first loss value based on the first sample label and the prediction similarities corresponding to multiple first categories; determine a second loss value based on the second sample label and the prediction category labels corresponding to multiple second categories; determine a third loss value based on the target prediction similarity and the target prediction category label; perform weighted fusion on the first loss value, the second loss value, and the third loss value to obtain a second loss sum value; and train the classification model based on the second loss sum value.
[0258] In another possible implementation, the text information is used to describe the multimedia resource, and the determination module 802 is further configured to determine the first target category to which the text information belongs as the category to which the multimedia resource belongs.
[0259] It should be noted that the classification device provided in the above embodiment is merely an example of the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device can be divided into different functional modules to complete all or part of the functions described above. In addition, the classification device provided in the above embodiment and the classification method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0260] An embodiment of the present application also provides a computer device, which includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the operations performed by the classification method of the above embodiment.
[0261] Optionally, the computer device is provided as a terminal. Figure 10The following is a block diagram of a terminal 1000 according to an exemplary embodiment of the present application. Terminal 1000 may be a portable mobile terminal, such as a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. Terminal 1000 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other similar names.
[0262] The terminal 1000 includes a processor 1001 and a memory 1002 .
[0263] The processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0264] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one computer program, which is executed by the processor 1001 to implement the classification method provided in the method embodiment of the present application.
[0265] In some embodiments, terminal 1000 may optionally include a peripheral device interface 1003 and at least one peripheral device. Processor 1001, memory 1002, and peripheral device interface 1003 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 1003 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006, an audio circuit 1007, and a power supply 1009.
[0266] The peripheral device interface 1003 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0267] The RF circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1004 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1004 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the RF circuit 1004 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 1004 can communicate with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1004 may also include circuitry related to Near Field Communication (NFC), which is not limited in this application.
[0268] The display screen 1005 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1005 is a touch screen display, the display screen 1005 also has the ability to collect touch signals on the surface or above the surface of the display screen 1005. The touch signal can be input as a control signal to the processor 1001 for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, there can be one display screen 1005, which is set on the front panel of the terminal 1000; in other embodiments, there can be at least two display screens 1005, which are respectively set on different surfaces of the terminal 1000 or in a folding design; in other embodiments, the display screen 1005 can be a flexible display screen, which is set on the curved surface or folding surface of the terminal 1000. Even more, the display screen 1005 can be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1005 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0269] The camera assembly 1006 is used to capture images or videos. Optionally, the camera assembly 1006 includes a front camera and a rear camera. The front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1006 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. The dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.
[0270] The audio circuit 1007 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input into the processor 1001 for processing, or input into the RF circuit 1004 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, each located in different parts of the terminal 1000. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert electrical signals from the processor 1001 or the RF circuit 1004 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1007 may also include a headphone jack.
[0271] Power supply 1009 is used to power various components in terminal 1000. Power supply 1009 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 1009 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0272] In some embodiments, the terminal 1000 further includes one or more sensors 1010 , including but not limited to: an acceleration sensor 1011 , a gyroscope sensor 1012 , a pressure sensor 1013 , an optical sensor 1015 , and a proximity sensor 1016 .
[0273] The accelerometer 1011 can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal 1000. For example, the accelerometer 1011 can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 1001 can control the display screen 1005 to display the user interface in either a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer 1011. The accelerometer 1011 can also be used to collect game or user motion data.
[0274] The gyroscope sensor 1012 can detect the body orientation and rotation angle of the terminal 1000. The gyroscope sensor 1012 can cooperate with the acceleration sensor 1011 to collect the user's 3D movements on the terminal 1000. Based on the data collected by the gyroscope sensor 1012, the processor 1001 can implement the following functions: motion sensing (such as changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0275] The pressure sensor 1013 can be set on the side frame of the terminal 1000 and / or the lower layer of the display screen 1005. When the pressure sensor 1013 is set on the side frame of the terminal 1000, it can detect the user's grip signal of the terminal 1000, and the processor 1001 performs left and right hand recognition or shortcut operations based on the grip signal collected by the pressure sensor 1013. When the pressure sensor 1013 is set on the lower layer of the display screen 1005, the processor 1001 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 1005. Operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0276] Optical sensor 1015 is used to detect ambient light intensity. In one embodiment, processor 1001 can control the display brightness of display screen 1005 based on the ambient light intensity detected by optical sensor 1015. Specifically, when the ambient light intensity is high, the display brightness of display screen 1005 is increased; when the ambient light intensity is low, the display brightness of display screen 1005 is decreased. In another embodiment, processor 1001 can also dynamically adjust the shooting parameters of camera assembly 1006 based on the ambient light intensity detected by optical sensor 1015.
[0277] Proximity sensor 1016, also known as a distance sensor, is disposed on the front panel of terminal 1000. Proximity sensor 1016 is used to detect the distance between the user and the front of terminal 1000. In one embodiment, when proximity sensor 1016 detects that the distance between the user and the front of terminal 1000 is gradually decreasing, processor 1001 controls display screen 1005 to switch from the screen-on state to the screen-off state. When proximity sensor 1016 detects that the distance between the user and the front of terminal 1000 is gradually increasing, processor 1001 controls display screen 1005 to switch from the screen-off state to the screen-on state.
[0278] Those skilled in the art will understand that Figure 10 The structure shown in the figure does not constitute a limitation on the terminal 1000, and the terminal 1000 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0279] Optionally, the computer device is provided as a server. Figure 111 is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server 1100 may vary significantly due to different configurations or performances, and may include one or more processors (Central Processing Units, CPUs) 1101 and one or more memories 1102, wherein the memories 1102 store at least one computer program, which is loaded and executed by the processor 1101 to implement the methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.
[0280] An embodiment of the present application further provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor to implement the operations performed by the classification method of the above embodiment.
[0281] An embodiment of the present application also provides a computer program product, including a computer program, which implements the operations performed by the classification method of the above embodiment when the computer program is executed by a processor.
[0282] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0283] The above description is merely an optional embodiment of the embodiments of the present application and is not intended to limit the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the embodiments of the present application shall be included in the scope of protection of the present application.
Claims
1. A classification method, characterized in that The method comprises: Obtaining, based on a classification model, category semantic features of a plurality of first categories, where the category semantic features are obtained by semantically extracting category information of the first category, the classification model corresponding to a plurality of first categories and a plurality of second categories, each first category being a subcategory of a second category, and at least two first categories belonging to different second categories; Based on the classification model, semantic extraction is performed on the text information to be classified to obtain text semantic features of the text information, and similarities between the text semantic features and semantic features of each category are respectively obtained; based on the similarities corresponding to multiple first categories, a first target category to which the text information belongs is determined from the multiple first categories; classifying the text semantic features based on the classification model to obtain a plurality of category labels corresponding to the second categories, wherein the category labels corresponding to the second categories indicate a likelihood that the text information belongs to the second category; and determining a second target category to which the text information belongs from the plurality of second categories based on the category labels corresponding to the plurality of second categories; Among them, the training process of the classification model includes: obtaining sample text information and a corresponding first sample label and a second sample label corresponding to the sample text information, the first sample label indicates the first category to which the sample text information belongs, and the second sample label indicates the second category to which the sample text information belongs; based on the classification model, obtaining a plurality of sample category semantic features of the first category; based on the classification model, performing semantic extraction on the sample text information to obtain the sample text semantic features of the sample text information, and respectively obtaining the predicted similarity between the sample text semantic features and each of the sample category semantic features; based on the classification model, classifying the sample text semantic features to obtain a plurality of sample category semantic features of the second category The predicted category label corresponding to the second category indicates the possibility of predicting that the sample text information belongs to the second category; based on the first sample label and the predicted similarities corresponding to the multiple first categories, the target predicted similarity corresponding to the first category to which the sample text information belongs is determined; based on the second sample label and the predicted category labels corresponding to the multiple second categories, the target predicted category label corresponding to the second category to which the sample text information belongs is determined; based on the first sample label, the predicted similarities corresponding to the multiple first categories, the second sample label, the predicted category labels corresponding to the multiple second categories, the target predicted similarity and the target predicted category label, the classification model is trained.
2. The method according to claim 1, characterized in that Before determining the second target category to which the text information belongs from the plurality of second categories based on the category labels corresponding to the plurality of second categories, the method further includes: Based on the plurality of second categories, the text semantic features are classified to obtain category labels corresponding to the plurality of second categories.
3. The method according to claim 1, characterized in that The classification model includes a first classification sub-model and a second classification sub-model; and the method of obtaining a plurality of first category semantic features based on the classification model includes: Based on the first classification sub-model, obtaining category semantic features of a plurality of the first categories; The method of performing semantic extraction on the text information to be classified based on the classification model to obtain text semantic features of the text information, and respectively obtaining similarities between the text semantic features and the semantic features of each category, includes: Based on the second classification sub-model, semantic extraction is performed on the text information to obtain the text semantic features; Based on the first classification sub-model, similarities between the text semantic feature and each category semantic feature are obtained respectively.
4. The method according to claim 3, characterized in that Before determining the second target category to which the text information belongs from the plurality of second categories based on the category labels corresponding to the plurality of second categories, the method further includes: Based on the second classification sub-model, the text semantic features are classified to obtain category labels corresponding to multiple second categories.
5. The method according to claim 1, wherein The method further comprises: Determining a first loss value based on the first sample label and the predicted similarities corresponding to the plurality of first categories; determining a second loss value based on the second sample label and a plurality of predicted category labels corresponding to the second categories; Performing weighted fusion on the first loss value and the second loss value to obtain a first loss sum value; The classification model is trained based on the first loss and value.
6. The method according to claim 1, characterized in that The training of the classification model based on the first sample label, the predicted similarities corresponding to the plurality of first categories, the second sample label, the predicted category labels corresponding to the plurality of second categories, the target predicted similarities, and the target predicted category label includes: Determining a first loss value based on the first sample label and the predicted similarities corresponding to the plurality of first categories; Determining a second loss value based on the second sample label and a plurality of predicted category labels corresponding to the second categories; Determining a third loss value based on the target prediction similarity and the target prediction category label; Performing weighted fusion on the first loss value, the second loss value, and the third loss value to obtain a second loss sum value; The classification model is trained based on the second loss and value.
7. The method according to any one of claims 1 to 6, characterized in that The text information is used to describe a multimedia resource. After determining, based on the similarities corresponding to the plurality of first categories, a first target category to which the text information belongs, the method further includes: The first target category to which the text information belongs is determined as the category to which the multimedia resource belongs.
8. A classification device, characterized in that: The device comprises: an acquisition module, configured to acquire, based on a classification model, category semantic features of a plurality of first categories, wherein the category semantic features are obtained by semantically extracting category information of the first category, wherein the classification model corresponds to a plurality of first categories and a plurality of second categories, wherein each first category is a subcategory of a second category, and at least two first categories belong to different second categories; The acquisition module is further configured to perform semantic extraction on the text information to be classified based on the classification model to obtain text semantic features of the text information, and respectively obtain similarities between the text semantic features and the semantic features of each category; a determination module, configured to determine, from a plurality of first categories, a first target category to which the text information belongs based on similarities corresponding to the plurality of first categories; a classification module, configured to classify the text semantic features based on the classification model to obtain a plurality of category labels corresponding to the second categories, wherein the category labels corresponding to the second categories indicate a possibility that the text information belongs to the second category; The determining module is further configured to determine, from a plurality of second categories, a second target category to which the text information belongs based on category labels corresponding to the plurality of second categories; Among them, the training process of the classification model includes: obtaining sample text information and a corresponding first sample label and a second sample label corresponding to the sample text information, the first sample label indicates the first category to which the sample text information belongs, and the second sample label indicates the second category to which the sample text information belongs; based on the classification model, obtaining a plurality of sample category semantic features of the first category; based on the classification model, performing semantic extraction on the sample text information to obtain the sample text semantic features of the sample text information, and respectively obtaining the predicted similarity between the sample text semantic features and each of the sample category semantic features; based on the classification model, classifying the sample text semantic features to obtain a plurality of sample category semantic features of the second category The predicted category label corresponding to the second category indicates the possibility of predicting that the sample text information belongs to the second category; based on the first sample label and the predicted similarities corresponding to the multiple first categories, the target predicted similarity corresponding to the first category to which the sample text information belongs is determined; based on the second sample label and the predicted category labels corresponding to the multiple second categories, the target predicted category label corresponding to the second category to which the sample text information belongs is determined; based on the first sample label, the predicted similarities corresponding to the multiple first categories, the second sample label, the predicted category labels corresponding to the multiple second categories, the target predicted similarity and the target predicted category label, the classification model is trained.
9. The device according to claim 8, characterized in that The classification module is further configured to classify the text semantic features based on the plurality of second categories to obtain category labels corresponding to the plurality of second categories.
10. The device according to claim 8, characterized in that The classification model includes a first classification sub-model and a second classification sub-model; the acquisition module is used to acquire the category semantic features of the plurality of first categories based on the first classification sub-model; The acquisition module is used to perform semantic extraction on the text information based on the second classification sub-model to obtain the text semantic features; based on the first classification sub-model, respectively obtain the similarity between the text semantic features and each category semantic feature.
11. The device according to claim 10, characterized in that The classification module is further configured to classify the text semantic features based on the second classification sub-model to obtain category labels corresponding to a plurality of second categories.
12. The device according to claim 8, characterized in that The device further comprises: A training module is used to determine a first loss value based on the first sample label and the predicted similarities corresponding to multiple first categories; determine a second loss value based on the second sample label and the predicted category labels corresponding to multiple second categories; perform weighted fusion on the first loss value and the second loss value to obtain a first loss sum value; and train the classification model based on the first loss sum value.
13. The device according to claim 8, characterized in that The device further comprises: A training module is used to determine a first loss value based on the first sample label and the prediction similarities corresponding to multiple first categories; determine a second loss value based on the second sample label and the prediction category labels corresponding to multiple second categories; determine a third loss value based on the target prediction similarity and the target prediction category label; perform weighted fusion on the first loss value, the second loss value and the third loss value to obtain a second loss sum value; and train the classification model based on the second loss sum value.
14. The device according to any one of claims 8 to 13, characterized in that The text information is used to describe multimedia resources, and the determination module is further used to determine the first target category to which the text information belongs as the category to which the multimedia resources belong.
15. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the operations performed by the classification method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by a processor to implement the operations performed by the classification method according to any one of claims 1 to 7.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the operations performed by the classification method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Text classification method and device, electronic equipment and storage medium
CN112860900A