Object classification method, device and equipment based on classification model
Through the object classification method based on the classification model, the encoding layer, the first classification layer and the second classification layer are used to vector code and classify media text, which solves the problem of inaccurate classification of lower-level categories in the prior art, and achieves higher classification accuracy and accuracy.
Patent Information
- Application Number
- CN202210272860.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-03-18
AI Technical Summary
In the prior art, multi-classification tasks based on the category system have low accuracy for subcategories with small data volumes, especially in hierarchical classification, and lower-level categories are not accurate enough.
Through the object classification method based on the classification model, the media text is encoded using the encoding layer, and first- and second-level classification layers are combined with the first and second-level classification layers. The target category of the object to be classified is determined using the representation vector and keywords, and the fusion sub-layer and classification sub-layer are used to fusion to optimize the classification process.
The accuracy of the objects to be classified belong to the secondary category has been improved, and the overall accuracy and accuracy of the classification have been improved.
Smart Images

Figure CN116821780B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to machine learning technology of artificial intelligence, and in particular to an object classification method, apparatus, device, computer-readable storage medium, and computer program product based on a classification model. Background Art
[0002] Hierarchical classification is an important task in multi-classification in fields such as natural language processing and computer vision. Its main feature is that the category labels in hierarchical classification have a hierarchical relationship, where the upper label is the parent of the lower label, and the granularity of the hierarchical classification becomes finer as you go down the hierarchy.
[0003] In related technologies, multi-classification tasks based on category systems mostly treat classification tasks as several basic multi-classification tasks, directly predict the secondary categories of the objects to be classified, and directly trace back the primary categories based on the prediction results. This classification method has low classification accuracy for sub-categories with smaller data volumes. Summary of the Invention
[0004] The embodiments of the present application provide an object classification method, apparatus, device, computer-readable storage medium, and computer program product based on a classification model, which can improve the classification accuracy of objects to be classified.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The present invention provides an object classification method based on a classification model, including:
[0007] Acquire media text associated with the object to be classified, and perform vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text;
[0008] Performing a first-level classification on the object to be classified based on the text vector through the first classification layer of the classification model to obtain a target first-level category to which the object to be classified belongs in the category system;
[0009] The category system includes: at least two first-level categories, and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword;
[0010] Performing secondary classification on the object to be classified based on the text vector and the representation vector of each of the secondary categories through the second classification layer of the classification model to obtain a target secondary category to which the object to be classified belongs;
[0011] The representation vector is determined based on keywords included in the corresponding secondary category, and the target secondary category belongs to the target primary category.
[0012] The present invention provides an object classification device based on a classification model, including:
[0013] An encoding module, configured to obtain media text associated with the object to be classified, and perform vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text;
[0014] a first classification module configured to perform a first-level classification on the object to be classified based on the text vector using a first classification layer of the classification model to obtain a target first-level category to which the object to be classified belongs in a category system; wherein the category system includes at least two first-level categories and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword;
[0015] The second classification module is used to perform secondary classification on the object to be classified based on the text vector and the representation vector of each of the secondary categories through the second classification layer of the classification model to obtain the target secondary category to which the object to be classified belongs; wherein the representation vector is determined based on the keywords included in the corresponding secondary category, and the target secondary category belongs to the target first-level category.
[0016] In the above solution, the second classification layer includes a fusion sublayer and a classification sublayer, and the second classification module is further used to fuse the text vector and the representation vector of each of the secondary categories through the fusion sublayer to obtain a vector fusion result;
[0017] Through the classification sublayer, the object to be classified is subjected to secondary classification based on the fusion result to obtain the target secondary category to which the object to be classified belongs.
[0018] In the above solution, the second classification module is further used to obtain a dimension vector for first-order vector fusion, and perform first-order fusion on the text vector and the representation vector of each of the secondary categories based on the dimension vector through the fusion sublayer to obtain a first-order fusion result;
[0019] Obtaining a second-order fusion parameter for second-order vector fusion, and performing second-order vector fusion on the text vector and the representation vectors of each of the secondary categories based on the second-order fusion parameter through the fusion sublayer to obtain a second-order fusion result;
[0020] The first-order fusion result and the second-order fusion result are fused through the fusion sublayer to obtain the vector fusion result.
[0021] In the above solution, the second classification module is further used to obtain a parameter matrix for vector fusion;
[0022] Through the fusion sublayer, based on the parameter matrix and the quadratic operation structure, the text vector and the representation vectors of each secondary category are fused to obtain a vector fusion result.
[0023] In the above solution, the second classification module is further used to perform vector splicing on the text vector and the representation vectors of each of the secondary categories to obtain a spliced vector;
[0024] A dimension vector for vector fusion is obtained, and the splicing vector and the dimension vector are multiplied to obtain the vector fusion result.
[0025] In the above solution, before performing primary classification on the object to be classified based on the text vector through the first classification layer of the classification model, the acquisition module is further used to obtain keywords included in each of the secondary categories in the category system;
[0026] For each of the secondary categories, encode each keyword included in the secondary category to obtain a keyword vector corresponding to each keyword;
[0027] A target vector operation is performed on the keyword vectors corresponding to the keywords included in each of the secondary categories to obtain a representation vector of the corresponding secondary category.
[0028] In the above solution, the acquisition module is further configured to, for each of the secondary categories, when the number of keywords included in the secondary category reaches a quantity threshold, perform vector averaging on the keyword vectors corresponding to the keywords included in the secondary category to obtain a representation vector for the secondary category;
[0029] For each of the secondary categories, when the number of keywords included in the secondary category does not reach a quantity threshold, keyword vectors corresponding to the keywords included in the secondary category are vector-summed to obtain a representation vector of the secondary category.
[0030] In the above solution, the acquisition module is further used to extract keywords from the media text to obtain at least one media keyword included in the media text;
[0031] The step of performing vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text includes:
[0032] Performing vector encoding on each media keyword included in the media text through the encoding layer of the classification model to obtain a word vector corresponding to each media keyword;
[0033] Perform vector concatenation on the obtained word vectors to obtain a text vector corresponding to the media text.
[0034] In the above solution, the first classification module is further used to obtain the at least two first-level categories included in the category system;
[0035] performing, by the first classification layer of the classification model, multi-classification of the object to be classified into the at least two first-level categories based on the text vector and the at least two first-level categories, and obtaining a probability that the object to be classified belongs to each of the first-level categories;
[0036] The first-level category corresponding to the maximum probability is used as the target first-level category to which the object to be classified belongs.
[0037] In the above solution, the object classification device based on the classification model further includes a training module, wherein the training module is used to obtain media text samples associated with the object samples to be classified, wherein the media text samples carry a first-level category label and a second-level category label;
[0038] Performing vector encoding on the media text sample through the encoding layer to obtain a target text vector corresponding to the media text sample;
[0039] Performing a first-level classification on the object sample to be classified based on the target text vector through the first classification layer to obtain a first-level classification result, wherein the first-level classification result is used to indicate the first-level category to which the object sample to be classified belongs;
[0040] Performing secondary classification on the object sample to be classified based on the target text vector and the representation vectors of each of the secondary categories through the second classification layer to obtain a secondary classification result, wherein the secondary classification result is used to indicate the secondary category to which the object sample to be classified belongs;
[0041] A first difference between the first-level category label and the first-level classification result, and a second difference between the second-level category label and the second-level classification result are obtained, and model parameters of the classification model are updated based on the first difference and the second difference.
[0042] In the above solution, the training module is further used to obtain a first loss function corresponding to the first classification layer, a second loss function corresponding to the second classification layer, and a constraint function;
[0043] Constructing a loss function of the classification model based on the first loss function, the second loss function and the constraint function;
[0044] The constraint function is used to ensure that the secondary category indicated by the secondary classification result is a subcategory of the primary category indicated by the primary classification result;
[0045] A value of a loss function of the classification model is determined based on the first difference and the second difference, and a model parameter of the classification model is updated based on the value of the loss function of the classification model.
[0046] The present invention provides a method for training a classification model, including:
[0047] Obtaining a media text sample associated with the object sample to be classified, wherein the media text sample carries a first-level category label and a second-level category label;
[0048] Performing vector encoding on the media text sample through the encoding layer of the classification model to obtain a target text vector corresponding to the media text sample;
[0049] Performing a first-level classification on the object sample to be classified based on the target text vector through the first classification layer of the classification model to obtain a first-level category to which the object sample to be classified belongs in the category system;
[0050] The category system includes: at least two first-level categories, and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword;
[0051] Performing secondary classification on the object sample to be classified based on the target text vector and the representation vector of each of the secondary categories through the second classification layer of the classification model to obtain the secondary category to which the object sample to be classified belongs;
[0052] The representation vector is determined based on the keywords included in the corresponding secondary category, and the secondary category to which the object to be classified belongs is a subcategory of the primary category to which the object to be classified belongs;
[0053] Obtain a first difference between the first-level category label and the first-level category to which the sample of the object to be classified belongs, and a second difference between the second-level category label and the second-level category to which the sample of the object to be classified belongs, and update the model parameters of the classification model based on the first difference and the second difference.
[0054] The present invention provides a training device for a classification model, including:
[0055] An acquisition module is used to acquire a media text sample associated with the object sample to be classified, wherein the media text sample carries a first-level category label and a second-level category label;
[0056] A vector encoding module, configured to perform vector encoding on the media text sample through the encoding layer of the classification model to obtain a target text vector corresponding to the media text sample;
[0057] a first-level classification module, configured to perform first-level classification on the object sample to be classified based on the target text vector using the first classification layer of the classification model, and obtain a first-level category to which the object sample to be classified belongs in a category system; wherein the category system includes: at least two first-level categories and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword;
[0058] a secondary classification module, configured to perform secondary classification on the object sample to be classified based on the target text vector and the representation vector of each of the secondary categories through the second classification layer of the classification model, to obtain the secondary category to which the object sample to be classified belongs; wherein the representation vector is determined based on the keywords included in the corresponding secondary category, and the secondary category to which the object sample to be classified belongs is a subcategory of the primary category to which the object to be classified belongs;
[0059] An updating module is used to obtain a first difference between the first-level category label and the first-level category to which the sample of the object to be classified belongs, and a second difference between the second-level category label and the second-level category to which the sample of the object to be classified belongs, and update the model parameters of the classification model based on the first difference and the second difference.
[0060] An embodiment of the present application provides an electronic device, including:
[0061] a memory for storing executable instructions;
[0062] The processor is configured to implement the object classification method based on the classification model provided in the embodiment of the present application when executing the executable instructions stored in the memory.
[0063] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute and implement the object classification method based on the classification model provided in the embodiment of the present application.
[0064] An embodiment of the present application provides a computer program product, including a computer program or instructions, which is used to cause a processor to execute and implement the object classification method based on the classification model provided in the embodiment of the present application.
[0065] The embodiments of the present application have the following beneficial effects:
[0066] Applying the embodiment of the present application, the representation vector of the secondary category to which the object to be classified belongs is determined by keywords. Since keywords can represent the semantics expressed by the secondary category to a certain extent, the representation vector corresponding to the secondary category and the text vector of the media text are determined based on the keywords of the secondary category, and the object to be classified is subjected to secondary classification. The target secondary category to which the object to be classified belongs is more accurate, thereby improving the classification accuracy of the object to be classified. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 This is a schematic diagram of the architecture of an object classification system based on a classification model provided in an embodiment of the present application;
[0068] Figure 2A 1 is a schematic structural diagram of an electronic device for implementing an object classification method based on a classification model provided in an embodiment of the present application;
[0069] Figure 2B Schematic diagram of the structure of an electronic device for implementing a classification model training method provided in an embodiment of the present application;
[0070] Figure 3 Schematic diagram of the process of the object classification method based on the classification model provided in the embodiment of the present application;
[0071] Figure 4 This is a flow chart of a method for obtaining a text vector provided in an embodiment of the present application;
[0072] Figure 5 This is a schematic diagram of the category system provided in the embodiment of the present application;
[0073] Figure 6 This is a method for obtaining the representation vector of the secondary category in the embodiment of the present application;
[0074] Figure 7 It is the secondary category keyword expression intention provided in the embodiment of this application;
[0075] Figure 8 This is a flow chart of a method for determining secondary categories provided in an embodiment of the present application;
[0076] Figure 9 This is a schematic diagram of the fusion method provided in the embodiment of the present application;
[0077] Figure 10 This is a flow chart of the training method of the classification model provided in the embodiment of the present application;
[0078] Figure 11 This is a schematic diagram of a media text sample provided in an embodiment of the present application;
[0079] Figure 12 This is a classification model processing flow chart provided in an embodiment of the present application;
[0080] Figure 13 This is a schematic diagram of the classification model update process provided by an embodiment of the present application;
[0081] Figure 14 This is a flow chart of a training method for a classification model provided in an embodiment of the present application;
[0082] Figure 15 This is a schematic diagram of the video category hierarchy provided in an embodiment of the present application;
[0083] Figure 16 It is a schematic diagram of the implementation method of the hierarchical classification model in the related technology;
[0084] Figure 17 This is a schematic diagram of the system structure of the hierarchical classification model provided in the embodiment of the present application;
[0085] Figure 18 This is a flow chart of the training method of the hierarchical classification model provided in the embodiment of the present application;
[0086] Figure 19 This is a schematic diagram of a video classification method based on a classification model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0087] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0088] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0089] If similar descriptions of "first / second" appear in the application documents, the following explanation is added. In the following description, the terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0090] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0091] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0092] 1) Hierarchical multi-label classification is an important task in multi-classification in fields such as natural language processing (NLP) and computer vision (CV). Its main feature is that the category labels in hierarchical classification have a hierarchical relationship, with the upper label being the parent of the lower label, and the granularity of the hierarchical classification increases as the level decreases.
[0093] 2) Hinge loss function: In support vector machines, the hinge loss function can be used as the loss function when constructing the objective function. The hinge loss function not only requires correct classification, but also requires a high enough confidence level for the loss to be zero. In other words, the hinge loss function has higher requirements for learning.
[0094] Based on the above explanations of the nouns and terms involved in the embodiments of the present application, the object classification system based on the classification model provided by the embodiments of the present application is described below. Figure 1 , Figure 1 This is an architectural diagram of an object classification system based on a classification model provided in an embodiment of the present application. To support an object classification application based on a classification model, in the object classification system 100 based on a classification model, a terminal (terminal 400-1 and terminal 400-2 are shown as examples) is connected to a server 200 via a network 300. The network 300 can be a wide area network or a local area network, or a combination of the two. Among them, the server 200 can belong to a target server cluster, which includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. The server cluster can be used to provide background services for applications that support three-dimensional virtual environments.
[0095] The terminal is used to send a classification request carrying media text associated with the object to be classified to a server deployed with a classification model, and receive a target primary category and a target secondary category for the object to be classified returned by the server based on the classification model.
[0096] The server 200 is used to obtain the media text associated with the object to be classified based on the classification request sent by the terminal, and perform vector encoding on the media text through the encoding layer of the classification model to obtain the text vector corresponding to the media text; through the first classification layer of the classification model, perform primary classification on the media information based on the text vector to obtain the target primary category to which the media information belongs in the category system; the category system includes: at least two primary categories, and multiple secondary categories obtained by dividing the at least two primary categories, each secondary category includes at least one keyword; through the second classification layer of the classification model, perform secondary classification on the media information based on the text vector and the representation vector of each secondary category to obtain the target secondary category to which the media information belongs; the representation vector is determined based on the keywords included in the corresponding secondary category, and the target secondary category belongs to the target first category.
[0097] In actual implementation, the trained classification model can also be directly deployed in the terminal. After the terminal obtains the media text associated with the object to be classified, the trained classification model is used to perform primary classification and secondary classification on the object to be classified, and the target primary category and target secondary category to which the object to be classified belongs are obtained, wherein the target secondary category belongs to the target first category.
[0098] In actual applications, the server 200 can be 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, content distribution networks (CDNs), and big data and artificial intelligence platforms. The terminal (such as terminal 400-1 and terminal 400-2) can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart TV, a smart watch, etc., but is not limited to this. The terminal (such as terminal 400-1 and terminal 400-2) and the server 200 can be directly or indirectly connected via wired or wireless communication, and this application is not limited thereto.
[0099] The embodiments of the present application can also be implemented with the help of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network within a wide area network or a local area network to realize data calculation, storage, processing, and sharing.
[0100] Cloud technology is a general term for network, information, integration, management platform, and application technologies used in the cloud computing business model. It can form a resource pool that can be used flexibly and conveniently on demand. Cloud computing technology will become a key support. The backend services of technical network systems require a large amount of computing and storage resources.
[0101] See also Figure 2A , Figure 2A This is a schematic diagram of the structure of an electronic device that implements the object classification method based on the classification model provided in the embodiment of the present application. In practical applications, the electronic device 500 can be implemented as Figure 1 The server or terminal in the embodiment of the present application is used to describe an electronic device that implements the object classification method based on the classification model of the embodiment of the present application. The electronic device 500 shown in Figure 2 includes: at least one processor 510, a memory 550, at least one network interface 520 and a user interface 530. The various components in the electronic device 500 are coupled together through a bus system 540. It can be understood that the bus system 540 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are labeled as bus systems 540 in Figure 2.
[0102] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0103] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0104] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, etc. The memory 550 may optionally include one or more storage devices that are physically remote from the processor 510.
[0105] The memory 550 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.
[0106] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.
[0107] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0108] A network communication module 552 for reaching other computing devices via one or more (wired or wireless) network interfaces 520 , exemplary network interfaces 520 including Bluetooth, WiFi, and USB;
[0109] a presentation module 553 for enabling presentation of information via one or more output devices 531 (e.g., a display screen, a speaker, etc.) associated with the user interface 530 (e.g., a user interface for operating peripheral devices and displaying content and information);
[0110] The input processing module 554 is configured to detect one or more user inputs or interactions from one of the one or more input devices 532 and to translate the detected inputs or interactions.
[0111] In some embodiments, the object classification device based on the classification model provided in the embodiments of the present application can be implemented in software. Figure 2A The electronic device provided in an embodiment of the present application is a schematic diagram of a server for providing classification model-based object classification. A classification model-based object classification device 555 stored in a memory 550 can be software in the form of a program or plug-in, and includes the following software modules: an encoding module 5551, a first classification module 5552, and a second classification module 5553. These modules are logical and can be arbitrarily combined or further separated according to the functions implemented. The functions of each module will be described below.
[0112] In other embodiments, the training device of the classification model provided in the embodiments of the present application can be implemented in a software manner, see Figure 2B , Figure 2B is a structural diagram of an electronic device for implementing a classification model training method provided in an embodiment of the present application, Figure 2BThe electronic device provided in an embodiment of the present application is a schematic diagram of the structure of a server for providing training of a classification model. The training device 556 of the classification model stored in the memory 550 can be software in the form of a program or plug-in, including the following software modules: an acquisition module 5561, a vector encoding module 5562, a primary classification module 5563, a secondary classification module 5564, and an update module 5565. These modules are logical and can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.
[0113] In other embodiments, the object classification device based on the classification model provided in the embodiments of the present application can be implemented in hardware. As an example, the object classification device based on the classification model provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the object classification method based on the classification model provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0114] Based on the above description of the object classification system and electronic device based on the classification model provided in the embodiment of the present application, the object classification method based on the classification model provided in the embodiment of the present application is described below. In some embodiments, the object classification method based on the classification model provided in the embodiment of the present application can be implemented separately by a server or a terminal, or implemented collaboratively by a server and a terminal. In some embodiments, the terminal or the server can implement the object classification method based on the classification model provided in the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in an operating system; it can be a local (Native) application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a client that supports virtual scenes, such as a game APP; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0115] The following uses server implementation as an example to illustrate the object classification method based on the classification model provided by the embodiment of the present application. Figure 3 , Figure 3 : is a flow chart of an object classification method based on a classification model provided in an embodiment of the present application. The object classification method based on a classification model provided in an embodiment of the present application includes:
[0116] In step 101, the server obtains the media text associated with the object to be classified, and performs vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text.
[0117] In practical applications, the object to be classified can be media information, such as video, audio, articles, etc., or it can be an entity to be classified on the Internet, such as a commodity in an e-commerce system, or it can be content in an Internet search system, etc. In addition, the media text associated with the object to be classified is used to explain the content, characteristics (such as the shape characteristics and usage purposes of the commodity), etc. of the object to be classified. The media text associated with the object to be classified can be the title text, text introduction, etc. of the media information, or it can be a descriptive text of the shape characteristics, usage characteristics, etc. of the entity to be classified on the Internet. When the object to be classified is media information, at least part of the text content is obtained by performing content recognition on the media information. For example, when the media information is a video, the media text associated with the media information can be obtained by identifying the actor role, subtitle text, etc.; when the media information is audio, the text information can be obtained by converting audio to text, and then part of the text information is extracted as the media information associated with the audio.
[0118] In actual implementation, the classification model for classifying objects to be classified can be understood as a hierarchical classification model. The classification model includes a coding layer, a first classification layer, and a second classification layer. The coding layer is used to perform vector encoding on the media text associated with the object to be classified to obtain a text vector corresponding to the media text; the first classification layer is used to perform a first-level classification on the text vector to obtain the first-level category to which the object to be classified belongs; the second classification layer is used to determine the target second-level category to which the object to be classified belongs. Finally, the server determines the first-level category and the corresponding second-level category corresponding to the object to be classified through the classification model.
[0119] Exemplarily, the encoding layer of the classification model can be implemented by N convolutional layers, the first classification layer can be implemented by a fully connected layer (softmax layer), and the second classification layer can be implemented by a pooling layer followed by a softmax layer.
[0120] In actual implementation, the category labels to which the objects to be classified belong have a hierarchical relationship, where the upper category is the parent of the lower category, and the granularity becomes finer as you go down the hierarchy.
[0121] For example, taking the object to be classified as video information and the media text associated with the object to be classified as the video title, in order to improve the search efficiency in the entire video search system and enhance the human-computer interaction experience, the category of the video information can be determined based on the video title through a classification model. The object to be classified for the video information can be divided into two-level categories with a hierarchical relationship. There are 44 first-level categories, including coarse-grained thematic categories such as sports, games, and entertainment. The first-level categories are further divided into multiple second-level categories, for a total of 305 fine-grained second-level categories. For a video information M of the game strategy type, whose video title is "How can I play mini program A well?", the corresponding first-level category can be "game", and the second-level category "mini game" corresponding to the first-level category "game", and so on.
[0122] In actual implementation, the server can use a pre-trained semantic feature extraction model to vectorize the media text, thereby obtaining the corresponding semantic vector. The semantic feature extraction model can determine whether the media text needs to be segmented or input directly at the character granularity.
[0123] For example, a variety of methods such as a Bidirectional Encoder Representations from Transformers (BERT) model, a convolutional neural network model, and a Long Short-Term Memory (LSTM) network can be determined as encoders for media texts.
[0124] In some embodiments, see Figure 4 , Figure 4 This is a flowchart of a method for obtaining a text vector provided by an embodiment of the present application, based on Figure 3 The process of determining the text vector corresponding to the media text in step 101 can be implemented through steps 1011 to 1013.
[0125] In step 1011, the server extracts keywords from the media text to obtain at least one media keyword included in the media text.
[0126] For example, a video information with the title "Square dance makes you healthier" is used, and the keywords "square dance", "dance", "health" and the like are extracted.
[0127] Step 1012: Perform vector encoding on each media keyword included in the media text through the encoding layer of the classification model to obtain a word vector corresponding to each media keyword.
[0128] Continuing with the above example, we perform (semantic) vector encoding on each media keyword to obtain the word vector corresponding to each media keyword.
[0129] Step 1013: perform vector concatenation on the obtained word vectors to obtain a text vector corresponding to the media text.
[0130] In actual implementation, each word vector is concatenated to obtain a text vector for representing the semantic information of the media text.
[0131] In step 102, the first classification layer of the classification model is used to perform primary classification on the object to be classified based on the text vector to obtain the target primary category to which the object to be classified belongs in the category system.
[0132] It should be noted that the category system for the classification model includes: at least two first-level categories, and multiple second-level categories obtained by dividing the at least two first-level categories, and each second-level category includes at least one keyword.
[0133] For example, taking the object to be classified as video information, a category system for the classification model of the corresponding video information can be constructed. The category system includes two-level categories with a hierarchical relationship. There are 44 first-level categories, including coarse-grained categories such as sports, games, and entertainment. The first-level categories are further divided into multiple second-level categories, totaling 305 fine-grained second-level categories. Based on this category system, the target first-level category to which the video information belongs is obtained. See Figure 5 , Figure 5 This is a schematic diagram of the category system provided by the embodiment of the present application, which shows a two-level category system for video information in the form of a hierarchical tree. For example, for a video titled "Square Dance for Health", it can be classified into the first-level category corresponding to "Dance".
[0134] In some embodiments, the server can determine the target first-level category to which the object to be classified belongs in the following manner: the server obtains at least two first-level categories included in the category system; through the first classification layer of the classification model, based on the text vector and at least two first-level categories, the object to be classified is multi-classified into at least two first-level categories to obtain the probability that the object to be classified belongs to each first-level category; the first-level category corresponding to the maximum probability is used as the target first-level category to which the object to be classified belongs.
[0135] In actual implementation, the first classification layer of the classification model, which can be a softmax layer, determines the probability that the text vector belongs to each first-level category in the category system, and takes the first-level category corresponding to the maximum probability as the first-level category of the object to be classified.
[0136] For example, taking the object to be classified as a video and the associated media text as the video title as an example, there is a video content A, and the video title T is "Jump Jump, teach you how to get to 600". Combined with the above category system including 44 first-level categories and 305 second-level categories, the text vector D corresponding to the video title T is determined. Through the first classification layer of the classification model, the probability that the text vector D belongs to the 44 first-level categories is output, that is, 44 probability values will be output. The first-level category corresponding to the maximum probability value (the probability corresponding to the first-level category "game" is the largest) is taken as the first-level category corresponding to the video content A, that is, the first-level category corresponding to the video content A is "game".
[0137] In some embodiments, see Figure 6 , Figure 6 This is a method for obtaining the characterization vector of the secondary category in the embodiment of the present application, combined with Figure 6 The steps shown are explained.
[0138] In step 201, the server obtains keywords included in each secondary category in the category system.
[0139] In actual implementation, for each secondary category, the corresponding keywords can be obtained through chi-square statistics. These keywords represent the semantic information to be expressed by the secondary category to some extent. The number of keywords can be one or at least two. When there is only one keyword, this keyword is directly used to represent the current secondary category. When there are at least two keywords, different weights can be set for each keyword to collaboratively represent the secondary category.
[0140] For example, see Figure 7 , Figure 7 This is the secondary category keyword representation intention provided by the embodiment of the present application. The secondary categories shown in the figure are "mini games", "square dance", "mobile games", "mobile phones", etc., among which the keywords used to represent "mini games" include ["jump", "plants", "instant messaging"], and the keywords used to represent "square dance" include ["square dance", "dance", "steps"], etc.
[0141] Step 202 : For each secondary category, encode each keyword included in the secondary category to obtain a keyword vector corresponding to each keyword.
[0142] In practice, the classification model's encoding layer encodes each keyword in each secondary category to generate a keyword vector. These keyword vectors can be trained on a general corpus, typically using a bag-of-words model (e.g., word2vec).
[0143] Step 203 : Perform target vector calculation on the keyword vectors corresponding to the keywords included in each secondary category to obtain a representation vector of the corresponding secondary category.
[0144] In actual implementation, since keywords can represent the semantics expressed by secondary categories to a certain extent, the semantic vectors of multiple keywords included in the secondary category are averaged or summed to obtain a representation vector representing the semantics of the secondary category. Each secondary category is represented by cls_i, and the specific expression of cls_i is as follows: cls_i == avg_pooling([v1, v2, ..., vk]), where v1, v2, ..., vk are the K (K ≥ 1, and K is an integer) keyword vectors corresponding to each secondary category. avg_pooling is a vector averaging operation.
[0145] In some embodiments, the server can also determine the characterization vector of the secondary category in the following manner: for each secondary category, when the number of keywords included in the secondary category reaches a quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector averaged to obtain the characterization vector of the secondary category; for each secondary category, when the number of keywords included in the secondary category does not reach a quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector summed to obtain the characterization vector of the secondary category.
[0146] In actual implementation, the server can also determine the target operation method for keywords based on the number of keywords in each secondary category. When the number of keywords is less than the quantity threshold, the corresponding target operation can be to directly add the keyword vectors, and use the summed vector as the representation vector of the secondary category; when the number of keywords reaches the quantity threshold, the keyword vectors can be averaged to obtain the average vector as the representation vector of the secondary category. It should be noted that the vector average can be to directly sum the keyword vectors and then calculate the average, or it can be to obtain the weight corresponding to each keyword vector, perform a weighted sum on the keyword vectors, and then calculate the average.
[0147] Exemplarily, when determining the secondary category of the object O to be classified for the classification model M, if the number of keywords corresponding to the secondary category in the category system is less than 3, the characterization vector of the secondary category is determined by direct vector addition; if the number of keywords corresponding to the secondary category reaches 3, the characterization vector of the secondary category can be determined by vector averaging, which can include vector direct averaging and vector weighted averaging. By default, the characterization vector of the secondary category can be determined directly by vector direct averaging. However, in order to highlight the importance of individual keywords, a higher weight can be set for important keywords to enhance the importance of the keyword in the current secondary category. When the keyword has a weight, the characterization vector of the secondary category can be determined by vector weighted averaging.
[0148] The above-mentioned method of determining the representation vector of the secondary category, which is applicable to various situations, can improve the accuracy of determining the secondary category.
[0149] In step 103, the second classification layer of the classification model performs secondary classification on the object to be classified based on the text vector and the representation vectors of each secondary category to obtain the target secondary category to which the object to be classified belongs.
[0150] In actual implementation, the representation vector of a secondary category is determined based on the keywords included in the corresponding secondary category, and the target secondary category belongs to the target primary category. In other words, the target secondary category is one of the at least two subcategories obtained by dividing the target primary category, that is, the primary category is the parent category of the secondary category.
[0151] In some embodiments, the second classification layer includes a fusion sublayer and a classification sublayer, see Figure 8 , Figure 8 This is a flow chart of the method for determining the secondary category provided in the embodiment of the present application, based on Figure 3 , step 103 can be implemented through steps 1031 and 1032.
[0152] In step 1031 , the server fuses the text vector and the representation vectors of each secondary category through the fusion sublayer to obtain a vector fusion result.
[0153] In actual implementation, the server performs multi-order fusion on the text vector representing the media text and the representation vectors of each secondary category through the fusion sublayer of the classification model to obtain a vector fusion result (i.e., a fusion vector). The multi-order fusion here can be a first-order fusion of the text vector and the representation vectors of each secondary category, a second-order fusion of the text vector and the representation vectors of each secondary category, or a hybrid fusion method that performs both first-order and second-order fusion on the text vector and the representation vectors of each secondary category.
[0154] Exemplarily, first-order fusion can be understood as linearly mapping the text vector with the characterization vector of each secondary category and the vector fusion result (first-order mapping). The linear mapping function can be set to y=wx+b, where x can be the result of summing the text vector with the characterization vector of each secondary category. The summation operation here can include direct summation or weighted summation, and y is the vector fusion result. Second-order fusion can be understood as performing a quadratic data operation (second-order mapping) on the text vector with the characterization vector of each secondary category and the vector fusion result. The second-order mapping function can be set to y=xWz+b, where x can be the text vector, z is the characterization vector of each secondary category, W is the parameter matrix, and y is the vector fusion result.
[0155] In some embodiments, see Figure 9 , Figure 9 This is a schematic diagram of the fusion method provided in the embodiment of the present application, combined with Figure 9 The steps shown are explained.
[0156] In step 301, the server obtains a dimension vector for first-order vector fusion, and performs first-order fusion on the text vector and the representation vectors of each secondary category based on the dimension vector through the fusion sublayer to obtain a first-order fusion result.
[0157] In actual implementation, the server may perform first-order fusion on the text vector and the representation vectors of each secondary category according to the following first-order fusion method.
[0158]
[0159] In the above formula (1), the text vector can be represented by l1_emb, the representation vector of each secondary category can be represented by e_emb, and V[l1_emb:e_emb] is the fusion result after the first-order fusion of the text vector and the representation vector of each secondary category (that is, the result after the first-order fusion method).
[0160] For example, assuming that l1_emb is of 1*m dimension and e_emb is of n*1, V[l1_emb:e_emb] is a (m+n)*1 vector obtained by concatenating l1_emb and e_emb, and V dimension is a d*(m+n) vector, then the obtained V[l1_emb:e_emb] is an output vector of 1*d dimension.
[0161] Step 302: Obtain second-order fusion parameters for second-order vector fusion, and perform second-order vector fusion on the text vector and the representation vectors of each secondary category based on the second-order fusion parameters through the fusion sublayer to obtain a second-order fusion result.
[0162] In actual implementation, the server can perform second-order vector fusion on the text vector and the representation vector of each secondary category based on the secondary fusion parameters through the following second-order fusion method to obtain a second-order fusion result.
[0163] Logits=l1_emb*w [1:d] *e_emb+b Formula (2)
[0164] In the above formula (2), the text vector can be represented by l1_emb, and the representation vector of each secondary category can be represented by e_emb, where l1_emb is the text vector of the media text, e_emb ∈Rm*d is the representation vector table of the secondary categories, m is the number of secondary categories, d is the word vector dimension, generally 200 to 500, W is the parameter matrix of the fusion module, l1_emb*w [1:d] *e_emb forms a second-order fusion vector, where d is the output vector dimension. It should be noted that formula (2) is the quadratic form y = xWz + b in the mathematical definition. The core of the mapping function is a quadratic change, which can be called bilinear, and is considered to expand the function to a second-order mapping.
[0165] For example, assuming l1_emb is 1*p dimension, e_emb is q*1, and W is a three-dimensional tensor of p*q*d, the obtained l1_emb*w [1:d] *e_emb is an output vector of 1*d dimension.
[0166] Step 303: fuse the first-order fusion result and the second-order fusion result through the fusion sub-layer to obtain a vector fusion result.
[0167] In actual implementation, the server fuses the first-order fusion result obtained in step 301 and the second-order fusion result obtained in step 302 through the fusion sublayer of the classification model to obtain a vector fusion result, namely, a target fusion vector.
[0168] In some embodiments, the server may implement the fusion of the first-order fusion result and the second-order fusion result in the following manner: the server directly adds the first-order fusion result and the second-order fusion result through a fusion sublayer to obtain a vector fusion result.
[0169] In actual implementation, the server can determine the vector fusion result through the following formula.
[0170]
[0171] In the above formula, the server directly adds the obtained first-order fusion result and the second-order fusion result to obtain the vector fusion result.
[0172] In some embodiments, the server can achieve the fusion of the first-order fusion result and the second-order fusion result in the following manner: the server obtains a first weight corresponding to the first-order fusion result and a second weight corresponding to the second-order fusion result; and based on the first weight and the second weight, performs weighted summation on the first-order fusion result and the second-order fusion result to obtain a vector fusion result.
[0173] In actual implementation, the server can determine the vector fusion result through the following formula.
[0174]
[0175] In the above formula, λ1 represents the first weight corresponding to the first-order fusion result, and λ2 represents the second weight corresponding to the second-order fusion result. Based on λ1 and λ2, the first-order fusion result and the second-order fusion result are weighted summed to obtain the vector fusion result. It should be noted that λ1 and λ2 can be pre-configured based on actual conditions or dynamically updated during the classification model training process.
[0176] In some embodiments, the server can also obtain the vector fusion result in the following manner: the server obtains the parameter matrix used for vector fusion; and through the fusion sublayer, based on the parameter matrix and the quadratic operation structure, the text vector and the representation vectors of each secondary category are fused to obtain the vector fusion result.
[0177] In actual implementation, the server can also fuse the text vector and the representation vectors of each secondary category through the fusion sublayer of the classification model according to the quadratic operation structure and the preset parameter matrix for vector fusion to obtain the vector fusion result.
[0178] For example, logits=l1_emb*w in the above formula (1) [1:d] *e_emb, can be seen as a variant of the quadratic operation structure. Among them, w is the parameter matrix for vector fusion, d is the output vector dimension, l1_emb*w [1:d] *e_emb is the vector fusion result.
[0179] In some embodiments, the server can also obtain the vector fusion result in the following manner: the server performs vector splicing on the text vector and the representation vectors of each secondary category to obtain a splicing vector; obtains the dimension vector used for vector fusion, and multiplies the splicing vector and the dimension vector to obtain the vector fusion result.
[0180] In actual implementation, the server can also fuse the text vector and the representation vectors of each secondary category through the fusion sublayer of the classification model according to the quadratic operation structure and the preset parameter matrix for vector fusion to obtain the vector fusion result.
[0181] For example, logits=l1_emb*w in the above formula (1) [1:d] *e_emb, can be seen as a variant of the quadratic operation structure. Among them, w is the parameter matrix for vector fusion, d is the output vector dimension, l1_emb*w [1:d] *e_emb is the vector fusion result.
[0182] Step 1032 , through the classification sub-layer, secondary classification is performed on the object to be classified based on the fusion result to obtain the target secondary category to which the object to be classified belongs.
[0183] In actual implementation, the server performs secondary classification on the objects to be classified through the classification sublayer, that is, performs multiple classifications of the secondary categories, obtains the probability that the objects to be classified belong to each secondary category, and takes the secondary category with the highest probability as the target secondary category.
[0184] For example, the server applies a softmax layer to the logits obtained by the above formulas (1)-(4) to obtain the predicted secondary category distribution, that is, the probability that the object to be classified belongs to each secondary category.
[0185] In some embodiments, see Figure 10 , Figure 10 This is a flow chart of the training method of the classification model provided in the embodiment of the present application, based on Figure 3 Before the server classifies the object to be classified using the trained classification model, it may further perform steps 401 to 405 to train the classification model.
[0186] In step 401 , the server obtains a media text sample associated with an object sample to be classified. The media text sample carries a first-level category label and a second-level category label.
[0187] In actual implementation, the first-level category tag carried in the media text sample is used to indicate the first-level category to which the object sample to be classified belongs in the category system, and the second-level category tag carried in the media text sample is used to indicate the second-level category to which the object sample to be classified belongs in the category system.
[0188] For example, taking the object to be classified as a video as an example, see Figure 11 , Figure 11 This is a schematic diagram of a media text sample provided in an embodiment of the present application. The media text for a video can be regarded as a video title. The video title shown in the figure carries two-level labels. For example, the media text sample "Jump and teach you how to get 600 points" is marked with a first-level category label (L1_class) "game" and a second-level category label (L2_class) "mini-game".
[0189] Step 402: Perform vector encoding on the media text sample through the encoding layer to obtain a target text vector corresponding to the media text sample.
[0190] In actual implementation, the text vector of the media text sample is obtained through the encoding layer of the classification model. The encoding layer can adopt a conventional multi-classification model, take the media text sample as the input of the encoding layer, and obtain the corresponding text vector.
[0191] Following the above example, see Figure 12 , Figure 12 This is a classification model processing flow chart provided in an embodiment of the present application. The video title T (media text sample) "Jump Jump, Teach You How to Get 600 Points" is input into the encoding layer of the classification model to obtain a text vector (l1_emb).
[0192] Step 403: Perform a first-level classification on the to-be-classified object sample based on the target text vector through the first classification layer to obtain a first-level classification result.
[0193] In actual implementation, the first-level classification result is used to indicate the first-level category to which the object sample to be classified belongs. The text vector obtained in step 402 is input into the first classification layer to obtain the first-level classification result of the object sample to be classified. In actual applications, a softmax classifier or an SVM (support vector machine) classifier can be used as the first classification layer of the classification model.
[0194] Following the above example, see Figure 12 , input the text vector (l1_emb) of the video title T "Jump Jump, teach you how to get 600 points" into the first classification layer containing the softmax classifier, and obtain the probability that the video title T belongs to each first-level category in the category system, and take the first-level category corresponding to the maximum probability as the target first-level category of the video title T. Under normal circumstances, the probability of the first-level category "game" is the largest.
[0195] Step 404 : Perform secondary classification on the to-be-classified object sample based on the target text vector and the representation vectors of each secondary category through the second classification layer to obtain a secondary classification result.
[0196] In actual implementation, the secondary classification result is used to indicate the secondary category to which the object sample to be classified belongs. The server pre-determines the representation vector corresponding to each secondary category based on each secondary category and at least one keyword corresponding to each secondary category in the category system, and adopts any fusion method in the above formulas (1)-(4) to fuse the target text vector and the representation vector of each secondary category, thereby realizing the secondary classification process of the object sample to be classified and obtaining the corresponding secondary classification result.
[0197] Following the above example, see Figure 12 , encode at least one keyword (number 1) corresponding to each secondary category in the category system through word2vec, obtain the keyword vector corresponding to each keyword, and based on each keyword vector, determine the representation vector (e_emb) corresponding to each secondary category, and fuse l1_emb and e_emb. Through the fusion method corresponding to the above formula (3), determine the target fusion vector logits, and input the target fusion vector logits into the second classification layer of the classification model to perform secondary classification on the video title T "Jump Jump, teach you how to get 600 points" to obtain the secondary classification result.
[0198] Step 405 : Obtain a first difference between the first-level category label and the first-level classification result, and a second difference between the second-level category label and the second-level classification result, and update the model parameters of the classification model based on the first difference and the second difference.
[0199] In actual implementation, the server can update the model parameters of the classification model based on the first difference between the first-level category label and the first-level classification result, and the second difference between the second-level category label and the second-level classification result, and train the classification model until the classification model converges to obtain a trained classification model.
[0200] In some embodiments, see Figure 13 , Figure 13 This is a schematic diagram of the classification model update process provided by the embodiment of the present application, based on Figure 13 , step 405 can be implemented by steps 4051 to 4053, which will be explained in combination with each step.
[0201] In step 4051, the server obtains a first loss function corresponding to the first classification layer, a second loss function corresponding to the second classification layer, and a constraint function.
[0202] In actual implementation, the constraint function is used to ensure that the secondary category indicated by the secondary classification result is a subcategory of the primary category indicated by the primary classification result.
[0203] For example, the first loss function may adopt a negative logarithmic loss function, and the specific formula is as follows:
[0204]
[0205] In the above formula, cls1 corresponds to the first classification layer, n is the number of first-level categories in the category system, and y i It takes 0 or 1, indicating whether the first-level category label is the i-th category, and ai is the predicted value of the first-level classification result in this category.
[0206] Correspondingly, the second loss function can use the negative logarithmic loss function, and the specific formula is as follows:
[0207]
[0208] In the above formula, cls2 represents the second classification layer, m is the number of secondary categories in the category system, and y j It takes 0 or 1, indicating whether the secondary category label is the jth category, and aj is the predicted value of the secondary classification result in this category.
[0209] Correspondingly, the constraint function can be expressed as follows:
[0210]
[0211] In the above formula, the constraint function is the hinge loss function, which is used to constrain the consistency of the first and second level categories, that is, to ensure that the predicted target second level category belongs to the second level category in the target first level category. λ is a hyperparameter greater than 0, and λ+l2_score-l1_score means that the predicted first level category score l1_score is always expected to be greater than the corresponding second level category l2_score. If λ+l2_score-l1_score <= 0, that is, l1_score is greater than l2_score, then loss h =0, no loss occurs;
[0212] Step 4052: Construct a loss function of the classification model based on the first loss function, the second loss function and the constraint function.
[0213] Exemplarily, the loss function of the classification model is obtained based on the first loss function, the second loss function, and the constraint function determined in step 4051. The loss function of the classification model can be expressed as follows:
[0214] loss = λ1loss cls1 +λ2loss cls2 +λ3loss h Formula (6)
[0215] Step 4053: Determine the value of the loss function of the classification model based on the first difference and the second difference, and update the model parameters of the classification model based on the value of the loss function of the classification model.
[0216] In actual implementation, the server can update the model parameters of the classification model based on the first difference between the first-level category label and the first-level classification result, and the second difference between the second-level category label and the second-level classification result, and train the classification model until the classification model converges to obtain a trained classification model.
[0217] In some instances, see Figure 14 , Figure 14 This is a flow chart of the training method for the classification model provided in the embodiment of the present application, combined with Figure 14 The steps shown are explained.
[0218] Step 501: The server obtains a media text sample associated with an object sample to be classified, wherein the media text sample carries a first-level category label and a second-level category label;
[0219] Step 502: Perform vector encoding on the media text sample through the encoding layer of the classification model to obtain a target text vector corresponding to the media text sample.
[0220] Step 503 : Performing a first-level classification on the object sample to be classified based on the target text vector through the first classification layer of the classification model to obtain the first-level category to which the object sample to be classified belongs in the category system.
[0221] The category system includes: at least two first-level categories, and multiple second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories includes at least one keyword;
[0222] Step 504 : Perform secondary classification on the object sample to be classified based on the target text vector and the representation vectors of each secondary category through the second classification layer of the classification model to obtain the secondary category to which the object sample to be classified belongs.
[0223] The representation vector is determined based on the keywords included in the corresponding secondary category, and the secondary category to which the sample of the object to be classified belongs is a subcategory of the primary category to which the object to be classified belongs.
[0224] Step 505: Obtain a first difference between the first-level category label and the first-level category to which the obtained sample of the object to be classified belongs, and a second difference between the second-level category label and the second-level category to which the obtained sample of the object to be classified belongs, and update the model parameters of the classification model based on the first difference and the second difference.
[0225] The server iteratively executes steps 501 to 505 to train the classification model until the classification model reaches a convergence condition, thereby obtaining a trained classification model. The convergence condition may be that the number of training times reaches a threshold or the training samples are exhausted.
[0226] In practical applications, the trained hierarchical classification model provided in the embodiment of the present application can be applied to various business scenarios that require the extraction of document categories, such as content classification in search, product title classification in e-commerce systems, etc.
[0227] In applying the embodiments of the present application, the first-level category to which the object to be classified belongs is first determined based on the media text associated with the object to be classified; since keywords can represent the semantics expressed by the second-level category to a certain extent, the semantics of each second-level category in the category system can be represented by at least one keyword. In this way, the semantics corresponding to the second-level category are determined based on the keywords of the second-level category, and then the object to be classified is subjected to second-level classification in combination with the text vector of the media text. The target second-level category obtained is more accurate, thereby improving the classification accuracy of the object to be classified.
[0228] Below, an exemplary application of the embodiment of the present application in a practical application scenario will be described.
[0229] Taking the video as an example, the video title exists as the media text associated with the video. Parsing the text based on the video title content combined with basic algorithms such as natural language processing to enhance the understanding of the video's semantic information is one of the core tasks of the entire video search system. Figure 15 , Figure 15 This is a schematic diagram of the video category hierarchy provided by an embodiment of the present application. In the figure, for video content, determining the basic subject category (i.e., the first-level category) of the video content based on the video title and modeling to complete the title word weight task are the basis for understanding the video content. For the business in the video subsystem, in actual applications, two levels of categories can be constructed for the classification of video content: 44 first-level categories, including coarse-grained thematic categories such as sports, games, and entertainment, among which the first-level categories can be further divided into multiple second-level categories, for a total of 305 fine-grained second-level categories. Among them, for the method of determining the second-level category to which the video content belongs, see the related art. Figure 16 , Figure 16 This is a schematic diagram of the implementation of the hierarchical classification model in related technologies. Most of them regard the task as several basic multi-classification tasks, flatten the category system, and the classification model directly predicts the secondary category, and then directly traces back to the primary category from the predicted secondary category. The above is a multi-classification method for discrimination, but for subcategories, there is often a problem of small data volume. This problem requires, first, expanding the subcategory data, and second, introducing some additional knowledge to enhance the model.
[0230] Based on this, a training method for a classification model is proposed in an embodiment of the present application. The trained classification model can be used to predict the secondary category to which the video content belongs. This method predicts the secondary category based on a bilinear fusion mechanism of category keywords. The classification model in the embodiment of the present application (also known as a hierarchical classification model) utilizes a category label classification system (category system), and the upper-level categories constrain the lower-level categories. At the same time, since the secondary categories themselves also have semantic information, the recognition ability of the hierarchical classification model can be enhanced by vector fusion. It also involves the construction of the semantic vector of the secondary category itself; and the enhancement of semantic interaction through multi-order feature fusion.
[0231] First, the structure of the classification model provided in the embodiment of the present application is described. Figure 11 In the figure, each training sample data has two levels of label data. For the second-level categories, the chi-squared statistical method can be used to obtain the keywords corresponding to each second-level category. These keywords represent the semantics expressed by the second-level category to some extent. For example, the video title "Jump Jump, Teach You How to Get 600 Points" shown in the figure corresponds to the first-level category "Game" and the second-level category "Mini Games". The "Mini Games" can be represented by keywords such as "Jump Jump", "Plants", and "Instant Messaging".
[0232] In actual implementation, see Figure 17 , Figure 17 It is a schematic diagram of the system structure of the hierarchical classification model provided in the embodiment of the present application. The hierarchical classification model adopts a conventional multi-classification model on the first-level category of the video title, takes the sentence (video title) as input, obtains the semantic vector after encoding processing of the multi-classification model, and then performs softmax multi-classification. For the second-level category of the video title, the word vector of the second-level category can be obtained to represent it. The second-level category is no longer obtained by DNN mapping, but is obtained based on the fusion of the sentence (video title) semantic vector and the second-level category semantic vector. Category prediction (i.e., secondary classification) is obtained. For the semantic vector expression of the second-level category, it can be represented based on the theme words of the second-level category, and the second-level category semantics and sentence semantic vectors can be strengthened through multi-order semantic interaction.
[0233] The training process of the hierarchical classification model is explained. The semantic encoding of the title sentence can be completed using various methods such as CNN and LSTM. The encoded semantic vector is used as input to obtain the first-level category result. All second-level categories are represented by word vectors. The word vector can be obtained by encoding the keywords of the second-level category through an encoding module trained on general corpus. The training method of this encoding module can be selected from word2vec and other methods. The second-level category is determined by vector fusion of the sentence semantic vector and all the second-level category word vectors, and then predicted. Vector fusion introduces the semantic vector of the second-level category. This method is also more advantageous when sub-category training data is missing. See Figure 18 , Figure 18 This is a flow chart of the training method of the hierarchical classification model provided in the embodiment of the present application, combined with Figure 18 The steps shown are explained.
[0234] In step 601 , the server encodes the video title of the sample video through the first encoding layer of the hierarchical classification model to obtain a corresponding sentence semantic vector.
[0235] In actual implementation, the semantic encoding of video title sentences can be completed using various methods such as CNN and LSTM. Figure 17 , L1_emb = Bert (sentence), where the encoding model for the sentence (content sample) can be completed using Bert, and the sentence uses the semantic vector corresponding to the (CLS) token.
[0236] Step 602: Classify and predict the sentence semantic vectors through the first output layer of the hierarchical classification model to obtain the prediction results corresponding to the first-level categories of the sample video.
[0237] In actual implementation, the semantic vector corresponding to the CLS obtained in step 601 is classified through the output layer of the hierarchical classification model to obtain the predicted category classification result A = [a1, a2, ..., an] corresponding to the first-level category of the content sample, where ai represents the probability value of the first-level category being predicted to be the i-th category.
[0238] Step 603 : Encode the keywords corresponding to the secondary categories included in the primary category through the second encoding layer of the hierarchical classification model to obtain a representation vector of each secondary category.
[0239] In actual implementation, cls_i is used to represent each secondary category. The specific expression of cls_i is as follows: cls_i = avg_pooling([w1, w2, ..., wk]), where cls_i is the representation vector of the i-th secondary category, and [w1, w2, ..., wk] are the k keywords corresponding to the secondary category. cls2_i = avg_pooling([v1, v2, ..., vk]), [v1, v2, ..., vk] is the semantic vector corresponding to the keyword table, which comes from the word vector obtained based on general expectation training. Vi is the keyword extracted for each secondary category based on the chi-square statistical method. The semantic vectors of all keywords are based on the word vectors obtained through general corpus training. The semantic vectors of all keywords in each secondary category are averaged to obtain the semantic expression of the corresponding secondary category, that is, the representation vector of the secondary category.
[0240] Step 604 : Through the vector fusion layer of the hierarchical classification model, the representation vectors of each secondary category are fused with the primary semantic vector to obtain a fusion result.
[0241] In actual implementation, each secondary category vector cls_i and the first-level semantic vector L1_emb are fused (that is, the multi-order feature fusion process) to obtain a fused feature vector.
[0242] The fusion method is explained. The fusion here can be understood as multi-stage fusion. The specific multi-stage fusion formula is as follows:
[0243]
[0244] From the above formula, we can see that the entire fusion module consists of two parts, namely, the first-order fusion method and the second-order fusion method. ∈Rm*d is the word semantic vector table of the secondary category, m is the number of secondary categories, d is the word vector dimension, generally 200 to 500, W is the parameter matrix of the fusion module, l1_emb*w [1:d] *e_emb constitutes the second-order fusion feature, where d is the output vector dimension. V[l1_emb:e_emb] is a first-order fusion method, which mixes the first and second order fusion features to obtain the target fusion vector.
[0245] For example, assuming l1_emb is 1*p dimension, e_emb is q*1, and W is a three-dimensional tensor of p*q*d, the obtained l1_emb*w [1:d]*e_emb is a 1*d dimensional output vector. V[l1_emb:e_emb] is the concatenation of l1_emb and e_emb to obtain a (p+q)*1 vector. V is a d*(p+q) dimensional vector, so the resulting V[l1_emb:e_emb] is a 1*d dimensional output vector.
[0246] Step 605 : Perform secondary category prediction based on the fusion result through the second output layer of the hierarchical classification model to obtain a predicted secondary category distribution.
[0247] In actual implementation, the logits obtained in step 604 are connected to the softmax output to obtain the predicted secondary category distribution, that is, the probability value belonging to each secondary category is obtained, and the secondary category with the highest probability value is selected as the target secondary category of the video content.
[0248] During the training process of the hierarchical classification model, the entire hierarchical classification model can be reconciled by summing the multi-task loss weights. The loss function formula is as follows:
[0249]
[0250]
[0251]
[0252] loss = λ1loss cls1 +λ2loss cls2 +λ3loss h (4)
[0253] The formula
[0254] (1) is the loss function for first-level category classification, and n is the number of first-level categories.
[0255] (2) is the loss function of the secondary category, and m is the number of secondary categories
[0256] (3) is the newly added part, which is used to constrain the consistency of the first and second level categories. λ is a hyperparameter greater than 0. This formula is used to constrain the second level category. Penalty will only occur when the first level category is larger than the second level category.
[0257] In the formula, λ+l2_score-l1_score means that the predicted first-level category score l1_score is always expected to be larger than the corresponding second-level category l2_score. If λ+l2_score-l1_score <= 0, that is, l1_score is larger than l2_score by λ, then loss h =0, no loss occurs;
[0258] On the contrary, if λ+l2_score-l1_score>0, a loss will occur. Because the model is oriented to reduce the loss, the difference between l1_score and l2_score will eventually be at least λ.
[0259] (4) is the total loss function for training the hierarchical classification model. The loss function loss consists of three parts, among which the first-level category uses the negative logarithmic loss function as the loss function loss cls1 , the final result of the secondary classification also uses the negative logarithmic loss function as the loss function loss cls2 In order to ensure the consistency of the two-level classification results, a hinge loss structure loss is added h . To illustrate consistency, for example, the prediction result of the first-level category is game, and the prediction result of the second-level category is sports_news. This is the phenomenon of inconsistent results of the two-level classification. The so-called consistency is to ensure that the predicted second-level category must belong to the corresponding first-level category. Assuming that the upper-level categories are always easy to fine-grained lower-level classification results, that is, the difficulty of fine-grained classification should be greater, the hinge loss function is added to ensure that the probability of the first-level classification should always be greater than the corresponding second-level classification result. Among them, the principle of the hinge loss function to ensure consistency is: the prediction score (score) of the first-level category is always kept larger than the prediction score of the corresponding second-level category. For the specific formula, see loss h In other words, the second-level category under the first-level category will only appear if the first-level prediction score is high enough.
[0260] By iteratively executing the above steps 601 to 605, the hierarchical classification model is trained until the hierarchical classification model converges to obtain a trained hierarchical classification model. In summary, the hierarchical classification model provided in the embodiment of the present application is a hierarchical classification model based on a multi-order feature fusion method of category keywords. In the secondary classification process, the final score of each secondary category is obtained by using the sentence semantic vector and the secondary category word vector based on the vector fusion method. Among them, the semantic vectors of each secondary category corresponding to the first-level category are expressed by the keyword vectors of each secondary category, the keywords are obtained by chi-square statistics, and the semantic vectors of the keywords are obtained based on general corpus training.
[0261] It should be noted that BERT is used as the encoding method for sentences in the embodiment of the present application, and other encoding methods can also be replaced; the weight sum method is used as the final loss function of the task in the embodiment of the present application, and other loss function reconciliation methods can also be replaced. The embodiment of the present application does not limit the above methods.
[0262] In practical applications, the trained hierarchical classification model provided in the embodiment of the present application can be applied to various business scenarios that require extracting document categories, such as content classification in search, product title classification in e-commerce systems, etc. Figure 19 , Figure 19 This is a schematic diagram of a video classification method based on a classification model provided in an embodiment of the present application. Taking the prediction of the primary category and the corresponding secondary category of a video to be classified as an example, the application of the hierarchical classification model in an embodiment of the present application is explained. The secondary category prediction process for a video to be classified V is as follows:
[0263] In step 701, the server encodes the video title of the video to be classified through a hierarchical classification model to obtain a sentence semantic vector, and predicts the first-level category corresponding to the video to be classified based on the sentence semantic vector.
[0264] Step 702 : Using a hierarchical classification model, the sentence semantic vector is fused with the representation vectors of the second-level categories included in the first-level categories to obtain a fused vector.
[0265] The representation vector of each secondary category is obtained by averaging the word vectors of multiple keywords of the secondary category, that is, the average vector of the keywords.
[0266] Step 703 : Using a hierarchical classification model, a secondary category is predicted based on the fusion vector as the secondary category of the video to be classified.
[0267] The application of the embodiments of the present application has the following beneficial effects:
[0268] (1) The embodiment of the present application proposes a hierarchical classification model based on a vector fusion mechanism (match) of category keywords. In the secondary classification process, the final score of each secondary category is obtained by fusion of sentence semantic vectors and secondary category word vectors.
[0269] (2) All keywords are obtained based on the data of the secondary categories based on the chi-square statistics to obtain the keywords of each category, and then the word vectors obtained based on the general corpus training are obtained, and finally the final secondary category semantic vectors are obtained through the average pooling operation.
[0270] (3) The difference between the first-level and second-level classification results is introduced into the loss function to constrain the consistency of multi-level category results, effectively utilizing the upper and lower level constraint relationship of the category system.
[0271] In the embodiments of the present application, user information and other related data are involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0272] The following continues to describe the exemplary structure of the object classification processing device 555 based on the classification model provided in the embodiment of the present application implemented as a software module. In some embodiments, such as Figure 2A As shown, the software modules stored in the classification model-based object classification device 555 of the memory 550 may include:
[0273] The encoding module 5551 is used to obtain the media text associated with the object to be classified, and perform vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text;
[0274] A first classification module 5552 is configured to perform a first-level classification on the object to be classified based on the text vector using the first classification layer of the classification model to obtain a target first-level category to which the object to be classified belongs in a category system; wherein the category system includes at least two first-level categories and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword;
[0275] The second classification module 5553 is used to perform secondary classification on the object to be classified based on the text vector and the representation vector of each secondary category through the second classification layer of the classification model, and obtain the target secondary category to which the object to be classified belongs; wherein, the representation vector is determined based on the keywords included in the corresponding secondary category, and the target secondary category belongs to the target first-level category.
[0276] In some embodiments, the second classification layer includes a fusion sublayer and a classification sublayer, and the second classification module is further used to fuse the text vector and the representation vector of each of the secondary categories through the fusion sublayer to obtain a vector fusion result; and to perform secondary classification on the object to be classified based on the fusion result through the classification sublayer to obtain the target secondary category to which the object to be classified belongs.
[0277] In some embodiments, the second classification module is further used to obtain a dimension vector for first-order vector fusion, and through the fusion sublayer, based on the dimension vector, perform first-order fusion on the text vector and the representation vectors of each of the secondary categories to obtain a first-order fusion result; obtain second-order fusion parameters for second-order vector fusion, and through the fusion sublayer, perform second-order vector fusion on the text vector and the representation vectors of each of the secondary categories based on the second-order fusion parameters to obtain a second-order fusion result; through the fusion sublayer, fuse the first-order fusion result and the second-order fusion result to obtain the vector fusion result.
[0278] In some embodiments, the second classification module is also used to obtain a parameter matrix for vector fusion; through the fusion sublayer, based on the parameter matrix and the quadratic operation structure, the text vector and the representation vector of each secondary category are fused to obtain a vector fusion result.
[0279] In some embodiments, the second classification module is further used to perform vector splicing on the text vector and the representation vectors of each of the secondary categories to obtain a spliced vector; obtain a dimension vector for vector fusion, and multiply the spliced vector and the dimension vector to obtain the vector fusion result.
[0280] In some embodiments, before the first classification layer of the classification model performs the first-level classification on the object to be classified based on the text vector, the acquisition module is also used to obtain the keywords included in each of the secondary categories in the category system; for each of the secondary categories, each keyword included in the secondary category is encoded separately to obtain the keyword vector corresponding to each keyword; the keyword vector corresponding to the keyword included in each of the secondary categories is subjected to target vector operation to obtain the representation vector of the corresponding secondary category.
[0281] In some embodiments, the acquisition module is also used to, for each of the secondary categories, when the number of keywords included in the secondary category reaches a quantity threshold, perform vector averaging on the keyword vectors corresponding to the keywords included in the secondary category to obtain the representation vector of the secondary category; for each of the secondary categories, when the number of keywords included in the secondary category does not reach the quantity threshold, perform vector summation on the keyword vectors corresponding to the keywords included in the secondary category to obtain the representation vector of the secondary category.
[0282] In some embodiments, the acquisition module is also used to extract keywords from the media text to obtain at least one media keyword included in the media text; accordingly, through the encoding layer of the classification model, each media keyword included in the media text is vector encoded to obtain a word vector corresponding to each media keyword; and vector splicing is performed on each obtained word vector to obtain a text vector corresponding to the media text.
[0283] In some embodiments, the first classification module is further used to obtain the at least two first-level categories included in the category system; through the first classification layer of the classification model, based on the text vector and at least two first-level categories, the object to be classified is multi-classified into the at least two first-level categories to obtain the probability that the object to be classified belongs to each of the first-level categories; and the first-level category corresponding to the maximum probability is used as the target first-level category to which the object to be classified belongs.
[0284] In some embodiments, the object classification device based on the classification model also includes a training module, which is used to obtain a media text sample associated with the object sample to be classified, and the media text sample carries a first-level category label and a second-level category label; through the encoding layer, the media text sample is vector encoded to obtain a target text vector corresponding to the media text sample; through the first classification layer, the object sample to be classified is first-level classified based on the target text vector to obtain a first-level classification result, and the first-level classification result is used to indicate the first-level category to which the object sample to be classified belongs; through the second classification layer, the object sample to be classified is second-level classified based on the target text vector and the representation vector of each of the second-level categories to obtain a second-level classification result, and the second-level classification result is used to indicate the second-level category to which the object sample to be classified belongs; obtain a first difference between the first-level category label and the first-level classification result, and a second difference between the second-level category label and the second-level classification result, and update the model parameters of the classification model based on the first difference and the second difference.
[0285] In some embodiments, the training module is also used to obtain a first loss function corresponding to the first classification layer, a second loss function corresponding to the second classification layer, and a constraint function; based on the first loss function, the second loss function and the constraint function, the loss function of the classification model is constructed; wherein the constraint function is used to ensure that the secondary category indicated by the secondary classification result is a subcategory of the primary category indicated by the primary classification result; based on the first difference and the second difference, the value of the loss function of the classification model is determined, and based on the value of the loss function of the classification model, the model parameters of the classification model are updated.
[0286] In some embodiments, as Figure 2B As shown, the software modules stored in the classification model training device 556 of the memory 550 may include:
[0287] An acquisition module 5561 is configured to acquire a media text sample associated with an object sample to be classified, wherein the media text sample carries a primary category label and a secondary category label;
[0288] A vector encoding module 5562 is configured to perform vector encoding on the media text sample through the encoding layer of the classification model to obtain a target text vector corresponding to the media text sample;
[0289] A primary classification module 5563 is configured to perform primary classification on the object sample to be classified based on the target text vector using the first classification layer of the classification model to obtain a primary category to which the object sample to be classified belongs in a category system; wherein the category system includes at least two primary categories and a plurality of secondary categories obtained by dividing the at least two primary categories, each of the secondary categories including at least one keyword;
[0290] A secondary classification module 5564 is configured to perform secondary classification on the object sample to be classified based on the target text vector and the representation vectors of each of the secondary categories using the second classification layer of the classification model, thereby obtaining the secondary category to which the object sample to be classified belongs; wherein the representation vector is determined based on the keywords included in the corresponding secondary category, and the secondary category to which the object sample to be classified belongs is a subcategory of the primary category to which the object to be classified belongs;
[0291] The updating module 5565 is used to obtain a first difference between the first-level category label and the first-level category to which the sample of the object to be classified belongs, and a second difference between the second-level category label and the second-level category to which the sample of the object to be classified belongs, and update the model parameters of the classification model based on the first difference and the second difference.
[0292] The present invention provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the object classification method based on the classification model described in the present invention.
[0293] The embodiment of the present application provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the object classification method based on the classification model provided by the embodiment of the present application, for example, Figure 3 The object classification method based on the classification model is shown.
[0294] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or various devices including one or any combination of the above memories.
[0295] In some embodiments, executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0296] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinating files (e.g., files storing one or more modules, subroutines, or code portions).
[0297] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0298] To sum up, through the embodiment of the present application, the target secondary category will be determined based on the vector fusion method of the sentence semantic vector and the representation vector of the secondary category during the secondary classification process; all keywords are based on the data of the secondary category based on the chi-square statistics to obtain the keywords of each category, and then the word vector obtained based on the general corpus training is obtained, and finally the final secondary category semantic vector is obtained through the average pooling operation; the difference value of the primary and secondary classification results is introduced into the loss function to constrain the consistency of the multi-level category results, which effectively utilizes the upper and lower level constraint relationship of the category system, and the classification model completed by training has a high accuracy rate.
[0299] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the scope of protection of the present application.
Claims
1. An object classification method based on a classification model, characterized in that: The method comprises: Acquire media text associated with the object to be classified, and perform vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text; Performing a first-level classification on the object to be classified based on the text vector through the first classification layer of the classification model to obtain a target first-level category to which the object to be classified belongs in the category system; The category system includes: at least two first-level categories, and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword; For each of the secondary categories, respectively encode each keyword included in the secondary category in the category system to obtain a keyword vector corresponding to each keyword; For each of the secondary categories, when the number of keywords included in the secondary category reaches a quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector averaged to obtain a representation vector of the secondary category; when the number of keywords included in the secondary category does not reach the quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector summed to obtain a representation vector of the secondary category; Through the second classification layer of the classification model, the object to be classified is secondarily classified based on the text vector and the representation vector of each of the second-level categories to obtain the target second-level category to which the object to be classified belongs; the target second-level category belongs to the target first-level category.
2. The method according to claim 1, wherein The second classification layer includes a fusion sublayer and a classification sublayer. The second classification layer of the classification model performs secondary classification on the object to be classified based on the text vector and the representation vector of each secondary category to obtain the target secondary category to which the object to be classified belongs, including: The text vector and the representation vectors of each of the secondary categories are fused through the fusion sublayer to obtain a vector fusion result; Through the classification sublayer, the object to be classified is subjected to secondary classification based on the fusion result to obtain the target secondary category to which the object to be classified belongs.
3. The method according to claim 2, wherein The text vector and the representation vectors of each of the secondary categories are fused through the fusion sublayer to obtain a vector fusion result, including: Obtaining a dimension vector for first-order vector fusion, and performing first-order fusion on the text vector and the representation vectors of each of the secondary categories based on the dimension vector through the fusion sublayer to obtain a first-order fusion result; Obtaining a second-order fusion parameter for second-order vector fusion, and performing second-order vector fusion on the text vector and the representation vectors of each of the secondary categories based on the second-order fusion parameter through the fusion sublayer to obtain a second-order fusion result; The first-order fusion result and the second-order fusion result are fused through the fusion sublayer to obtain the vector fusion result.
4. The method according to claim 2, wherein The text vector and the representation vectors of each of the secondary categories are fused through the fusion sublayer to obtain a vector fusion result, including: Get the parameter matrix for vector fusion; Through the fusion sublayer, based on the parameter matrix and the quadratic operation structure, the text vector and the representation vectors of each secondary category are fused to obtain a vector fusion result.
5. The method according to claim 2, wherein The text vector and the representation vectors of each of the secondary categories are fused through the fusion sublayer to obtain a vector fusion result, including: Performing vector splicing on the text vector and the representation vectors of each of the secondary categories to obtain a spliced vector; A dimension vector for vector fusion is obtained, and the splicing vector and the dimension vector are multiplied to obtain the vector fusion result.
6. The method according to claim 1, wherein After obtaining the media text associated with the object to be classified, the method further includes: Performing keyword extraction on the media text to obtain at least one media keyword included in the media text; The step of performing vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text includes: Performing vector encoding on each media keyword included in the media text through the encoding layer of the classification model to obtain a word vector corresponding to each media keyword; Perform vector concatenation on the obtained word vectors to obtain a text vector corresponding to the media text.
7. The method according to claim 1, wherein The first classification layer of the classification model is used to perform a first-level classification on the object to be classified based on the text vector to obtain a target first-level category to which the object to be classified belongs in the category system, including: Obtaining the at least two first-level categories included in the category system; performing, by the first classification layer of the classification model, multi-classification of the object to be classified into the at least two first-level categories based on the text vector and the at least two first-level categories, and obtaining a probability that the object to be classified belongs to each of the first-level categories; The first-level category corresponding to the maximum probability is used as the target first-level category to which the object to be classified belongs.
8. The method according to claim 1, wherein Before performing vector encoding on the media text through the encoding layer of the classification model, the method further includes: Obtaining a media text sample associated with the object sample to be classified, wherein the media text sample carries a first-level category label and a second-level category label; Performing vector encoding on the media text sample through the encoding layer to obtain a target text vector corresponding to the media text sample; Performing a first-level classification on the object sample to be classified based on the target text vector through the first classification layer to obtain a first-level classification result, wherein the first-level classification result is used to indicate the first-level category to which the object sample to be classified belongs; Performing secondary classification on the object sample to be classified based on the target text vector and the representation vectors of each of the secondary categories through the second classification layer to obtain a secondary classification result, wherein the secondary classification result is used to indicate the secondary category to which the object sample to be classified belongs; A first difference between the first-level category label and the first-level classification result, and a second difference between the second-level category label and the second-level classification result are obtained, and model parameters of the classification model are updated based on the first difference and the second difference.
9. The method according to claim 8, wherein The updating of the model parameters of the classification model based on the first difference and the second difference includes: Obtain a first loss function corresponding to the first classification layer, a second loss function corresponding to the second classification layer, and a constraint function; Constructing a loss function of the classification model based on the first loss function, the second loss function and the constraint function; The constraint function is used to ensure that the secondary category indicated by the secondary classification result is a subcategory of the primary category indicated by the primary classification result; A value of a loss function of the classification model is determined based on the first difference and the second difference, and a model parameter of the classification model is updated based on the value of the loss function of the classification model.
10. A classification model training method, characterized in that: The method comprises: Obtaining a media text sample associated with the object sample to be classified, wherein the media text sample carries a first-level category label and a second-level category label; Performing vector encoding on the media text sample through the encoding layer of the classification model to obtain a target text vector corresponding to the media text sample; Performing a first-level classification on the object sample to be classified based on the target text vector through the first classification layer of the classification model to obtain a first-level category to which the object sample to be classified belongs in the category system; The category system includes: at least two first-level categories, and a plurality of second-level categories obtained by dividing the at least two first-level categories, each of the second-level categories including at least one keyword; For each of the secondary categories, respectively encode each keyword included in the secondary category in the category system to obtain a keyword vector corresponding to each keyword; For each of the secondary categories, when the number of keywords included in the secondary category reaches a quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector averaged to obtain a representation vector of the secondary category; when the number of keywords included in the secondary category does not reach the quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector summed to obtain a representation vector of the secondary category; performing secondary classification on the object sample to be classified based on the target text vector and the representation vectors of each of the secondary categories through the second classification layer of the classification model to obtain the secondary category to which the object sample to be classified belongs; the secondary category to which the object sample to be classified belongs is a subcategory of the primary category to which the object to be classified belongs; Obtain a first difference between the first-level category label and the first-level category to which the sample of the object to be classified belongs, and a second difference between the second-level category label and the second-level category to which the sample of the object to be classified belongs, and update the model parameters of the classification model based on the first difference and the second difference.
11. An object classification device based on a classification model, characterized in that: The device comprises: An encoding module, configured to obtain media text associated with the media information, and perform vector encoding on the media text through the encoding layer of the classification model to obtain a text vector corresponding to the media text; a first classification module configured to perform a primary classification on the media information based on the text vector using a first classification layer of the classification model to obtain a target primary category to which the media information belongs in a category system; wherein the category system includes at least two primary categories and a plurality of secondary categories obtained by dividing the at least two primary categories, each of the secondary categories including at least one keyword; The second classification module is used to encode each keyword included in the secondary category in the category system for each of the secondary categories, and obtain the keyword vector corresponding to each keyword; for each of the secondary categories, when the number of keywords included in the secondary category reaches a quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector-averaged to obtain the representation vector of the secondary category; when the number of keywords included in the secondary category does not reach the quantity threshold, the keyword vectors corresponding to the keywords included in the secondary category are vector-summed to obtain the representation vector of the secondary category; through the second classification layer of the classification model, the media information is secondarily classified based on the text vector and the representation vector of each of the secondary categories to obtain the target secondary category to which the media information belongs; the target secondary category belongs to the target primary category.
12. The device according to claim 11, characterized in that The second classification layer includes a fusion sublayer and a classification sublayer, and the second classification module is further configured to: The text vector and the representation vectors of each of the secondary categories are fused through the fusion sublayer to obtain a vector fusion result; Through the classification sublayer, the object to be classified is subjected to secondary classification based on the fusion result to obtain the target secondary category to which the object to be classified belongs.
13. An electronic device, characterized in that: The electronic device comprises: a memory for storing executable instructions; A processor, configured to implement the object classification method based on the classification model according to any one of claims 1 to 10 when executing the executable instructions stored in the memory.
14. A computer-readable storage medium storing executable instructions, characterized in that: When the executable instructions are executed by a processor, the object classification method based on the classification model according to any one of claims 1 to 10 is implemented.
15. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the object classification method based on the classification model according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Content classification method and device, computer equipment and storage medium
CN110737801A
Text classification method and device, computer equipment and storage medium
CN111090719A