CN117312979A - Object classification method, classification model training method and electronic equipment - Google Patents
Object classification method, classification model training method and electronic equipment Download PDFInfo
- Publication number
- CN117312979A CN117312979A CN202311065380.2A CN202311065380A CN117312979A CN 117312979 A CN117312979 A CN 117312979A CN 202311065380 A CN202311065380 A CN 202311065380A CN 117312979 A CN117312979 A CN 117312979A
- Authority
- CN
- China
- Prior art keywords
- category
- sample
- information
- classification
- level
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000013145 classification model Methods 0.000 title claims abstract description 121
- 238000000034 method Methods 0.000 title claims abstract description 89
- 238000012549 training Methods 0.000 title claims abstract description 63
- 238000012545 processing Methods 0.000 claims abstract description 75
- 230000015654 memory Effects 0.000 claims description 28
- 238000007499 fusion processing Methods 0.000 claims description 21
- 230000008569 process Effects 0.000 claims description 20
- 238000004364 calculation method Methods 0.000 claims description 15
- 238000010606 normalization Methods 0.000 claims description 11
- 238000012216 screening Methods 0.000 claims description 2
- 238000000605 extraction Methods 0.000 description 22
- 230000006870 function Effects 0.000 description 21
- 239000013598 vector Substances 0.000 description 14
- 230000000694 effects Effects 0.000 description 11
- 238000012360 testing method Methods 0.000 description 10
- 238000004590 computer program Methods 0.000 description 9
- 235000013305 food Nutrition 0.000 description 9
- 238000010586 diagram Methods 0.000 description 8
- 238000013473 artificial intelligence Methods 0.000 description 7
- 238000013528 artificial neural network Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 238000010801 machine learning Methods 0.000 description 5
- 239000011159 matrix material Substances 0.000 description 5
- 238000013527 convolutional neural network Methods 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 2
- 230000004927 fusion Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- 241000282412 Homo Species 0.000 description 1
- 241001465754 Metazoa Species 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000000052 comparative effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000004069 differentiation Effects 0.000 description 1
- 235000013399 edible fruits Nutrition 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 210000002569 neuron Anatomy 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008447 perception Effects 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 235000013311 vegetables Nutrition 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
- G06F18/2415—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/25—Fusion techniques
- G06F18/253—Fusion techniques of extracted features
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/084—Backpropagation, e.g. using gradient descent
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/09—Supervised learning
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Molecular Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Computational Biology (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Evolutionary Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域Technical field
本申请涉及人工智能技术,尤其涉及一种对象分类方法、分类模型训练方法、装置、电子设备及计算机可读存储介质。The present application relates to artificial intelligence technology, and in particular, to an object classification method, a classification model training method, a device, an electronic device, and a computer-readable storage medium.
背景技术Background technique
类目系统是为了高效分辨和应用特定对象所创建的,类目系统包括多个类目层级,每个类目层级包括若干个类目。类目系统常见于电商平台,通过确定各个商品所属的类目,能够帮助平台更好地进行站内商品维护和管理。The category system is created to efficiently identify and apply specific objects. The category system includes multiple category levels, and each category level includes several categories. Category systems are common on e-commerce platforms. By determining the categories to which each product belongs, it can help the platform better maintain and manage the products on the site.
对于商品所属的类目,在相关技术提供的方案中,通常是将商品的文本信息与最后一个类目层级进行文本匹配,从而确定商品在最后一个类目层级所属的类目。然而,发明人经过研究发现,由于类目系统本身庞大且错综复杂,依靠最后一个类目层级进行分类的准确性低,很容易将商品划分到错误的类目。As for the category to which the product belongs, in the solution provided by the relevant technology, the text information of the product is usually matched with the last category level to determine the category to which the product belongs at the last category level. However, after research, the inventor found that because the category system itself is large and complex, the accuracy of classification based on the last category level is low, and it is easy to classify products into the wrong category.
发明内容Contents of the invention
本申请实施例提供一种对象分类方法、分类模型训练方法、装置、电子设备及计算机可读存储介质,能够综合考虑多个类目层级的情况,提升分类模型的训练效果,进而提升分类精度。Embodiments of the present application provide an object classification method, a classification model training method, a device, an electronic device, and a computer-readable storage medium, which can comprehensively consider the situation of multiple category levels, improve the training effect of the classification model, and thereby improve the classification accuracy.
本申请实施例的技术方案是这样实现的:The technical solution of the embodiment of this application is implemented as follows:
本申请实施例提供一种对象分类方法,包括:The embodiment of the present application provides an object classification method, including:
获取预设类目信息及待测对象的待测描述信息;其中,所述预设类目信息包括多个类目层级的预设类目;Obtain preset category information and test description information of the object to be tested; wherein the preset category information includes preset categories at multiple category levels;
通过分类模型基于所述待测描述信息及所述预设类目信息进行逐层级分类处理,得到所述待测对象在所述多个类目层级的分类结果;The classification model performs level-by-level classification processing based on the description information to be tested and the preset category information to obtain classification results of the object to be tested at the multiple category levels;
根据所述待测对象在所述多个类目层级的分类结果,确定所述待测对象在所述多个类目层级的目标类目。According to the classification results of the object to be tested at the plurality of category levels, the target category of the object to be tested at the plurality of category levels is determined.
通过上述方案,利用训练后的分类模型对待测对象实现多层级分类,相较于仅依靠最后一个类目层级进行分类的方案,能够综合考虑各个类目层级,有效提升分类精度。Through the above solution, the trained classification model is used to achieve multi-level classification of the object to be tested. Compared with the solution that only relies on the last category level for classification, each category level can be comprehensively considered, effectively improving the classification accuracy.
在上述方案中,还包括:In the above scheme, it also includes:
针对任意一个类目层级,执行以下处理:For any category level, perform the following processing:
根据所述任意一个类目层级的前一个类目层级的分类结果,对所述任意一个类目层级的多个预设类目进行筛选处理;Perform screening processing on multiple preset categories of any one category level according to the classification results of the previous category level of any one category level;
根据筛选出的预设类目更新所述预设类目信息。Update the preset category information according to the filtered preset category.
通过上述方案,根据已有的分类结果对预设类目信息进行更新,如此,能够符合类目系统的规则,提升分类的准确性和合理性,同时减少计算量。Through the above solution, the preset category information is updated based on the existing classification results. In this way, it can comply with the rules of the category system, improve the accuracy and rationality of classification, and reduce the amount of calculation.
在上述方案中,所述通过分类模型基于所述待测描述信息及所述预设类目信息进行逐层级分类处理,得到所述待测对象在所述多个类目层级的分类结果,包括:In the above solution, the classification model performs level-by-level classification processing based on the description information to be tested and the preset category information to obtain classification results of the object to be tested at the multiple category levels, include:
通过所述分类模型执行以下处理:The following processing is performed by the classification model:
从所述待测描述信息中提取待测描述特征,从所述预设类目信息包括的预设类目中提取预设类目特征;Extract description features to be tested from the description information to be tested, and extract preset category features from the preset categories included in the preset category information;
根据所述待测描述特征及所述预设类目特征,计算所述待测对象属于所述预设类目特征对应预设类目的概率;Calculate the probability that the object to be tested belongs to the preset category corresponding to the preset category feature according to the description feature to be tested and the preset category feature;
针对任意一个类目层级,将所述待测对象分别属于所述任意一个类目层级的多个预设类目的概率,确定为所述待测对象在所述任意一个类目层级的分类结果。For any category level, the probability that the object to be tested belongs to multiple preset categories of the any category level is determined as the classification result of the object to be tested at the any category level. .
通过上述方案,能够基于学习到的特征关联,来预测待测对象属于预设类目的概率,保证得到的概率的准确性。Through the above solution, the probability that the object to be tested belongs to the preset category can be predicted based on the learned feature association, ensuring the accuracy of the obtained probability.
本申请实施例提供一种分类模型训练方法,包括:The embodiment of the present application provides a classification model training method, including:
获取样本对象的样本描述信息及样本类目信息;所述样本类目信息包括所述样本对象在多个类目层级的样本类目;Obtain sample description information and sample category information of the sample object; the sample category information includes sample categories of the sample object at multiple category levels;
通过分类模型基于所述样本描述信息及所述样本类目信息进行逐层级分类处理,得到在所述多个类目层级的分类结果;The classification model performs level-by-level classification processing based on the sample description information and the sample category information to obtain classification results at the multiple category levels;
根据同一类目层级的样本类目及分类结果进行损失计算得到层级损失,对所述多个类目层级分别对应的层级损失进行多层级融合处理得到多层级损失;Perform loss calculation according to the sample categories and classification results of the same category level to obtain hierarchical loss, and perform multi-level fusion processing on the hierarchical losses corresponding to the multiple category levels to obtain multi-level loss;
根据所述多层级损失训练所述分类模型;其中,训练后的所述分类模型用于预测待测对象在所述多个类目层级的分类结果。The classification model is trained according to the multi-level loss; wherein the trained classification model is used to predict the classification results of the object to be tested at the multiple category levels.
通过上述方案,综合考虑多个类目层级分别对应的层级损失,能够提升对分类模型的训练效果,使得训练后的分类模型具有多层级分类的能力,而不再仅仅依靠最后一个类目层级,能够有效提升分类精度。Through the above solution, comprehensive consideration of the hierarchical losses corresponding to multiple category levels can improve the training effect of the classification model, so that the trained classification model has the ability to classify at multiple levels, instead of just relying on the last category level. It can effectively improve classification accuracy.
在上述方案中,所述通过分类模型基于所述样本描述信息及所述样本类目信息进行逐层级分类处理,得到在所述多个类目层级的分类结果,包括:In the above solution, the classification model performs level-by-level classification processing based on the sample description information and the sample category information to obtain classification results at the multiple category levels, including:
通过所述分类模型执行以下处理:The following processing is performed by the classification model:
从所述样本描述信息中提取样本描述特征,从所述样本类目信息中提取样本类目特征;Extract sample description features from the sample description information, and extract sample category features from the sample category information;
针对任意一个类目层级,根据所述样本描述特征及所述样本类目特征计算在所述任意一个类目层级的类目概率分布,以作为在所述任意一个类目层级的分类结果。For any category level, calculate the category probability distribution at the any category level based on the sample description features and the sample category features as a classification result at the any category level.
通过上述方案,提供了逐层级分类的一种实现方式,即从输入信息中提取特征来预测每个类目层级的类目概率分布,能够适应于每个类目层级的情况。Through the above solution, an implementation method of level-by-level classification is provided, that is, extracting features from the input information to predict the category probability distribution of each category level, which can be adapted to the situation of each category level.
在上述方案中,所述从所述样本描述信息中提取样本描述特征,从所述样本类目信息中提取样本类目特征之后,所述方法还包括:In the above solution, after extracting sample description features from the sample description information and extracting sample category features from the sample category information, the method further includes:
对所述样本描述特征及所述样本类目特征进行线性投射处理;Perform linear projection processing on the sample description features and the sample category features;
对线性投射后的所述样本描述特征及所述样本类目特征进行归一化处理。The sample description features and the sample category features after linear projection are normalized.
通过上述方案,以线性投射方式将样本描述特征及所述样本类目特征在维度上调整为一致,以归一化方式将样本描述特征及所述样本类目特征在度量上调整为一致,能够加强特征之间的可比性,强化学习效果。Through the above solution, the sample description characteristics and the sample category characteristics are adjusted to be consistent in dimension by linear projection, and the sample description characteristics and the sample category characteristics are adjusted to be consistent in measurement by normalization method, which can Strengthen the comparability between features and enhance the learning effect.
在上述方案中,所述样本描述信息包括多个模态的描述信息;所述从所述样本描述信息中提取样本描述特征,包括:In the above solution, the sample description information includes description information of multiple modalities; and extracting sample description features from the sample description information includes:
从每个模态的描述信息中提取模态描述特征;Extract modal description features from the description information of each modality;
对所述多个模态分别对应的模态描述特征进行特征融合处理,得到样本描述特征。Feature fusion processing is performed on modal description features corresponding to the plurality of modalities to obtain sample description features.
通过上述方案,综合考虑与样本对象相关的多个模态的描述信息,能够提升信息的丰富度,进而提升分类模型的训练效果。Through the above solution, comprehensive consideration of the description information of multiple modalities related to the sample object can improve the richness of the information, thereby improving the training effect of the classification model.
在上述方案中,样本对象的数量包括多个;所述通过分类模型基于所述样本描述信息及所述样本类目信息进行逐层级分类处理,得到在所述多个类目层级的分类结果,包括:In the above solution, the number of sample objects includes multiple; the classification model performs level-by-level classification processing based on the sample description information and the sample category information to obtain classification results at the multiple category levels. ,include:
对多个样本描述信息及多个样本类目信息进行组合处理,得到多个信息组合;每个信息组合包括一个样本描述信息及一个样本类目信息;Combine multiple sample description information and multiple sample category information to obtain multiple information combinations; each information combination includes one sample description information and one sample category information;
通过所述分类模型基于信息组合进行逐层级分类处理,得到信息组合在所述多个类目层级的分类结果;The classification model performs level-by-level classification processing based on the information combination to obtain the classification results of the information combination at the multiple category levels;
所述根据同一类目层级的样本类目及分类结果进行损失计算得到层级损失,包括:The loss calculation based on the sample categories and classification results of the same category level results in hierarchical loss, including:
针对任意一个类目层级,执行以下处理:For any category level, perform the following processing:
根据信息组合对应的目标样本对象在所述任意一个类目层级的样本类目,确定信息组合在所述任意一个类目层级的类目标签;According to the sample category of the target sample object corresponding to the information combination at the any category level, determine the category target label of the information combination at the any category level;
确定信息组合在所述任意一个类目层级的类目标签与分类结果之间的差异,以作为信息组合损失;Determine the difference between the category label and the classification result of the information combination at any category level as the information combination loss;
对所述多个信息组合分别对应的信息组合损失进行信息组合融合处理,得到所述任意一个类目层级的层级损失。Information combination fusion processing is performed on the information combination losses corresponding to the multiple information combinations to obtain the hierarchical loss of any category level.
通过上述方案,基于对比学习的思路生成多个信息组合,能够提升训练数据的丰富程度,从而提升模型训练的效果。Through the above solution, multiple information combinations are generated based on the idea of comparative learning, which can increase the richness of training data and thereby improve the effect of model training.
在上述方案中,还包括:In the above scheme, it also includes:
当信息组合中的样本描述信息及样本类目信息对应同一样本对象时,将所述同一样本对象确定为信息组合对应的目标样本对象;When the sample description information and sample category information in the information combination correspond to the same sample object, determine the same sample object as the target sample object corresponding to the information combination;
当信息组合中的样本描述信息及样本类目信息对应不同样本对象时,将信息组合对应的目标样本对象确定为无对象;其中,所述无对象在所述任意一个类目层级的样本类目为无类目。When the sample description information and sample category information in the information combination correspond to different sample objects, the target sample object corresponding to the information combination is determined to be no object; wherein the no object is in the sample category of any category level There is no category.
通过上述方案,当信息组合中的样本描述信息及样本类目信息对应同一样本对象时,将该信息组合作为正样本;当信息组合中的样本描述信息及样本类目信息对应不同样本对象时,将该信息组合作为负样本。如此,准确有效地实现了训练数据的扩充。Through the above scheme, when the sample description information and sample category information in the information combination correspond to the same sample object, the information combination is used as a positive sample; when the sample description information and sample category information in the information combination correspond to different sample objects, Combine this information as negative samples. In this way, the expansion of training data is achieved accurately and effectively.
本申请实施例提供一种对象分类装置,包括:An embodiment of the present application provides an object classification device, including:
目标获取模块,用于获取预设类目信息及待测对象的待测描述信息;其中,所述预设类目信息包括多个类目层级中每个类目层级的预设类目;The target acquisition module is used to obtain preset category information and test description information of the object to be tested; wherein the preset category information includes a preset category for each category level in multiple category levels;
目标处理模块,用于通过分类模型基于所述待测描述信息及所述预设类目信息进行逐层级分类处理,得到所述待测对象在所述多个类目层级的分类结果;A target processing module, configured to perform level-by-level classification processing based on the description information to be tested and the preset category information through a classification model to obtain classification results of the object to be tested at the multiple category levels;
确定模块,用于根据所述待测对象在所述多个类目层级的分类结果,确定所述待测对象在所述多个类目层级的类目。A determining module, configured to determine the category of the object to be tested at the multiple category levels according to the classification results of the object to be tested at the multiple category levels.
本申请实施例提供一种分类模型训练装置,包括:An embodiment of the present application provides a classification model training device, including:
样本获取模块,用于获取样本对象的样本描述信息及样本类目信息;所述样本类目信息包括所述样本对象在多个类目层级的样本类目;A sample acquisition module is used to obtain sample description information and sample category information of a sample object; the sample category information includes sample categories of the sample object at multiple category levels;
样本处理模块,用于通过分类模型基于所述样本描述信息及所述样本类目信息进行逐层级分类处理,得到在所述多个类目层级的分类结果;A sample processing module, configured to perform level-by-level classification processing based on the sample description information and the sample category information through a classification model to obtain classification results at the multiple category levels;
损失计算模块,用于根据同一类目层级的样本类目及分类结果进行损失计算得到层级损失,对所述多个类目层级分别对应的层级损失进行多层级融合处理得到多层级损失;The loss calculation module is used to perform loss calculation according to the sample categories and classification results of the same category level to obtain the hierarchical loss, and perform multi-level fusion processing on the hierarchical losses corresponding to the multiple category levels to obtain the multi-level loss;
训练模块,用于根据所述多层级损失训练所述分类模型;其中,训练后的所述分类模型用于预测待测对象在所述多个类目层级的分类结果。A training module configured to train the classification model according to the multi-level loss; wherein the trained classification model is used to predict the classification results of the object to be tested at the multiple category levels.
本申请实施例提供一种电子设备,包括:An embodiment of the present application provides an electronic device, including:
存储器,用于存储可执行指令;Memory, used to store executable instructions;
处理器,用于执行所述存储器中存储的可执行指令时,实现本申请实施例提供的对象分类方法或分类模型训练方法。The processor is configured to implement the object classification method or classification model training method provided by the embodiments of the present application when executing executable instructions stored in the memory.
本申请实施例提供一种计算机可读存储介质,存储有可执行指令,用于引起处理器执行时,实现本申请实施例提供的对象分类方法或分类模型训练方法。Embodiments of the present application provide a computer-readable storage medium that stores executable instructions for causing the processor to implement the object classification method or classification model training method provided by the embodiments of the present application when executed.
本申请实施例提供了一种计算机程序产品,该计算机程序产品包括可执行指令,用于引起处理器执行时,实现本申请实施例提供的对象分类方法或分类模型训练方法。Embodiments of the present application provide a computer program product. The computer program product includes executable instructions for causing a processor to implement the object classification method or classification model training method provided by the embodiments of the present application when executed.
附图说明Description of the drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can also be obtained based on these drawings without exerting creative efforts.
图1是本申请实施例提供的分类系统的一个结构示意图;Figure 1 is a schematic structural diagram of a classification system provided by an embodiment of the present application;
图2A是本申请实施例提供的服务器的一个结构示意图;Figure 2A is a schematic structural diagram of a server provided by an embodiment of the present application;
图2B是本申请实施例提供的服务器的另一个结构示意图;Figure 2B is another schematic structural diagram of a server provided by an embodiment of the present application;
图3A是本申请实施例提供的分类模型训练方法的一个流程示意图;Figure 3A is a schematic flow chart of the classification model training method provided by the embodiment of the present application;
图3B是本申请实施例提供的分类模型训练方法的另一个流程示意图;Figure 3B is another schematic flow chart of the classification model training method provided by the embodiment of the present application;
图3C是本申请实施例提供的分类模型训练方法的另一个流程示意图;Figure 3C is another schematic flow chart of the classification model training method provided by the embodiment of the present application;
图4是本申请实施例提供的对象分类方法的一个流程示意图;Figure 4 is a schematic flow chart of the object classification method provided by the embodiment of the present application;
图5是本申请实施例提供的电商平台的商品展示示意图;Figure 5 is a schematic diagram of product display on the e-commerce platform provided by the embodiment of the present application;
图6是本申请实施例提供的构建特征组合矩阵的示意图。Figure 6 is a schematic diagram of constructing a feature combination matrix provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述,所描述的实施例不应视为对本申请的限制,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be described in further detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. Those of ordinary skill in the art will not make any All other embodiments obtained under the premise of creative work belong to the scope of protection of this application.
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。在以下的描述中,所涉及的术语“多个”是指至少两个。In the following description, references to "some embodiments" describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or a different subset of all possible embodiments, and Can be combined with each other without conflict. In the following description, the term "plurality" refers to at least two.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
对本申请实施例进行进一步详细说明之前,对本申请实施例中涉及的名词和术语进行说明,本申请实施例中涉及的名词和术语适用于如下的解释。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 applicable to the following explanations.
1)人工智能(Artificial Intelligence,AI):是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个综合技术,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。1) Artificial Intelligence (AI): It is the theory, method, technology and application of using digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. system. In other words, artificial intelligence is a comprehensive technology of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is the study of the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
机器学习(Machine Learning,ML)是人工智能的核心,是使计算机具有智能的根本途径,其应用遍及人工智能的各个领域。机器学习涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科,专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能。Machine Learning (ML) is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications cover all fields of artificial intelligence. Machine learning involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specializes in studying how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge. The structure enables it to continuously improve its performance.
在本申请实施例中,分类模型可以是人工神经网络模型,人工神经网络基于机器学习理论实现,是模仿生物神经元相互传递信号的方式。In this embodiment of the present application, the classification model may be an artificial neural network model. The artificial neural network is implemented based on machine learning theory and imitates the way biological neurons transmit signals to each other.
2)前向传播(Forward Propagation):指的是按照神经网络的网络层从左到右的顺序运行,一直运行至最后一层得到输出结果的过程。反向传播(Back Propagation)是指在输出结果与期望结果之间存在误差的情况下,对神经网络的网络层中的权重参数和偏移量进行更新,从而减少这种误差的过程。反向传播与前向传播在顺序上相反。2) Forward Propagation: refers to the process of running the network layers of the neural network from left to right, until the last layer gets the output result. Back propagation refers to the process of updating the weight parameters and offsets in the network layer of the neural network to reduce this error when there is an error between the output result and the expected result. Backpropagation is the reverse order of forward propagation.
3)类目系统:包括多个类目层级,每个类目层级包括若干个预设类目。以商品类目系统举例,则第一个类目层级可以包括“衣服”、“食品”等类目;对于“衣服”类目来说,更下一级(第二个类目层级)可以包括“上衣”、“裤子”等类目;对于“上衣”类目来说,更下一级(第三个类目层级)可以包括“T恤”、“羽绒服”等类目。3) Category system: includes multiple category levels, each category level includes several preset categories. Taking the product category system as an example, the first category level can include categories such as "clothing" and "food"; for the "clothing" category, the next level (the second category level) can include Categories such as "tops" and "pants"; for the category "tops", the next level (the third category level) can include categories such as "T-shirts" and "down jackets".
4)对象:指需要进行分类的对象,本申请实施例对对象的类型不做限定,可以是商品、车辆、人类、动物等。4) Object: refers to the object that needs to be classified. The embodiment of the present application does not limit the type of object, which can be commodities, vehicles, humans, animals, etc.
5)损失值(Loss):“损失”意味着模型因未能输出期望结果而受到的惩罚,损失函数通过比较模型的输出结果和期望结果来确定模型的性能,进而寻找优化方向,通过损失函数得到的值即为损失值。如果输出结果与期望结果二者之间的偏差非常大,则损失值会很大;如果偏差很小,则损失值会非常低。本申请实施例对损失函数的类型不做限定,例如可以是交叉熵损失函数、合页损失函数、负对数似然损失函数等。5) Loss value (Loss): "Loss" means the penalty received by the model for failing to output the expected results. The loss function determines the performance of the model by comparing the output results of the model with the expected results, and then finds the optimization direction. Through the loss function The resulting value is the loss value. If the deviation between the output result and the expected result is very large, the loss value will be large; if the deviation is small, the loss value will be very low. The embodiment of the present application does not limit the type of the loss function. For example, it may be a cross-entropy loss function, a hinge loss function, a negative log-likelihood loss function, etc.
对于特定对象的类目分类,在相关技术提供的方案中,通常是将对象的文本信息与最后一个类目层级中的各个类目进行文本匹配,并将文本相似度最大的类目作为对象所属的类目。然而,发明人经过研究发现,在一方面,文本信息较为片面,信息量不足,单纯的文本信息对于类目的判断存在极大的混淆;另一方面,依靠最后一个类目层级来进行分类,准确率较低,容易将对象归到错误的类目。For the category classification of specific objects, in the solutions provided by related technologies, text information of the object is usually matched with each category in the last category level, and the category with the greatest text similarity is used as the category to which the object belongs. category. However, the inventor found through research that on the one hand, text information is relatively one-sided and the amount of information is insufficient. Pure text information can greatly confuse the judgment of categories; on the other hand, relying on the last category level for classification, The accuracy is low and it is easy to classify objects into wrong categories.
针对于此,本申请实施例提供一种对象分类方法、分类模型训练方法、装置、电子设备及计算机可读存储介质,能够通过机器学习的方式使得分类模型具有多层级分类的能力,进而提升对象分类的精度。下面说明本申请实施例提供的电子设备的示例性应用,本申请实施例提供的电子设备可以实施为各种类型的终端设备,也可以实施为服务器。In view of this, embodiments of the present application provide an object classification method, classification model training method, device, electronic device and computer-readable storage medium, which can make the classification model have multi-level classification capabilities through machine learning, thereby improving object classification. Classification accuracy. The following describes exemplary applications of the electronic device provided by the embodiments of the present application. The electronic device provided by the embodiments of the present application can be implemented as various types of terminal devices or as a server.
参见图1,图1是本申请实施例提供的分类系统100的一个架构示意图,终端设备400通过网络300连接服务器200,服务器200连接数据库500,其中,网络300可以是广域网或者局域网,又或者是二者的组合。Referring to Figure 1, Figure 1 is an architectural schematic diagram of the classification system 100 provided by the embodiment of the present application. The terminal device 400 is connected to the server 200 through the network 300, and the server 200 is connected to the database 500. The network 300 can be a wide area network or a local area network, or a A combination of the two.
在一些实施例中,以电子设备是服务器为例,本申请实施例提供的分类模型训练方法可以由服务器实现。例如,服务器200获取样本对象的样本描述信息及样本类目信息,样本类目信息包括样本对象在多个类目层级分别所属的样本类目。服务器200可以从终端设备400或者数据库500处获取样本对象的样本描述信息及样本类目信息。然后,服务器200调用分类模型基于样本描述信息及样本类目信息进行逐层级分类处理,得到在多个类目层级的分类结果;根据同一类目层级的样本类目及分类结果进行损失计算得到层级损失,对多个类目层级分别对应的层级损失进行多层级融合处理得到多层级损失;根据多层级损失训练分类模型;其中,训练后的分类模型用于预测待测对象在多个类目层级的分类结果。In some embodiments, taking the electronic device as a server as an example, the classification model training method provided in the embodiments of the present application can be implemented by the server. For example, the server 200 obtains sample description information and sample category information of the sample object. The sample category information includes the sample categories to which the sample object belongs at multiple category levels. The server 200 may obtain the sample description information and sample category information of the sample object from the terminal device 400 or the database 500 . Then, the server 200 calls the classification model to perform level-by-level classification processing based on the sample description information and sample category information to obtain classification results at multiple category levels; the loss is calculated based on the sample categories and classification results at the same category level. Hierarchical loss: perform multi-level fusion processing on the hierarchical losses corresponding to multiple category levels to obtain multi-level loss; train the classification model based on the multi-level loss; among them, the trained classification model is used to predict the performance of the test object in multiple categories Level classification results.
在一些实施例中,以电子设备是服务器为例,本申请实施例提供的对象分类方法可以由服务器实现。例如,服务器200可以获取预设的预设类目信息(例如可以预先存储在服务器200本地或者数据库500中),并从终端设备400或者数据库500中获取待测对象的待测描述信息。然后,服务器200调用训练后的分类模型基于待测描述信息及预设类目信息进行逐层级分类处理,得到待测对象在多个类目层级的分类结果,并根据待测对象在多个类目层级的分类结果,确定待测对象在多个类目层级的目标类目。对于得到的待测对象在多个类目层级的目标类目,服务器200可以存储在数据库500或者发送至终端设备400。In some embodiments, taking the electronic device as a server as an example, the object classification method provided in the embodiments of this application can be implemented by the server. For example, the server 200 can obtain preset category information (for example, it can be stored locally in the server 200 or in the database 500 in advance), and obtain the test description information of the object to be tested from the terminal device 400 or the database 500 . Then, the server 200 calls the trained classification model to perform level-by-level classification processing based on the description information to be tested and the preset category information, to obtain the classification results of the object to be tested at multiple category levels, and based on the classification results of the object to be tested in multiple categories. The classification results at the category level determine the target category of the object to be tested at multiple category levels. The server 200 may store the obtained target categories of the object to be tested at multiple category levels in the database 500 or send them to the terminal device 400 .
在一些实施例中,以电子设备是终端设备为例,本申请实施例提供的对象分类方法可以由终端设备实现。例如,服务器200可以将训练后的分类模型发送至终端设备400,以使终端设备400将训练后的分类模型部署在本地。终端设备400可以获取预设类目信息及待测对象的待测描述信息,调用训练后的分类模型基于待测描述信息及预设类目信息进行逐层级分类处理,得到待测对象在多个类目层级的分类结果,并根据待测对象在多个类目层级的分类结果,确定待测对象在多个类目层级的目标类目。In some embodiments, taking the electronic device as a terminal device as an example, the object classification method provided in the embodiments of this application can be implemented by the terminal device. For example, the server 200 may send the trained classification model to the terminal device 400, so that the terminal device 400 deploys the trained classification model locally. The terminal device 400 can obtain the preset category information and the test description information of the object to be tested, call the trained classification model to perform hierarchical classification processing based on the description information to be tested and the preset category information, and obtain the multi-level classification of the object to be tested. Classification results at multiple category levels, and based on the classification results of the object to be tested at multiple category levels, determine the target category of the object to be tested at multiple category levels.
在一些实施例中,终端设备400或服务器200可以通过运行计算机程序来实现本申请实施例提供的分类模型训练方法或对象分类方法,例如,计算机程序可以是操作系统中的原生程序或软件模块;可以是本地(Native)应用程序(APP,Application),即需要在操作系统中安装才能运行的程序,如电商平台应用程序(如图1中的客户端410);也可以是小程序,即只需要下载到浏览器环境中就可以运行的程序;还可以是能够嵌入至任意APP中的小程序,其中,该小程序可以由用户控制运行或关闭。总而言之,上述计算机程序可以是任意形式的应用程序、模块或插件。In some embodiments, the terminal device 400 or the server 200 can implement the classification model training method or object classification method provided by the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the 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 an e-commerce platform application (client 410 in Figure 1); it can also be a small program, that is, A program that only needs to be downloaded to the browser environment to run; it can also be a small program that can be embedded in any APP, where the small program can be run or closed under the user's control. In summary, the computer program described above can be any form of application, module or plug-in.
在一些实施例中,服务器200可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content DeliveryNetwork,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器,其中,云服务可以是分类模型训练服务或对象分类服务,供终端设备400进行调用。终端设备400可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能电视、智能手表等,但并不局限于此。终端设备以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请实施例中不做限制。In some embodiments, the server 200 may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or may provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, Cloud servers for basic cloud computing services such as network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. Among them, cloud services can be classification models The training service or object classification service is for the terminal device 400 to call. The terminal device 400 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart TV, a smart watch, etc., but is not limited thereto. The terminal device and the server can be connected directly or indirectly through wired or wireless communication methods, which are not limited in the embodiments of this application.
以本申请实施例提供的电子设备是服务器为例说明,可以理解的,对于电子设备是终端设备的情况,在图2A基础上还可以包括用户接口、呈现模块和输入处理模块等模块。参见图2A,图2A是本申请实施例提供的服务器200的结构示意图,图2A所示的服务器200包括:至少一个处理器210、存储器250和至少一个网络接口220。服务器200中的各个组件通过总线系统240耦合在一起。可理解,总线系统240用于实现这些组件之间的连接通信。总线系统240除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图2A中将各种总线都标为总线系统240。Taking the electronic device provided by the embodiment of the present application as a server as an example, it can be understood that when the electronic device is a terminal device, modules such as a user interface, a presentation module, and an input processing module may also be included on the basis of Figure 2A. Referring to Figure 2A, Figure 2A is a schematic structural diagram of a server 200 provided by an embodiment of the present application. The server 200 shown in Figure 2A includes: at least one processor 210, a memory 250, and at least one network interface 220. The various components in server 200 are coupled together by bus system 240 . It can be understood that the bus system 240 is used to implement connection communication between these components. In addition to the data bus, the bus system 240 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the various buses are labeled bus system 240 in FIG. 2A.
处理器210可以是一种集成电路芯片,具有信号的处理能力,例如通用处理器、数字信号处理器(DSP,Digital Signal Processor),或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等,其中,通用处理器可以是微处理器或者任何常规的处理器等。The processor 210 may 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, or discrete hardware. Components, etc., wherein the general processor can be a microprocessor or any conventional processor, etc.
存储器250可以是可移除的,不可移除的或其组合。示例性的硬件设备包括固态存储器,硬盘驱动器,光盘驱动器等。存储器250可选地包括在物理位置上远离处理器210的一个或多个存储设备。Memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, etc. Memory 250 optionally includes one or more storage devices physically located remotely from processor 210 .
存储器250包括易失性存储器或非易失性存储器,也可包括易失性和非易失性存储器两者。非易失性存储器可以是只读存储器(ROM,Read Only Memory),易失性存储器可以是随机存取存储器(RAM,Random Access Memory)。本申请实施例描述的存储器250旨在包括任意适合类型的存储器。Memory 250 includes volatile memory or non-volatile memory, and may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM, Read Only Memory), and the volatile memory may be a random-access memory (RAM, Random Access Memory). The memory 250 described in the embodiments of this application is intended to include any suitable type of memory.
在一些实施例中,存储器250能够存储数据以支持各种操作,这些数据的示例包括程序、模块和数据结构或者其子集或超集,下面示例性说明。In some embodiments, the memory 250 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplarily described below.
操作系统251,包括用于处理各种基本系统服务和执行硬件相关任务的系统程序,例如框架层、核心库层、驱动层等,用于实现各种基础业务以及处理基于硬件的任务;The operating system 251 includes system programs used to process various basic system services and perform hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., which are used to implement various basic services and process hardware-based tasks;
网络通信模块252,用于经由一个或多个(有线或无线)网络接口220到达其他计算设备,示例性的网络接口220包括:蓝牙、无线相容性认证(WiFi)、和通用串行总线(USB,Universal Serial Bus)等;Network communications module 252 for reaching other computing devices via one or more (wired or wireless) network interfaces 220. Exemplary network interfaces 220 include: Bluetooth, Wireless Compliance Certified (WiFi), and Universal Serial Bus ( USB, Universal Serial Bus), etc.;
在一些实施例中,本申请实施例提供的分类模型训练装置可以采用软件方式实现,图2A示出了存储在存储器250中的分类模型训练装置2551,其可以是程序和插件等形式的软件,包括以下软件模块:样本获取模块25511、样本处理模块25512、损失计算模块25513及训练模块25514,这些模块是逻辑上的,因此根据所实现的功能可以进行任意的组合或进一步拆分。将在下文中说明各个模块的功能。In some embodiments, the classification model training device provided by the embodiment of the present application can be implemented in software. Figure 2A shows the classification model training device 2551 stored in the memory 250, which can be software in the form of programs, plug-ins, etc., It includes the following software modules: sample acquisition module 25511, sample processing module 25512, loss calculation module 25513 and training module 25514. These modules are logical, so they can be combined or further split according to the functions implemented. The functions of each module are explained below.
在一些实施例中,本申请实施例提供的对象分类装置也可以采用软件方式实现,图2B示出了存储在存储器250中的对象分类装置2552,其可以是程序和插件等形式的软件,包括以下软件模块:目标获取模块25521、目标处理模块25522及确定模块25523,这些模块是逻辑上的,因此根据所实现的功能可以进行任意的组合或进一步拆分。将在下文中说明各个模块的功能。值得说明的是,图2B中除了示出的对象分类装置2552外,其余结构均可与图2A相同。In some embodiments, the object classification device provided by the embodiments of the present application can also be implemented in software. Figure 2B shows the object classification device 2552 stored in the memory 250, which can be software in the form of programs, plug-ins, etc., including The following software modules: target acquisition module 25521, target processing module 25522, and determination module 25523. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module are explained below. It is worth noting that, except for the object classification device 2552 shown in Figure 2B, the other structures can be the same as Figure 2A.
将结合本申请实施例提供的电子设备的示例性应用和实施,说明本申请实施例提供的分类模型训练方法。The classification model training method provided by the embodiment of the present application will be described with reference to the exemplary application and implementation of the electronic device provided by the embodiment of the present application.
参见图3A,图3A是本申请实施例提供的分类模型训练方法的一个流程示意图,将结合图3A示出的步骤进行说明。Referring to Figure 3A, Figure 3A is a schematic flow chart of a classification model training method provided by an embodiment of the present application, which will be described in conjunction with the steps shown in Figure 3A.
在步骤101中,获取样本对象的样本描述信息及样本类目信息;样本类目信息包括样本对象在多个类目层级的样本类目。In step 101, sample description information and sample category information of the sample object are obtained; the sample category information includes sample categories of the sample object at multiple category levels.
在本申请实施例中,类目系统已预先建立,类目系统包括多个类目层级,每个类目层级包括若干个预设类目,不同的类目层级的类目之间存在关联关系,即某一类目层级中的某个类目与下一个类目层级中的至少一个类目之间存在关联关系。在已建立的类目系统的基础上,需要将特定对象划分到正确的类目,因此,可以将样本对象的相关数据作为训练数据,以训练分类模型,使得分类模型具有准确分类的能力,其中,样本对象是指已标注好类目的对象。In the embodiment of this application, the category system has been established in advance. The category system includes multiple category levels. Each category level includes several preset categories. There are correlations between categories at different category levels. , that is, there is an association relationship between a category in a certain category level and at least one category in the next category level. On the basis of the established category system, specific objects need to be classified into the correct categories. Therefore, the relevant data of the sample objects can be used as training data to train the classification model, so that the classification model has the ability to classify accurately, where , sample objects refer to objects that have been labeled with categories.
样本对象的相关数据包括样本描述信息及样本类目信息,其中,样本描述信息用于描述样本对象,样本描述信息可以是单模态的信息,如文本信息;也可以是多模态的信息,如包括文本信息、图片信息等。样本类目信息包括样本对象在每个类目层级所属的样本类目,样本类目是指已标注的、认定为正确的类目。The relevant data of the sample object includes sample description information and sample category information. The sample description information is used to describe the sample object. The sample description information can be single-modal information, such as text information; it can also be multi-modal information. Such as including text information, picture information, etc. The sample category information includes the sample category to which the sample object belongs at each category level. The sample category refers to the category that has been marked and determined to be correct.
以电商场景举例,电商类目系统可以包括三个类目层级,第一个类目层级可以包括“衣服”、“食品”、“电器”类目;对于“衣服”类目来说,更下一级(第二个类目层级)可以包括“上衣”、“裤子”类目,即“衣服”类目与“上衣”、“裤子”类目存在关联关系,以下同理;对于“上衣”类目来说,更下一级(第三个类目层级)可以包括“T恤”、“羽绒服”类目。在该场景下,样本对象可以是人为标注好类目的商品,样本描述信息可以包括该商品的图片、文本(如商品介绍)等,样本类目信息包括样本对象在电商类目系统中的每个类目层级所属的样本类目,例如样本类目信息可以是“衣服-上衣-T恤”,样本类目“衣服”对应第一个类目层级,样本类目“上衣”对应第二个类目层级,样本类目“T恤”对应第三个类目层级。Taking the e-commerce scenario as an example, the e-commerce category system can include three category levels. The first category level can include "clothing", "food", and "electrical appliances" categories; for the "clothing" category, The next level (the second category level) can include the categories of "tops" and "pants", that is, the "clothes" category has an associated relationship with the categories of "tops" and "pants". The same is true below; for "tops" and "pants" categories, For the "tops" category, the next level (the third category level) can include "T-shirts" and "down jackets" categories. In this scenario, the sample object can be a product that has been manually labeled with a good category. The sample description information can include pictures and texts of the product (such as product introduction), etc. The sample category information includes the sample object in the e-commerce category system. The sample category to which each category level belongs. For example, the sample category information can be "clothes-tops-T-shirts", the sample category "clothes" corresponds to the first category level, and the sample category "tops" corresponds to the second There are three category levels, and the sample category "T-shirt" corresponds to the third category level.
在步骤102中,通过分类模型基于样本描述信息及样本类目信息进行逐层级分类处理,得到在多个类目层级的分类结果。In step 102, the classification model performs level-by-level classification processing based on the sample description information and the sample category information to obtain classification results at multiple category levels.
这里,将样本描述信息及样本类目信息作为分类模型的输入数据,在分类模型中进行前向传播处理,即通过分类模型基于样本描述信息及样本类目信息进行逐层级分类处理,得到的输出结果为在每个类目层级的分类结果。其中,分类模型可以是人工神经网络模型,前向传播处理是指按照分类模型中的网络层从前到后的顺序,对网络层的输入数据进行处理。Here, the sample description information and sample category information are used as input data of the classification model, and forward propagation processing is performed in the classification model. That is, the classification model performs level-by-level classification processing based on the sample description information and sample category information. The obtained The output results are classification results at each category level. The classification model may be an artificial neural network model, and forward propagation processing refers to processing the input data of the network layers in the order from front to back in the classification model.
在步骤103中,根据同一类目层级的样本类目及分类结果进行损失计算得到层级损失,对多个类目层级分别对应的层级损失进行多层级融合处理得到多层级损失。In step 103, loss calculation is performed based on the sample categories and classification results of the same category level to obtain a hierarchical loss, and multi-level fusion processing is performed on the hierarchical losses corresponding to multiple category levels to obtain a multi-level loss.
对于每个类目层级来说,根据类目层级的分类结果、以及样本类目信息中的在该类目层级的样本类目,计算得到该类目层级的层级损失,层级损失即表示分类模型在该类目层级的输出结果与期望结果之间的误差。本申请实施例对损失计算所用到的损失函数不做限定,可以是用于解决分类问题的各种损失函数,如交叉熵损失函数等。For each category level, based on the classification results of the category level and the sample categories at that category level in the sample category information, the hierarchical loss of the category level is calculated. The hierarchical loss represents the classification model. The error between the output results at the category level and the expected results. The embodiments of this application do not limit the loss function used in loss calculation, and may be various loss functions used to solve classification problems, such as cross-entropy loss functions, etc.
如此,可以得到多个类目层级分别对应的层级损失,然后,对这些层级损失进行多层级融合处理,得到多层级损失,多层级损失即表示分类模型在所有类目层级的总误差。本申请实施例对多层级融合处理的方式不做限定,例如可以是加权求和处理,各个类目层级的权重可以根据实际应用场景进行设定。In this way, the hierarchical losses corresponding to multiple category levels can be obtained. Then, these hierarchical losses are subjected to multi-level fusion processing to obtain multi-level losses. The multi-level loss represents the total error of the classification model at all category levels. The embodiment of the present application does not limit the method of multi-level fusion processing. For example, it can be weighted summation processing, and the weight of each category level can be set according to the actual application scenario.
在步骤104中,根据多层级损失训练分类模型;其中,训练后的分类模型用于预测待测对象在多个类目层级的分类结果。In step 104, a classification model is trained based on multi-level losses; wherein the trained classification model is used to predict the classification results of the object to be tested at multiple category levels.
例如,在得到多层级损失的基础上,根据多层级损失对分类模型进行反向传播处理,在反向传播的过程中更新分类模型的权重参数及偏移量,如此达到训练分类模型的目的。在反向传播的过程中,可以采用梯度下降(Gradient Descent)算法来寻找使得多层级损失最小化的权重参数及偏移量。训练后的分类模型具有准确进行逐层级分类的能力,因此,可以通过训练后的分类模型来预测待测对象在每个类目层级的分类结果。For example, on the basis of obtaining multi-level losses, the classification model is back-propagated based on the multi-level losses, and the weight parameters and offsets of the classification model are updated during the back-propagation process, thus achieving the purpose of training the classification model. In the process of backpropagation, the gradient descent (Gradient Descent) algorithm can be used to find the weight parameters and offsets that minimize the multi-level loss. The trained classification model has the ability to accurately perform level-by-level classification. Therefore, the trained classification model can be used to predict the classification results of the object to be tested at each category level.
在一些实施例中,当根据多层级损失训练分类模型时,还包括:当满足预设的停止条件时,停止训练分类模型。这里,可以预先设定停止条件,例如停止条件可以是分类模型的训练轮数达到训练轮数阈值,也可以是分类模型的性能指标达到性能指标阈值,这里的性能指标可以是准确率或者F1-score等。通过上述方式,可以对训练过程进行精准控制,在保证分类模型性能的前提下,减少计算资源的浪费。In some embodiments, when training the classification model according to the multi-level loss, it also includes: stopping training the classification model when a preset stopping condition is met. Here, the stopping condition can be set in advance. For example, the stopping condition can be that the number of training rounds of the classification model reaches the training round threshold, or it can be that the performance index of the classification model reaches the performance index threshold. The performance index here can be accuracy or F1- score, etc. Through the above method, the training process can be precisely controlled, and the waste of computing resources can be reduced while ensuring the performance of the classification model.
如图3A所示,本申请实施例综合考虑各个类目层级的层级损失,使得训练后的分类模型具有准确进行逐层级分类的能力,能够提升分类精度,避免因仅依靠最后一个类目层级所导致的分类错误率高的问题。As shown in Figure 3A, the embodiment of the present application comprehensively considers the hierarchical loss of each category level, so that the trained classification model has the ability to accurately perform level-by-level classification, which can improve the classification accuracy and avoid relying solely on the last category level. The problem caused by high classification error rate.
在一些实施例中,参见图3B,图3B是本申请实施例提供的分类模型训练方法的一个流程示意图,图3A示出的步骤102可以通过步骤201至步骤202实现,将结合各步骤进行说明。In some embodiments, see Figure 3B. Figure 3B is a schematic flowchart of the classification model training method provided by the embodiment of the present application. Step 102 shown in Figure 3A can be implemented through steps 201 to 202. Each step will be explained in combination. .
在步骤201中,从样本描述信息中提取样本描述特征,从样本类目信息中提取样本类目特征。In step 201, sample description features are extracted from sample description information, and sample category features are extracted from sample category information.
这里,对样本描述信息进行特征提取得到样本描述特征,对样本类目信息进行特征提取得到样本类目特征。本申请实施例对特征提取的方式不做限定,例如可以针对需要特征提取的信息类型,通过信息类型对应的特定模型(这里的特定模型是分类模型的一部分)来实现,例如,对于文本(例如样本描述信息中的文本或者以文本形式体现的样本类目信息)来说,可以通过文本特征提取模型来实现特征提取,文本特征提取模型如TextTransformer模型;对于图片(例如样本描述信息中的图片)来说,可以通过图片特征提取模型来实现特征提取,图片特征提取模型如卷积神经网络(Convolutional NeuralNetworks,CNN)或Vision Transformer模型等。值得说明的是,对于样本描述信息和样本类目信息来说,实现特征提取的模型的类型可以相同或者部分相同,但是模型中的权重参数及偏移量是存在差异的。Here, feature extraction is performed on the sample description information to obtain sample description features, and feature extraction is performed on the sample category information to obtain sample category features. The embodiments of the present application do not limit the method of feature extraction. For example, the type of information that requires feature extraction can be implemented through a specific model corresponding to the information type (the specific model here is part of the classification model). For example, for text (for example, For text in the sample description information or sample category information embodied in text form), feature extraction can be achieved through a text feature extraction model, such as the TextTransformer model; for pictures (such as pictures in the sample description information) In other words, feature extraction can be achieved through image feature extraction models, such as convolutional neural networks (Convolutional Neural Networks, CNN) or Vision Transformer models. It is worth noting that for sample description information and sample category information, the types of models used to implement feature extraction may be the same or partially the same, but the weight parameters and offsets in the models are different.
在一些实施例中,样本描述信息包括多个模态的描述信息;可以通过这样的方式来实现上述的从样本描述信息中提取样本描述特征:从每个模态的描述信息中提取模态描述特征;对多个模态分别对应的模态描述特征进行特征融合处理,得到样本描述特征。In some embodiments, the sample description information includes description information of multiple modalities; the above-mentioned extraction of sample description features from the sample description information can be achieved in this way: extracting the modality description from the description information of each modality Features; perform feature fusion processing on the modal description features corresponding to multiple modalities to obtain sample description features.
样本描述信息可以包括单一模态的描述信息,如仅包括图片信息或文本信息;也可以包括多个模态的描述信息,如同时包括图片信息、文本信息及声音信息等,多个模态的描述信息能够更加全面地描述样本对象。The sample description information may include description information in a single modality, such as only picture information or text information; it may also include description information in multiple modalities, such as picture information, text information, and sound information at the same time. Descriptive information can describe the sample object more comprehensively.
在样本描述信息包括多个模态的描述信息的情况下,可以先从每个模态的描述信息中提取模态描述特征,再对所有模态描述特征进行特征融合处理,得到样本描述特征,其中,对特征融合处理的方式不做限定,例如可以是直接求和或加权求和等。通过上述的多模态融合,可以提升得到的样本描述特征的全面性,从而提升模型训练的效果,充分学习到各个模态与类目之间的数据规律。When the sample description information includes description information of multiple modalities, the modal description features can be extracted from the description information of each modality first, and then feature fusion processing is performed on all modal description features to obtain the sample description features. The method of feature fusion processing is not limited, for example, it can be direct summation or weighted summation. Through the above-mentioned multi-modal fusion, the comprehensiveness of the obtained sample description features can be improved, thereby improving the effect of model training and fully learning the data patterns between various modalities and categories.
在步骤202中,针对任意一个类目层级,根据样本描述特征及样本类目特征计算在任意一个类目层级的类目概率分布,以作为在任意一个类目层级的分类结果。In step 202, for any category level, the category probability distribution at any category level is calculated according to the sample description characteristics and the sample category characteristics as a classification result at any category level.
这里,对于每个类目层级,根据样本描述特征及样本类目特征计算类目概率分布,即计算与类目层级中每个预设类目对应的概率,如此,得到的任意一个类目层级的类目概率分布的维度(以向量形式体现的类目概率分布的维度)与该任意一个类目层级的预设类目的数量相同。值得说明的是,对于不同的类目层级,求取类目概率分布的过程是相互独立的;可以按照类目系统中第一个类目层级到最后一个类目层级的顺序,来依次求取每个类目层级的类目概率分布。Here, for each category level, the category probability distribution is calculated based on the sample description characteristics and sample category characteristics, that is, the probability corresponding to each preset category in the category level is calculated. In this way, any category level obtained The dimension of the category probability distribution (the dimension of the category probability distribution represented in the form of a vector) is the same as the number of preset categories at any category level. It is worth noting that for different category levels, the process of obtaining the category probability distribution is independent of each other; it can be obtained in sequence from the first category level to the last category level in the category system. Category probability distribution at each category level.
在一些实施例中,从样本描述信息中提取样本描述特征,从样本类目信息中提取样本类目特征之后,还包括:对样本描述特征及样本类目特征进行线性投射处理;对线性投射后的样本描述特征及样本类目特征进行归一化处理。In some embodiments, after extracting the sample description features from the sample description information and extracting the sample category features from the sample category information, it also includes: performing linear projection processing on the sample description features and sample category features; The sample description features and sample category features are normalized.
这里,可以对样本描述特征及样本类目特征进行线性投射处理,线性投射的目的是将样本描述特征及样本类目特征投射到相同的维度,便于后续计算。在线性投射的基础上,可以对线性投射后的样本描述特征及样本类目特征进行归一化处理,其中,归一化是指将特征中有量纲的数值变成无量纲的数值,即变成标量,如此可以加强不同特征之间的可比性,提升模型训练的效果。本申请实施例对归一化方式不做限定,例如可以是L1归一化或者L2归一化等。通过上述方式,能够使得样本描述特征及样本类目特征更适合运算、比较,能够有效加强模型训练效果。Here, linear projection processing can be performed on the sample description features and sample category features. The purpose of linear projection is to project the sample description features and sample category features into the same dimension to facilitate subsequent calculations. On the basis of linear projection, the sample description features and sample category features after linear projection can be normalized. Normalization refers to turning the dimensionless values in the features into dimensionless values, that is, Become a scalar, which can enhance the comparability between different features and improve the effect of model training. The embodiment of the present application does not limit the normalization method. For example, it may be L1 normalization or L2 normalization. Through the above method, the sample description features and sample category features can be made more suitable for calculation and comparison, and the model training effect can be effectively enhanced.
如图3B所示,通过提取信息中的特征,并基于提取出的特征来预测每个类目层级的类目概率分布,在实现分类的同时,可以适应于每个类目层级的实际情况。As shown in Figure 3B, by extracting features in the information and predicting the category probability distribution of each category level based on the extracted features, classification can be achieved while adapting to the actual situation of each category level.
在一些实施例中,参见图3C,图3C是本申请实施例提供的分类模型训练方法的一个流程示意图,图3A示出的步骤102可以通过步骤301至步骤302实现,将结合各步骤进行说明。In some embodiments, see Figure 3C. Figure 3C is a schematic flowchart of the classification model training method provided by the embodiment of the present application. Step 102 shown in Figure 3A can be implemented through steps 301 to 302. Each step will be explained in combination. .
在步骤301中,对多个样本描述信息及多个样本类目信息进行组合处理,得到多个信息组合;每个信息组合包括一个样本描述信息及一个样本类目信息。In step 301, multiple sample description information and multiple sample category information are combined to obtain multiple information combinations; each information combination includes one sample description information and one sample category information.
在本申请实施例中,样本对象的样本描述信息及样本类目信息可以视为模型训练的正样本,而如果仅根据正样本进行模型训练,很容易使得分类模型陷入过拟合的状态,大大降低分类模型的泛化能力。因此,可以构造出负样本,基于对比学习的思路来进行模型训练。In the embodiment of this application, the sample description information and sample category information of the sample object can be regarded as positive samples for model training. However, if the model training is only based on positive samples, it is easy for the classification model to fall into an overfitting state, which greatly affects the model training. Reduce the generalization ability of the classification model. Therefore, negative samples can be constructed and model training based on the idea of contrastive learning.
例如,在样本对象的数量包括多个的情况下,可以得到多个样本描述信息及多个样本类目信息,进而,对多个样本描述信息及多个样本类目信息进行组合处理,得到多个信息组合,其中,每个信息组合包括一个样本描述信息及一个样本类目信息。组合处理的方式可以是穷举组合,例如存在N个样本描述信息及N个样本类目信息,则可以得到N×N个信息组合。For example, when the number of sample objects includes multiple samples, multiple sample description information and multiple sample category information can be obtained. Furthermore, the multiple sample description information and multiple sample category information can be combined to obtain multiple samples. Information combinations, wherein each information combination includes a sample description information and a sample category information. The combination processing method can be exhaustive combination. For example, if there are N pieces of sample description information and N pieces of sample category information, N×N information combinations can be obtained.
为了便于理解,进行举例说明。样本对象包括样本对象A及样本对象B,样本对象A对应有样本描述信息A1及样本类目信息A2,样本对象B对应有样本描述信息B1及样本类目信息B2,则经过组合处理后,可以得到四个信息组合,分别为A1-A2、A1-B2、B1-A2、B1-B2。对于得到的信息组合,存在两种情况,第一种情况是,信息组合中的样本描述信息及样本类目信息对应同一样本对象(如A1-A2、B1-B2),符合这种情况的信息组合为正样本;第二种情况是,信息组合中的样本描述信息及样本类目信息对应不同样本对象(如A1-B2、B1-A2),符合这种情况的信息组合为负样本。To facilitate understanding, examples are given. The sample object includes sample object A and sample object B. Sample object A corresponds to sample description information A1 and sample category information A2. Sample object B corresponds to sample description information B1 and sample category information B2. After combination processing, it can Four information combinations are obtained, namely A1-A2, A1-B2, B1-A2, and B1-B2. There are two situations for the obtained information combination. The first situation is that the sample description information and sample category information in the information combination correspond to the same sample object (such as A1-A2, B1-B2). Information that meets this situation The combination is a positive sample; the second case is that the sample description information and sample category information in the information combination correspond to different sample objects (such as A1-B2, B1-A2), and the information combination that meets this situation is a negative sample.
在步骤302中,通过分类模型基于信息组合进行逐层级分类处理,得到信息组合在多个类目层级的分类结果。In step 302, a classification model is used to perform level-by-level classification processing based on the information combination to obtain classification results of the information combination at multiple category levels.
对于每个信息组合,调用分类模型基于信息组合中的样本描述信息及样本类目信息进行逐层级分类处理,即进行前向传播处理,得到该信息组合在每个类目层级的分类结果。For each information combination, the classification model is called to perform level-by-level classification processing based on the sample description information and sample category information in the information combination, that is, forward propagation processing is performed to obtain the classification results of the information combination at each category level.
在图3C中,图3A示出的步骤103可以通过步骤303至步骤306实现,将结合各步骤进行说明。In Figure 3C, step 103 shown in Figure 3A can be implemented through steps 303 to 306, which will be described in combination with each step.
在步骤303中,根据信息组合对应的目标样本对象在任意一个类目层级的样本类目,确定信息组合在任意一个类目层级的类目标签。In step 303, the category target label of the information combination at any category level is determined based on the sample category of the target sample object corresponding to the information combination at any category level.
这里,在确定出各个信息组合对应的在每个类目层级的分类结果后,根据分类结果在每个类目层级计算层级损失,为了便于理解,后文以第一个类目层级为例进行说明。Here, after determining the classification results at each category level corresponding to each information combination, the level loss is calculated at each category level based on the classification results. For ease of understanding, the following article takes the first category level as an example. illustrate.
首先,对于每个信息组合,根据信息组合对应的目标样本对象在第一个类目层级的样本类目,确定该信息组合在第一个类目层级的类目标签,该类目标签即为期望结果。First, for each information combination, determine the category target label of the information combination at the first category level based on the sample category of the target sample object corresponding to the information combination at the first category level. The category target label is Desired result.
本申请实施例对类目标签的形式不做限定,例如可以是One-Hot向量的形式,One-Hot向量是有且只有1个元素的数值为1,其他元素的数值均为0的向量,在此基础上,在确定第一个类目层级的层级损失的过程中,得到的类目标签的维度等于第一个类目层级中的预设类目的数量(种类),类目标签中的每一个元素对应第一个类目层级中的一个预设类目,数值为1的元素即对应目标样本对象在第一个类目层级的样本类目。相对应地,第一个类目层级的分类结果也可以是向量形式(如以向量形式体现的类目概率分布),且与第一个类目层级的类目标签在维度上相同,分类结果所包括的多个元素的数值之和为1,每个元素的数值表示属于对应预设类目的概率。The embodiment of this application does not limit the form of the class target label. For example, it can be in the form of a One-Hot vector. A One-Hot vector is a vector with only one element with a value of 1 and other elements with a value of 0. On this basis, in the process of determining the hierarchical loss of the first category level, the dimension of the obtained category target label is equal to the number (type) of the preset categories in the first category level. Each element of corresponds to a preset category in the first category level, and the element with a value of 1 corresponds to the sample category of the target sample object in the first category level. Correspondingly, the classification result of the first category level can also be in the form of a vector (such as a category probability distribution represented in vector form), and has the same dimensions as the category label of the first category level. The classification result The sum of the values of the multiple elements included is 1, and the value of each element represents the probability of belonging to the corresponding preset category.
例如,第一个类目层级共有3种预设类目,分别为“衣服”、“食品”、“电器”,则在确定第一个类目层级的层级损失的过程中,确定出的类目标签的维度为3,形式如[元素1,元素2,元素3],其中,元素1对应类目“衣服”,元素2对应类目“食品”,元素3对应类目“电器”,当然,元素与类目之间的一一对应关系可以调整,并不限于上述例子。借助该例子,假如某个信息组合在第一个类目层级的分类结果为[0.1,0.7,0.2],则表明该信息组合属于“衣服”的概率为10%,属于“食品”的概率为70%,属于“电器”的概率为20%。For example, there are three preset categories in the first category level, namely "clothing", "food", and "electrical appliances". In the process of determining the level loss of the first category level, the determined categories The dimension of the target tag is 3, in the form [Element 1, Element 2, Element 3], where Element 1 corresponds to the category "Clothes", Element 2 corresponds to the category "Food", and Element 3 corresponds to the category "Electrical Appliances". Of course , the one-to-one correspondence between elements and categories can be adjusted and is not limited to the above examples. Using this example, if the classification result of a certain information combination at the first category level is [0.1, 0.7, 0.2], it means that the probability that the information combination belongs to "clothing" is 10%, and the probability of belonging to "food" is 70%, the probability of belonging to "electrical appliances" is 20%.
在一些实施例中,当信息组合中的样本描述信息及样本类目信息对应同一样本对象时,将同一样本对象确定为信息组合对应的目标样本对象;当信息组合中的样本描述信息及样本类目信息对应不同样本对象时,将信息组合对应的目标样本对象确定为无对象;其中,无对象在任意一个类目层级的样本类目为无类目。In some embodiments, when the sample description information and sample category information in the information combination correspond to the same sample object, the same sample object is determined as the target sample object corresponding to the information combination; when the sample description information and sample category information in the information combination When the target information corresponds to different sample objects, the target sample object corresponding to the information combination is determined as no object; among them, the sample category with no object at any category level is no category.
当信息组合中的样本描述信息及样本类目信息对应同一样本对象时,证明该信息组合为正样本,则将该同一样本对象确定为该信息组合对应的目标样本对象,并根据目标样本对象的样本类目来确定类目标签。以前述例子再次举例,若确定出的目标样本对象在第一个类目层级的样本类目为“衣服”,则确定对应信息组合在第一个类目层级的类目标签为[1,0,0]。When the sample description information and sample category information in the information combination correspond to the same sample object, it is proved that the information combination is a positive sample, then the same sample object is determined as the target sample object corresponding to the information combination, and based on the target sample object Sample category to determine the category target label. Taking the above example again, if the sample category of the determined target sample object at the first category level is "clothing", then it is determined that the category target label of the corresponding information combination at the first category level is [1, 0 ,0].
当信息组合中的样本描述信息及样本类目信息对应不同样本对象时,证明该信息组合为负样本,则将该信息组合对应的目标样本对象确定为无对象。对于无对象来说,类目标签可以是固定的,例如是数值均为0的向量,以前述例子再次举例,则无对象在第一个类目层级的样本类目为无类目,进而确定对应信息组合在第一个类目层级的类目标签为[0,0,0]。When the sample description information and sample category information in the information combination correspond to different sample objects, it is proved that the information combination is a negative sample, and the target sample object corresponding to the information combination is determined to be no object. For no objects, the category label can be fixed, for example, a vector with all values 0. Taking the above example again, then the sample category of the first category level without objects is no category, and then determine The category target label of the corresponding information combination at the first category level is [0, 0, 0].
通过上述方式,能够准确划分正样本与负样本,准确有效地实现训练数据的扩充,同时也可以得到准确的类目标签。Through the above method, positive samples and negative samples can be accurately divided, training data can be expanded accurately and effectively, and accurate class target labels can also be obtained.
在步骤304中,确定信息组合在任意一个类目层级的类目标签与分类结果之间的差异,以作为信息组合损失。In step 304, the difference between the category label and the classification result of the information combination at any category level is determined as the information combination loss.
对于每个信息组合,确定信息组合在第一个类目层级的类目标签(期望结果)与该信息组合在第一个类目层级的分类结果(输出结果)之间的差异,以作为信息组合损失,例如,可以将信息组合在第一个类目层级的类目标签及该信息组合在第一个类目层级的分类结果代入至损失函数,得到信息组合损失。For each information combination, the difference between the category label (expected result) of the information combination at the first category level and the classification result (output result) of the information combination at the first category level is determined as the information For the combination loss, for example, the category label of the information combination at the first category level and the classification result of the information combination at the first category level can be substituted into the loss function to obtain the information combination loss.
在步骤305中,对多个信息组合分别对应的信息组合损失进行信息组合融合处理,得到任意一个类目层级的层级损失。In step 305, information combination fusion processing is performed on the information combination losses corresponding to multiple information combinations to obtain the hierarchical loss of any category level.
这里,在得到每个信息组合在第一个类目层级的信息组合损失后,对这些信息组合损失进行信息组合融合处理,得到第一个类目层级的层级损失。本申请实施例对信息组合融合处理的方式不做限定,例如可以是直接求和或加权求和等。Here, after obtaining the information combination loss of each information combination at the first category level, these information combination losses are subjected to information combination fusion processing to obtain the hierarchical loss at the first category level. The embodiment of the present application does not limit the method of information combination and fusion processing. For example, it may be direct summation or weighted summation.
以上仅是确定第一个类目层级的层级损失的过程进行举例说明,确定其余类目层级的层级损失的过程可以参照执行。The above is only an example of the process of determining the hierarchical loss of the first category level. The process of determining the hierarchical loss of the remaining category levels can be performed by reference.
在步骤306中,对多个类目层级分别对应的层级损失进行多层级融合处理得到多层级损失。In step 306, multi-level fusion processing is performed on hierarchical losses corresponding to multiple category levels to obtain multi-level losses.
如图3C所示,本申请实施例基于对比学习的思路生成多个信息组合,并确定对应的类目标签,能够提升训练数据的丰富程度,使分类模型基于正样本及负样本得到充分训练,能够有效提升训练后的分类模型的泛化能力,避免陷入过拟合。As shown in Figure 3C, the embodiment of the present application generates multiple information combinations based on the idea of contrastive learning and determines the corresponding class target labels, which can improve the richness of training data and enable the classification model to be fully trained based on positive samples and negative samples. It can effectively improve the generalization ability of the trained classification model and avoid overfitting.
在一些实施例中,参见图4,图4是本申请实施例提供的对象分类方法的一个流程示意图,将结合示出的各个步骤进行说明。In some embodiments, see FIG. 4 , which is a schematic flowchart of an object classification method provided by an embodiment of the present application, which will be described with reference to each of the steps shown.
在步骤401中,获取预设类目信息及待测对象的待测描述信息;其中,预设类目信息包括多个类目层级的预设类目。In step 401, preset category information and test description information of the object to be tested are obtained; wherein the preset category information includes preset categories of multiple category levels.
这里,可以通过分类模型来预测待测对象在每个类目层级的分类结果。首先,可以获取预设类目信息及待测对象的待测描述信息,其中,分类模型可以是通过本申请实施例提供的分类模型训练方法训练得到的。其中,预设类目信息可以基于类目系统来确定,例如可以包括类目系统中的每个类目层级的所有预设类目,当然,根据实际应用场景中的需求,也可以选取类目系统中的部分而非全部预设类目以加入到预设类目信息中,例如某些预设类目不需要做分类,则这些预设类目不需要加入到预设类目信息中。Here, the classification model can be used to predict the classification results of the object to be tested at each category level. First, the preset category information and the test description information of the object to be tested can be obtained, where the classification model can be trained by the classification model training method provided by the embodiment of the present application. The preset category information can be determined based on the category system. For example, it can include all preset categories at each category level in the category system. Of course, categories can also be selected according to the needs in actual application scenarios. Some but not all of the default categories in the system can be added to the default category information. For example, if some default categories do not need to be classified, then these default categories do not need to be added to the default category information.
值得说明的是,待测描述信息与样本描述信息在类型上相同,例如都仅包括图片信息,又例如都同时包括图片信息及文本信息。It is worth noting that the description information to be tested and the sample description information are of the same type. For example, they both include only picture information, or they both include picture information and text information.
在步骤402中,通过分类模型基于待测描述信息及预设类目信息进行逐层级分类处理,得到待测对象在多个类目层级的分类结果。In step 402, the classification model performs level-by-level classification processing based on the description information to be tested and the preset category information to obtain classification results of the object to be tested at multiple category levels.
这里,调用分类模型,以基于待测描述信息及预设类目信息进行逐层级分类处理,得到待测对象在每个类目层级的分类结果。其中,这里的逐层级分类可以是指按照从第一个类目层级到最后一个类目层级的顺序进行分类。Here, the classification model is called to perform level-by-level classification processing based on the description information to be tested and the preset category information to obtain the classification results of the objects to be tested at each category level. The hierarchical classification here may refer to classification in order from the first category level to the last category level.
在一些实施例中,可以通过这样的方式来实现上述的通过分类模型基于待测描述信息及预设类目信息进行逐层级分类处理,得到待测对象在多个类目层级的分类结果:通过分类模型执行以下处理:从待测描述信息中提取待测描述特征,从预设类目信息包括的预设类目中提取预设类目特征;根据待测描述特征及预设类目特征,计算待测对象属于预设类目特征对应预设类目的概率;针对任意一个类目层级,将待测对象分别属于任意一个类目层级的多个预设类目的概率,确定为待测对象在任意一个类目层级的分类结果。In some embodiments, the above-mentioned classification process based on the description information to be tested and the preset category information through the classification model can be implemented in this way to obtain the classification results of the object to be tested at multiple category levels: The following processing is performed through the classification model: extracting the description features to be tested from the description information to be tested, and extracting the preset category features from the preset categories included in the preset category information; based on the description features to be tested and the preset category features , calculate the probability that the object to be tested belongs to the preset category corresponding to the preset category characteristics; for any category level, determine the probability that the object to be tested belongs to multiple preset categories at any category level as the probability to be tested. Classification results of test objects at any category level.
这里,针对预设类目信息中的每个预设类目,单独预测待测对象属于每个预设类目的概率。首先,从待测描述信息中提取待测描述特征,从预设类目信息包括的预设类目中提取预设类目特征,其中,预设类目与预设类目特征之间是一对一的关系。值得说明的是,这里的预设类目特征表示是预设类目的特征,预设类目特征本身并非是预设的。Here, for each preset category in the preset category information, the probability that the object to be tested belongs to each preset category is separately predicted. First, the description features to be tested are extracted from the description information to be tested, and the preset category features are extracted from the preset categories included in the preset category information, where there is a relationship between the preset categories and the preset category features. One-to-one relationship. It is worth noting that the preset category features here represent features of the preset category, and the preset category features themselves are not preset.
然后,根据待测描述特征及预设类目特征,计算待测对象属于预设类目特征对应预设类目的概率。如果在训练分类模型时是根据样本描述特征及样本类目特征计算类目概率分布,则在这里,也可以根据待测描述特征及预设类目特征来计算出类目概率分布,并查找类目概率分布中与预设类目(这里指预设类目特征对应的预设类目)对应的概率。Then, based on the description characteristics to be tested and the preset category characteristics, the probability that the object to be tested belongs to the preset category corresponding to the preset category characteristics is calculated. If the category probability distribution is calculated based on the sample description features and sample category features when training the classification model, here, the category probability distribution can also be calculated based on the description features to be tested and the preset category features, and the category can be found. The probability corresponding to the preset category (here refers to the preset category corresponding to the preset category characteristics) in the category probability distribution.
例如,在预设类目信息中,第一个类目层级共有3种预设类目,分别为“衣服”、“食品”、“电器”。则针对“衣服”类目,先提取出“衣服”类目特征,再根据待测描述特征及“衣服”类目特征来计算类目概率分布。由于“衣服”类目位于第一个类目层级,则计算出的类目概率分布的维度与预设类目信息在第一个类目层级的预设类目的数量相等,即维度为3,类目概率分布中的每一个元素对应预设类目信息在第一个类目层级的一个预设类目。假如类目概率分布中的元素从前到后依次对应“衣服”、“食品”、“电器”,且类目概率分布具体为[0.6,0.3,0.1],则可以得到待测对象属于“衣服”类目的概率为60%,至于类目概率分布中其他元素的数值,在求取待测对象属于“衣服”类目的概率的过程中可以无需关注。For example, in the preset category information, there are three preset categories in the first category level, namely "clothing", "food", and "electrical appliances". For the "clothing" category, first extract the "clothing" category features, and then calculate the category probability distribution based on the description features to be measured and the "clothing" category features. Since the "clothing" category is located at the first category level, the dimension of the calculated category probability distribution is equal to the number of preset categories of the preset category information at the first category level, that is, the dimension is 3 , each element in the category probability distribution corresponds to a preset category of the preset category information at the first category level. If the elements in the category probability distribution correspond to "clothing", "food", and "electrical appliances" from front to back, and the category probability distribution is specifically [0.6, 0.3, 0.1], then it can be concluded that the object to be tested belongs to "clothing" The probability of the category is 60%. As for the values of other elements in the category probability distribution, there is no need to pay attention to the process of calculating the probability that the object to be tested belongs to the "clothing" category.
如此,针对任意一个类目层级,可以得到待测对象属于类目层级的每个预设类目的概率,这些概率即为待测对象在该类目层级的分类结果。通过上述方式,能够基于待测描述特征及预设类目特征准确求解出待测对象属于对应预设类目的概率,针对每个预设类目实现精准预测。In this way, for any category level, the probability that the object to be tested belongs to each preset category of the category level can be obtained, and these probabilities are the classification results of the object to be tested at that category level. Through the above method, the probability that the object to be measured belongs to the corresponding preset category can be accurately calculated based on the description features to be measured and the preset category features, and accurate predictions can be achieved for each preset category.
在一些实施例中,当通过分类模型基于待测描述信息及预设类目信息进行逐层级分类处理时,还包括:针对任意一个类目层级,执行以下处理:根据任意一个类目层级的前一个类目层级的分类结果,对任意一个类目层级的多个预设类目进行筛选处理;根据筛选出的预设类目更新预设类目信息。In some embodiments, when the classification model is used to perform level-by-level classification processing based on the description information to be tested and the preset category information, it also includes: performing the following processing for any one category level: according to any one category level The classification results of the previous category level are filtered for multiple preset categories at any category level; the preset category information is updated according to the filtered preset categories.
在按照从第一个类目层级到最后一个类目层级的顺序进行逐层级分类的过程中,针对除第一个类目层级外的任意一个类目层级,可以根据该任意一个类目层级的前一个类目层级的分类结果,对该任意一个类目层级的多个预设类目进行筛选处理。In the process of classifying level by level in the order from the first category level to the last category level, for any category level except the first category level, you can The classification results of the previous category level are used to filter multiple preset categories at any category level.
为了便于理解,以第二个类目层级进行举例,则对于第二个类目层级来说,可以根据第一个类目层级的分类结果,确定待测对象在第一个类目层级所属的类目(为了便于区分,命名为目标类目),然后,可以筛选出第二个类目层级中的、与第一个类目层级的目标类目存在关联关系的预设类目,并根据第二个类目层级中筛选出的预设类目更新预设类目信息,使得预设类目信息中的第二个类目层级仅包括筛选出的预设类目。For ease of understanding, the second category level is used as an example. For the second category level, the classification result of the first category level can be used to determine the category to which the object to be tested belongs at the first category level. Category (named target category for ease of differentiation), then you can filter out the default categories in the second category level that are associated with the target category of the first category level, and based on The default category information filtered out in the second category level updates the default category information, so that the second category level in the default category information only includes the filtered default category.
例如,在预设类目信息中,第一个类目层级包括“衣服”、“食品”类目,“衣服”类目在第二个类目层级关联有“上衣”和“裤子”类目,“食品”类目在第二个类目层级关联有“蔬菜”和“水果”类目,如果第一个类目层级的目标类目为“衣服”,则筛选出第二个类目层级中与“衣服”类目存在关联关系的“上衣”和“裤子”类目,并更新预设类目信息,使得预设类目信息在第二个类目层级仅包括“上衣”和“裤子”类目。For example, in the default category information, the first category level includes "clothing" and "food" categories, and the "clothing" category is associated with the "tops" and "pants" categories at the second category level. , the "Food" category is associated with the "Vegetables" and "Fruits" categories at the second category level. If the target category of the first category level is "Clothes", then filter out the second category level. "Top" and "Pants" categories that are associated with the "Clothing" category, and update the default category information so that the default category information only includes "Top" and "Pants" at the second category level "Category.
通过上述方式,能够基于不同类目层级之间的类目关联关系进行逐层推理,从而能够减少计算量,同时使得不同类目层级的目标类目相关联。Through the above method, layer-by-layer reasoning can be performed based on the category association relationships between different category levels, thereby reducing the amount of calculation and at the same time correlating target categories at different category levels.
在步骤403中,根据待测对象在多个类目层级的分类结果,确定待测对象在多个类目层级的目标类目。In step 403, target categories of the object to be tested at multiple category levels are determined based on the classification results of the object to be tested at multiple category levels.
这里,针对每个类目层级,可以根据待测对象在类目层级的分类结果,确定待测对象在该类目层级的目标类目。例如,对于任意一个类目层级,当待测对象在该任意一个类目层级的分类结果是指待测对象属于该任意一个类目层级的每个预设类目的概率时,可以将其中数值最大的概率对应的预设类目作为目标类目。Here, for each category level, the target category of the object to be tested at the category level can be determined based on the classification result of the object to be tested at the category level. For example, for any category level, when the classification result of the object to be tested at any category level refers to the probability that the object to be tested belongs to each preset category of any category level, the value can be The preset category corresponding to the highest probability is used as the target category.
值得说明的是,在一些实施例中,步骤403可以在步骤402的执行过程中执行,例如,在得到待测对象在某个类目层级的分类结果后,确定待测对象在该类目层级的目标类目,从而基于推理原则,确定待测对象在下一个类目层级的分类结果。It is worth noting that in some embodiments, step 403 can be executed during the execution of step 402. For example, after obtaining the classification result of the object to be tested at a certain category level, it is determined that the object to be tested is classified at the category level. target category, thereby determining the classification result of the object to be tested at the next category level based on the inference principle.
如图4所示,本申请实施例通过逐层级分类处理,综合考虑各个类目层级的情况,能够准确地得到待测对象在每个类目层级的目标类目,按照类目系统对待测对象进行精准分类。As shown in Figure 4, the embodiment of the present application can accurately obtain the target category of the object to be tested at each category level through level-by-level classification processing and comprehensively consider the situation at each category level. According to the category system, the target category of the object to be tested can be obtained. Objects are accurately classified.
下面,将说明本申请实施例在一个实际的应用场景中的示例性应用,为了便于理解,以商品分类场景进行举例说明。Below, an exemplary application of the embodiment of the present application in an actual application scenario will be described. To facilitate understanding, a commodity classification scenario is used as an example.
步骤一:构建分类模型的训练数据。Step 1: Construct training data for the classification model.
这里,输入分类模型的数据包括三种,分别为图片信息、文本信息以及类目信息,其中,图片信息及文本信息均为商品的描述信息,图片信息可以是商品外观,文本信息可以包括商品名称、商品介绍文本等。图5是本申请实施例提供的电商平台中一个商品的展示图示例,包括商品外观51、商品名称52、商品介绍文本53以及类目信息54,其中,商品外观51包括左侧的六个小图以及右侧的一个大图。Here, the data input to the classification model includes three types, namely picture information, text information and category information. Among them, picture information and text information are both description information of the product. The picture information can be the appearance of the product, and the text information can include the name of the product. , product introduction text, etc. Figure 5 is an example of a display diagram of a product in the e-commerce platform provided by the embodiment of the present application, including product appearance 51, product name 52, product introduction text 53 and category information 54, where the product appearance 51 includes six on the left Small image and a larger image on the right.
对于样本商品(已标注类目的商品)来说,相关的图片信息、文本信息以及类目信息可以从样本商品的展示图中识别得到,或者也可以直接从电商平台的数据库中获取。For sample products (products with labeled categories), the relevant picture information, text information, and category information can be identified from the display image of the sample product, or can be obtained directly from the database of the e-commerce platform.
为了提升模型训练效果,可以准确多个样本商品,并获取每个样本商品的样本图片信息(指样本商品的图片信息,以下同理)、样本文本信息及样本类目信息,以作为分类模型的训练数据。In order to improve the model training effect, multiple sample products can be accurately identified, and the sample image information of each sample product (referring to the image information of the sample product, the same below), sample text information and sample category information can be obtained as the basis for the classification model. training data.
步骤二:通过分类模型基于训练数据进行逐层级分类。Step 2: Use the classification model to perform hierarchical classification based on the training data.
为了便于理解,将结合图6进行说明。For ease of understanding, description will be made in conjunction with FIG. 6 .
步骤1)对于每个样本商品,通过第一文本特征提取模型从样本类目信息中提取样本类目特征,通过图片特征提取模型从样本图片信息中提取样本图片特征,通过第二文本特征提取模型从样本文本信息中提取样本文本特征,样本图片特征、样本文本特征、样本类目特征分别记为I_f、T_f、C_f。Step 1) For each sample product, extract sample category features from the sample category information through the first text feature extraction model, extract sample image features from the sample image information through the image feature extraction model, and extract sample image features from the sample image information through the second text feature extraction model. Sample text features are extracted from the sample text information. Sample picture features, sample text features, and sample category features are recorded as I_f, T_f, and C_f respectively.
其中,第一文本特征提取模型、图片特征提取模型、第二文本特征提取模型均为分类模型的一部分。本申请实施例对文本特征提取模型(第一文本特征提取模型或第二文本特征提取模型)及图片特征提取模型的类型不做限定,例如文本特征提取模型可以是TextTransformer模型,图片特征提取模型可以是CNN模型或者Vision Transformer模型。Among them, the first text feature extraction model, the picture feature extraction model, and the second text feature extraction model are all part of the classification model. The embodiments of this application do not limit the types of the text feature extraction model (the first text feature extraction model or the second text feature extraction model) and the picture feature extraction model. For example, the text feature extraction model can be a TextTransformer model, and the picture feature extraction model can be It is a CNN model or a Vision Transformer model.
步骤2)对样本商品的I_f及T_f进行特征融合处理,例如可以进行求和处理,得到样本描述特征I_f+T_f。Step 2) Perform feature fusion processing on I_f and T_f of the sample product. For example, a summation process can be performed to obtain the sample description feature I_f+T_f.
步骤3)对样本商品的I_f+T_f及C_f进行线性投射处理,以投射到相同的维度。再对线性投射后的I_f+T_f及C_f进行L2归一化处理,分别得到I(对应I_f+T_f)和T(对应C_f)。线性投射处理及L2归一化处理在图6中未示出。Step 3) Perform linear projection processing on I_f+T_f and C_f of the sample product to project to the same dimension. Then perform L2 normalization processing on the linearly projected I_f+T_f and C_f to obtain I (corresponding to I_f+T_f) and T (corresponding to C_f) respectively. Linear projection processing and L2 normalization processing are not shown in FIG. 6 .
其中,L2归一化公式如下:Among them, the L2 normalization formula is as follows:
x=[x1,x2,…,xn]x=[x 1 ,x 2 ,…,x n ]
y=[y1,y2,…,yn]y=[y 1 ,y 2 ,…,y n ]
在上述公式中,x表示原始的特征向量,y表示经过L2归一化后的特征向量,n表示特征向量的维度。In the above formula, x represents the original feature vector, y represents the feature vector after L2 normalization, and n represents the dimension of the feature vector.
步骤4)对多个I和T进行穷举式的组合处理,得到多个特征组合,每个特征组合包括一个I和一个T,如图6所示,构成了特征组合矩阵,其中,I1表示第一个样本商品的I,T1表示第一个样本商品的T,其余可类推;I1.T1表示I1和T1构成的特征组合,其余可类推。Step 4) Exhaustively combine multiple I and T to obtain multiple feature combinations. Each feature combination includes an I and a T, as shown in Figure 6, forming a feature combination matrix, where I1 represents The I and T1 of the first sample product represent the T of the first sample product, and the rest can be deduced by analogy; I1.T1 represents the feature combination composed of I1 and T1, and the rest can be deduced by analogy.
对于每个特征组合,根据其内的两个特征计算在每个类目层级的类目概率分布Logits,类目概率分布可以通过向量的形式体现。For each feature combination, the category probability distribution Logits at each category level are calculated based on the two features within it. The category probability distribution can be reflected in the form of a vector.
步骤三:计算多层级损失。Step 3: Calculate multi-level loss.
对于每个类目层级,单独计算层级损失,再将所有层级损失融合为多层级损失。各个类目层级可以使用相同的损失函数,如交叉熵损失函数,公式如下:For each category level, the level loss is calculated separately, and then all level losses are merged into multi-level losses. The same loss function can be used at each category level, such as the cross-entropy loss function. The formula is as follows:
上述公式中,L表示损失值,y(i)表示第i个样本商品对应的输出结果,表示第i个样本商品对应的期望结果,N表示样本商品的数量。In the above formula, L represents the loss value, y (i) represents the output result corresponding to the i-th sample product, represents the expected result corresponding to the i-th sample product, and N represents the number of sample products.
为了便于理解,以求取第一个类目层级的层级损失的过程进行举例说明。在特征组合矩阵中,如果特征组合中的两个特征对应同一样本商品,则该特征组合为正样本(即图6中加粗的特征组合),以I1.T1为例,则I1.T1对应的类目标签Labels为One-Hot向量,One-Hot向量中数值为1的元素对应第一个样本商品(即特征组合中的两个特征对应的同一样本商品)在第一个类目层级所属的样本类目;如果特征组合中的两个特征不对应同一样本商品,则该特征组合为负样本,对应的类目标签Labels为全0向量。Logits即为输出结果,Labels即为期望结果。在此础上,按行(即按照I1.T1至I1.TN、I2.T1至I2.TN……IN.T1至IN.TN的顺序)遍历特征组合矩阵中的各个特征组合,将遍历到的特征组合对应的Logits和Labels代入到上述损失函数,再对得到的损失值进行求和得到loss_i_1;按列(即按照I1.T1至IN.T1、I1.T2至IN.T2……I1.TN至IN.TN的顺序)遍历特征组合矩阵中的各个特征组合,将遍历到的特征组合对应的Logits和Labels代入到上述损失函数,再对得到的损失值进行求和得到loss_t_1。最后,计算第一个类目层级的层级损失loss_1=(loss_i_1+loss_t_1)/2,该过程实质上是求取每个特征组合的损失值并求和的过程。For ease of understanding, the process of obtaining the hierarchical loss of the first category level is given as an example. In the feature combination matrix, if two features in the feature combination correspond to the same sample product, then the feature combination is a positive sample (that is, the bold feature combination in Figure 6). Taking I1.T1 as an example, then I1.T1 corresponds to The category label Labels is a One-Hot vector. The element with a value of 1 in the One-Hot vector corresponds to the first sample product (that is, the same sample product corresponding to the two features in the feature combination) at the first category level. sample category; if the two features in the feature combination do not correspond to the same sample product, the feature combination is a negative sample, and the corresponding category label Labels are all 0 vectors. Logits are the output results, and Labels are the expected results. On this basis, traverse each feature combination in the feature combination matrix row by row (that is, in the order of I1.T1 to I1.TN, I2.T1 to I2.TN...IN.T1 to IN.TN), and you will traverse to The Logits and Labels corresponding to the feature combination are substituted into the above loss function, and then the obtained loss values are summed to obtain loss_i_1; by column (that is, according to I1.T1 to IN.T1, I1.T2 to IN.T2...I1. The order from TN to IN.TN) traverses each feature combination in the feature combination matrix, substitutes the Logits and Labels corresponding to the traversed feature combinations into the above loss function, and then sums the obtained loss values to obtain loss_t_1. Finally, calculate the hierarchical loss loss_1=(loss_i_1+loss_t_1)/2 of the first category level. This process is essentially a process of finding the loss value of each feature combination and summing it up.
类似地,依次计算后续类目层级的层级损失,假设类目层级共有5层,则多层级损失Loss=x1*loss_1+x2*loss_2+x3*loss_3+x4*loss_4+x5*loss_5Similarly, the hierarchical losses of subsequent category levels are calculated in sequence. Assuming that there are 5 categories in total, the multi-level loss Loss=x1*loss_1+x2*loss_2+x3*loss_3+x4*loss_4+x5*loss_5
其中,loss_2表示第二个类目层级的层级损失,其余可类推;x1、x2、x3、x4、x5为自定义参数,可根据训练情况来确定,例如可分别设定为3、2、2、1、1。Among them, loss_2 represents the hierarchical loss of the second category level, and the rest can be deduced by analogy; x1, x2, x3, x4, and x5 are custom parameters that can be determined according to the training situation. For example, they can be set to 3, 2, and 2 respectively. ,1,1.
步骤四:根据多层级损失训练分类模型,直至满足停止条件。Step 4: Train the classification model based on multi-level losses until the stopping condition is met.
第五步:通过训练后的分类模型,基于推理原则来预测待测对象在多个类目层级分别所属的目标类目。其中,推理原则是指在已确定某一个类目层级的目标类目的基础上,在下一个类目层级中的、与该目标类目关联的多个预设类目的范围内进行预测。Step 5: Use the trained classification model to predict the target categories to which the object to be tested belongs at multiple category levels based on inference principles. Among them, the inference principle refers to making predictions within the range of multiple preset categories associated with the target category in the next category level on the basis of determining the target category of a certain category level.
通过本申请实施例至少可以实现以下技术效果:1)充分发挥多模态(图片和文本)的优势,综合图片和文本的信息,相较于传统的文本匹配方案,能够提升模型训练的效果以及分类的精度;2)构建多层级的分类损失函数,可以实现逐层级分类,相较于直接在最后一个类目层级进行分类的方案,精度更高,比如按照衣服-上衣-T恤这样分层级的识别会比直接识别T恤的准确度更高。Through the embodiments of this application, at least the following technical effects can be achieved: 1) Give full play to the advantages of multi-modality (pictures and text), integrate the information of pictures and text, and improve the effect of model training compared with traditional text matching solutions; Classification accuracy; 2) Constructing a multi-level classification loss function can achieve level-by-level classification. Compared with the scheme of classifying directly at the last category level, the accuracy is higher, such as clothes-tops-T-shirts. Hierarchical recognition will be more accurate than directly identifying T-shirts.
下面继续说明本申请实施例提供的分类模型训练装置2551实施为软件模块的示例性结构,在一些实施例中,如图2A所示,存储在存储器250的分类模型训练装置2551中的软件模块可以包括:样本获取模块25511,用于获取样本对象的样本描述信息及样本类目信息;样本类目信息包括样本对象在多个类目层级的样本类目;样本处理模块25512,用于通过分类模型基于样本描述信息及样本类目信息进行逐层级分类处理,得到在多个类目层级的分类结果;损失计算模块25513,用于根据同一类目层级的样本类目及分类结果进行损失计算得到层级损失,对多个类目层级分别对应的层级损失进行多层级融合处理得到多层级损失;训练模块25514,用于根据多层级损失训练分类模型;其中,训练后的分类模型用于预测待测对象在多个类目层级的分类结果。The following continues to describe an exemplary structure in which the classification model training device 2551 provided by the embodiment of the present application is implemented as a software module. In some embodiments, as shown in FIG. 2A , the software module stored in the classification model training device 2551 of the memory 250 can Includes: sample acquisition module 25511, used to obtain sample description information and sample category information of sample objects; sample category information includes sample categories of sample objects at multiple category levels; sample processing module 25512, used to pass the classification model Perform level-by-level classification processing based on sample description information and sample category information to obtain classification results at multiple category levels; the loss calculation module 25513 is used to calculate the loss based on sample categories and classification results at the same category level. Hierarchical loss: perform multi-level fusion processing on hierarchical losses corresponding to multiple category levels to obtain multi-level loss; training module 25514 is used to train the classification model based on multi-level loss; among them, the trained classification model is used to predict the test Classification results of objects at multiple category levels.
在一些实施例中,样本处理模块25512还用于通过分类模型执行以下处理:从样本描述信息中提取样本描述特征,从样本类目信息中提取样本类目特征;针对任意一个类目层级,根据样本描述特征及样本类目特征计算在任意一个类目层级的类目概率分布,以作为在任意一个类目层级的分类结果。In some embodiments, the sample processing module 25512 is also used to perform the following processing through the classification model: extract sample description features from sample description information, extract sample category features from sample category information; for any category level, according to The sample description features and sample category features calculate the category probability distribution at any category level as the classification result at any category level.
在一些实施例中,样本处理模块25512还用于:对样本描述特征及样本类目特征进行线性投射处理;对线性投射后的样本描述特征及样本类目特征进行归一化处理。In some embodiments, the sample processing module 25512 is also used to: perform linear projection processing on the sample description features and sample category features; and perform normalization processing on the linearly projected sample description features and sample category features.
在一些实施例中,样本描述信息包括多个模态的描述信息;样本处理模块25512还用于:从每个模态的描述信息中提取模态描述特征;对多个模态分别对应的模态描述特征进行特征融合处理,得到样本描述特征。In some embodiments, the sample description information includes description information of multiple modalities; the sample processing module 25512 is also used to: extract modal description features from the description information of each modality; Perform feature fusion processing on state description features to obtain sample description features.
在一些实施例中,样本对象的数量包括多个;样本处理模块25512还用于:对多个样本描述信息及多个样本类目信息进行组合处理,得到多个信息组合;每个信息组合包括一个样本描述信息及一个样本类目信息;通过分类模型基于信息组合进行逐层级分类处理,得到信息组合在多个类目层级的分类结果;损失计算模块25513,还用于针对任意一个类目层级,执行以下处理:根据信息组合对应的目标样本对象在任意一个类目层级的样本类目,确定信息组合在任意一个类目层级的类目标签;确定信息组合在任意一个类目层级的类目标签与分类结果之间的差异,以作为信息组合损失;对多个信息组合分别对应的信息组合损失进行信息组合融合处理,得到任意一个类目层级的层级损失。In some embodiments, the number of sample objects includes multiple; the sample processing module 25512 is also used to: combine multiple sample description information and multiple sample category information to obtain multiple information combinations; each information combination includes A sample description information and a sample category information; the classification model performs level-by-level classification processing based on the information combination to obtain the classification results of the information combination at multiple category levels; the loss calculation module 25513 is also used to target any category level, perform the following processing: according to the sample category of the target sample object corresponding to the information combination at any category level, determine the category target label of the information combination at any category level; determine the category of the information combination at any category level The difference between the target label and the classification result is used as the information combination loss; the information combination losses corresponding to multiple information combinations are processed by information combination fusion to obtain the hierarchical loss at any category level.
在一些实施例中,损失计算模块25513,还用于:当信息组合中的样本描述信息及样本类目信息对应同一样本对象时,将同一样本对象确定为信息组合对应的目标样本对象;当信息组合中的样本描述信息及样本类目信息对应不同样本对象时,将信息组合对应的目标样本对象确定为无对象;其中,无对象在任意一个类目层级的样本类目为无类目。In some embodiments, the loss calculation module 25513 is also used to: when the sample description information and sample category information in the information combination correspond to the same sample object, determine the same sample object as the target sample object corresponding to the information combination; when the information combination When the sample description information and sample category information in the combination correspond to different sample objects, the target sample object corresponding to the information combination is determined as no object; among them, the sample category with no object at any category level is no category.
在一些实施例中,如图2B所示,存储在存储器250的对象分类装置2552中的软件模块可以包括:目标获取模块25521,用于获取预设类目信息及待测对象的待测描述信息;其中,预设类目信息包括多个类目层级中每个类目层级的预设类目;目标处理模块25522,用于通过分类模型基于待测描述信息及预设类目信息进行逐层级分类处理,得到待测对象在多个类目层级的分类结果;确定模块25523,用于根据待测对象在多个类目层级的分类结果,确定待测对象在多个类目层级的类目。In some embodiments, as shown in FIG. 2B , the software module stored in the object classification device 2552 of the memory 250 may include: a target acquisition module 25521 for acquiring preset category information and test description information of the object to be tested. ; Among them, the preset category information includes preset categories for each category level in multiple category levels; the target processing module 25522 is used to perform layer-by-layer based on the description information to be tested and the preset category information through the classification model level classification processing to obtain the classification results of the object to be tested at multiple category levels; the determination module 25523 is used to determine the classification results of the object to be tested at multiple category levels based on the classification results of the object to be tested at multiple category levels. Head.
在一些实施例中,目标处理模块25522还用于针对任意一个类目层级,执行以下处理:根据任意一个类目层级的前一个类目层级的分类结果,对任意一个类目层级的多个预设类目进行筛选处理;根据筛选出的预设类目更新预设类目信息。In some embodiments, the target processing module 25522 is also configured to perform the following processing for any category level: based on the classification result of the previous category level of any category level, perform multiple pre-processing for any category level. Set categories for filtering processing; update the default category information based on the filtered default categories.
在一些实施例中,目标处理模块25522还用于通过分类模型执行以下处理:从待测描述信息中提取待测描述特征,从预设类目信息包括的预设类目中提取预设类目特征;根据待测描述特征及预设类目特征,计算待测对象属于预设类目特征对应预设类目的概率;针对任意一个类目层级,将待测对象分别属于任意一个类目层级的多个预设类目的概率,确定为待测对象在任意一个类目层级的分类结果。In some embodiments, the target processing module 25522 is also configured to perform the following processing through the classification model: extract the description features to be tested from the description information to be tested, and extract the preset categories from the preset categories included in the preset category information. Characteristics; based on the description characteristics to be tested and the preset category characteristics, calculate the probability that the object to be tested belongs to the preset category characteristics corresponding to the preset category; for any category level, the object to be tested belongs to any category level. The probabilities of multiple preset categories are determined as the classification results of the object to be tested at any category level.
本申请实施例提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括可执行指令,该可执行指令存储在计算机可读存储介质中。电子设备的处理器从计算机可读存储介质读取该可执行指令,处理器执行该可执行指令,使得该电子设备执行本申请实施例上述的分类模型训练方法或对象分类方法。Embodiments of the present application provide a computer program product or computer program. The computer program product or computer program includes executable instructions, and the executable instructions are stored in a computer-readable storage medium. The processor of the electronic device reads the executable instructions from the computer-readable storage medium, and the processor executes the executable instructions, so that the electronic device executes the classification model training method or object classification method described in the embodiments of the present application.
本申请实施例提供一种存储有可执行指令的计算机可读存储介质,其中存储有可执行指令,当可执行指令被处理器执行时,将引起处理器执行本申请实施例提供的方法,例如,如图3A、图3B及图3C示出的分类模型训练方法,或者如图4示出的对象分类方法。Embodiments of the present application provide a computer-readable storage medium storing executable instructions. The executable instructions are stored therein. When the executable instructions are executed by a processor, they will cause the processor to execute the method provided by the embodiments of the present application, such as , the classification model training method shown in Figure 3A, Figure 3B and Figure 3C, or the object classification method shown in Figure 4.
在一些实施例中,计算机可读存储介质可以是FRAM、ROM、PROM、EPROM、EEPROM、闪存、磁表面存储器、光盘、或CD-ROM等存储器;也可以是包括上述存储器之一或任意组合的各种设备。In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; it may also include one or any combination of the above memories. Various equipment.
在一些实施例中,可执行指令可以采用程序、软件、软件模块、脚本或代码的形式,按任意形式的编程语言(包括编译或解释语言,或者声明性或过程性语言)来编写,并且其可按任意形式部署,包括被部署为独立的程序或者被部署为模块、组件、子例程或者适合在计算环境中使用的其它单元。In some embodiments, executable instructions may take 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 their May be deployed in any form, including deployed as a stand-alone program or deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.
作为示例,可执行指令可以但不一定对应于文件系统中的文件,可以可被存储在保存其它程序或数据的文件的一部分,例如,存储在超文本标记语言(HTML,Hyper TextMarkup Language)文档中的一个或多个脚本中,存储在专用于所讨论的程序的单个文件中,或者,存储在多个协同文件(例如,存储一个或多个模块、子程序或代码部分的文件)中。As an example, executable instructions may, but do not necessarily correspond to, files in a file system and may be stored as part of a file holding other programs or data, for example, in a Hyper Text Markup Language (HTML) document. in one or more scripts, stored in a single file specific to the program in question, or in multiple collaborative files (e.g., files storing one or more modules, subroutines, or portions of code).
作为示例,可执行指令可被部署为在一个计算设备上执行,或者在位于一个地点的多个计算设备上执行,又或者,在分布在多个地点且通过通信网络互连的多个计算设备上执行。As examples, executable instructions may be deployed to execute on one computing device, or on multiple computing devices located at one location, or alternatively, on multiple computing devices distributed across multiple locations and interconnected by a communications network execute on.
以上,仅为本申请的实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和范围之内所作的任何修改、等同替换和改进等,均包含在本申请的保护范围之内。The above are only examples of the present application and are not used to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of this application are included in the protection scope of this application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311065380.2A CN117312979A (en) | 2023-08-22 | 2023-08-22 | Object classification method, classification model training method and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311065380.2A CN117312979A (en) | 2023-08-22 | 2023-08-22 | Object classification method, classification model training method and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117312979A true CN117312979A (en) | 2023-12-29 |
Family
ID=89287373
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311065380.2A Pending CN117312979A (en) | 2023-08-22 | 2023-08-22 | Object classification method, classification model training method and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117312979A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118013047A (en) * | 2024-04-03 | 2024-05-10 | 浙江口碑网络技术有限公司 | Data classification prediction method and device based on large language model |
-
2023
- 2023-08-22 CN CN202311065380.2A patent/CN117312979A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118013047A (en) * | 2024-04-03 | 2024-05-10 | 浙江口碑网络技术有限公司 | Data classification prediction method and device based on large language model |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Chen et al. | Deep reinforcement learning in recommender systems: A survey and new perspectives | |
US12182227B2 (en) | User interface for visual diagnosis of image misclassification by machine learning | |
US10719301B1 (en) | Development environment for machine learning media models | |
US11537506B1 (en) | System for visually diagnosing machine learning models | |
US20240303494A1 (en) | Method for few-shot unsupervised image-to-image translation | |
US20200097810A1 (en) | Automated window based feature generation for time-series forecasting and anomaly detection | |
US20180336453A1 (en) | Domain specific language for generation of recurrent neural network architectures | |
JP2020510910A (en) | Machine learning method and apparatus for ranking network nodes after using a network with software agents at network nodes | |
Pintea | Advances in bio-inspired computing for combinatorial optimization problems | |
US12164599B1 (en) | Multi-view image analysis using neural networks | |
CN112256537B (en) | Model running state display method and device, computer equipment and storage medium | |
CN111708823B (en) | Abnormal social account identification method and device, computer equipment and storage medium | |
CN113590863A (en) | Image clustering method and device and computer readable storage medium | |
CN113609337A (en) | Pre-training method, device, equipment and medium of graph neural network | |
US11797776B2 (en) | Utilizing machine learning models and in-domain and out-of-domain data distribution to predict a causality relationship between events expressed in natural language text | |
US20200257982A1 (en) | Categorical feature encoding for property graphs by vertex proximity | |
CN112749737A (en) | Image classification method and device, electronic equipment and storage medium | |
WO2024002167A1 (en) | Operation prediction method and related apparatus | |
WO2023050143A1 (en) | Recommendation model training method and apparatus | |
Terziyan et al. | Causality-aware convolutional neural networks for advanced image classification and generation | |
CN117251619A (en) | Data processing method and related device | |
US20240395014A1 (en) | Object recognition model updating method and apparatus, electronic device, storage medium, and computer program product | |
WO2024067779A1 (en) | Data processing method and related apparatus | |
CN112420125A (en) | Molecular attribute prediction method and device, intelligent equipment and terminal | |
Latona et al. | The ai review lottery: Widespread ai-assisted peer reviews boost paper scores and acceptance rates |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |