CN117807232A - Commodity classification method, commodity classification model construction method and device - Google Patents

Commodity classification method, commodity classification model construction method and device Download PDF

Info

Publication number
CN117807232A
CN117807232A CN202311855495.1A CN202311855495A CN117807232A CN 117807232 A CN117807232 A CN 117807232A CN 202311855495 A CN202311855495 A CN 202311855495A CN 117807232 A CN117807232 A CN 117807232A
Authority
CN
China
Prior art keywords
commodity
category
features
feature
causal
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
Application number
CN202311855495.1A
Other languages
Chinese (zh)
Inventor
刘进
张萌
齐岳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan University WHU
Original Assignee
Wuhan University WHU
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Wuhan University WHU filed Critical Wuhan University WHU
Priority to CN202311855495.1A priority Critical patent/CN117807232A/en
Publication of CN117807232A publication Critical patent/CN117807232A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/213Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/25Fusion techniques
    • G06F18/253Fusion techniques of extracted features
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Business, Economics & Management (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A commodity classification method, a commodity classification model construction method and a device relate to the commodity category prediction field, and comprise the steps of obtaining a commodity text to be classified and commodity category codes, and performing splicing processing on the commodity text to be classified based on a causal enhancement learning template comprising a context feature object, a causal word and a commodity text causal reasoning feature object to obtain a target sequence; inputting the target sequence and commodity category codes into a commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighting fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified, so that the accuracy of commodity classification is improved on the basis of ensuring the commodity classification efficiency.

Description

Commodity classification method, commodity classification model construction method and device
Technical Field
The application relates to the technical field of commodity category prediction, in particular to a commodity classification method, a commodity classification model construction method and a commodity classification model construction device.
Background
With the rapid development of the internet, electronic commerce and online shopping have become mainstream channels for people to purchase goods. Under the electronic market, each commodity belongs to a certain category, and the category often belongs to a tree-shaped category system which comprises a parent category and a child category. The main goal of commodity classification is to sort commodities into different categories or categories so that shopping websites can better organize and display commodities, helping users to quickly find commodities of interest to them. However, as the number of commodities increases dramatically, how to efficiently and accurately perform automated classification of commodities remains a common problem in academia and industry.
In the related art, the mainstream commodity classification method includes two types: (1) The traditional commodity classification method generally depends on manually formulated rules and keywords, and is low in efficiency and inflexible, and cannot cope with the rapidly-growing commodity quantity and diversity; (2) With the rapid development of neural networks and deep learning in recent years, many efforts have proposed using pre-trained language models to automatically learn and extract commodity text features, such as using BERT and its variant models to map input text to high-dimensional vectors, so as to obtain a richer feature representation, but because such models have inconsistency problems in the pre-training and fine-tuning stages, the expressive ability of features and the comprehensiveness of information are weak, and thus the accuracy of commodity classification is affected. Therefore, how to effectively improve the accuracy of commodity classification on the basis of ensuring the commodity classification efficiency is a current urgent problem to be solved.
Disclosure of Invention
The application provides a commodity classification method, a commodity classification model construction method and a commodity classification model construction device, which can effectively improve the accuracy of commodity classification on the basis of ensuring commodity classification efficiency.
In a first aspect, an embodiment of the present application provides a method for classifying a commodity, where the method includes:
acquiring commodity texts to be classified and preset commodity category codes, and performing splicing processing on the commodity texts to be classified based on a preset causal reinforcement learning template to obtain a target sequence, wherein the causal reinforcement learning template comprises a context feature object, causal words and commodity text causal reasoning feature objects;
inputting the target sequence and commodity category codes into a preset commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighting fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified.
With reference to the first aspect, in one implementation manner, the performing feature extraction and dynamic weighted fusion on the target sequence to obtain a fused feature includes:
performing feature extraction on the target sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
With reference to the first aspect, in an implementation manner, the performing multi-level semantic and hierarchical feature mapping on the fusion feature and performing commodity category dependency and hierarchical feature mapping based on commodity category encoding includes:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
and taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
With reference to the first aspect, in an implementation manner, the calculating the euclidean space distance and the hyperbolic space distance based on the mapping result includes:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
and calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
In a second aspect, embodiments of the present application provide a commodity classification apparatus, including:
the processing unit is used for acquiring commodity texts to be classified and preset commodity category codes, and performing splicing processing on the commodity texts to be classified based on a preset causal reinforcement learning template to obtain a target sequence, wherein the causal reinforcement learning template comprises a context feature object, a causal word and a commodity text causal reasoning feature object;
the classification unit is used for inputting the target sequence and the commodity category code into a preset commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighted fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified.
With reference to the second aspect, in one embodiment, the performing feature extraction and dynamic weighted fusion on the input sequence to obtain a fused feature includes:
performing feature extraction on the input sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
With reference to the second aspect, in one embodiment, the performing multi-level semantic and hierarchical feature mapping on the fusion feature, and performing commodity category dependency and hierarchical feature mapping based on historical commodity category codes includes:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and the historical commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
And taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
With reference to the second aspect, in an implementation manner, the calculating the euclidean space distance and the hyperbolic space distance based on the mapping result includes:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
and calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
In a third aspect, an embodiment of the present application provides a method for constructing a commodity classification model, where the method includes:
acquiring a historical commodity text and a historical commodity category, performing splicing processing on the historical commodity text based on a preset causal reinforcement learning template to obtain an input sequence, wherein the causal reinforcement learning template comprises a context feature object, causal words and commodity text causal reasoning feature objects, encoding the historical commodity category to obtain a historical commodity category code, and the input sequence and the historical commodity category code form a data set;
the method comprises the steps of constructing a neural network model, wherein the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, and the feature extraction module is used for carrying out feature extraction and dynamic weighted fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating Euclidean space distance and hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text;
Training the neural network model based on the data set to obtain a commodity classification model so as to realize commodity classification through the commodity classification model.
In a fourth aspect, an embodiment of the present application provides a commodity classification model construction apparatus, including:
the data acquisition unit is used for acquiring a historical commodity text and a historical commodity category, splicing the historical commodity text based on a preset causal reinforcement learning template to obtain an input sequence, wherein the causal reinforcement learning template comprises a context feature object, a causal word and a commodity text causal reasoning feature object, the historical commodity category is coded to obtain a historical commodity category code, and the input sequence and the historical commodity category code form a data set;
the training unit is used for constructing a neural network model, the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, and the feature extraction module is used for carrying out feature extraction and dynamic weighting fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating Euclidean space distance and hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text; training the neural network model based on the data set to obtain a commodity classification model so as to realize commodity classification through the commodity classification model.
The beneficial effects that technical scheme that this application embodiment provided include:
splicing the commodity text to be classified through a causal reinforcement learning template comprising a context feature object, a causal word and a commodity text causal reasoning feature object so that a commodity classification model can fully understand a prediction target, and realizing dynamic semantic fusion of a context layer and a causal reasoning layer through dynamically weighting a target sequence; meanwhile, the distance weighting of the European space and the hyperbolic space is introduced, so that the semantic and hierarchical structure information of the commodity label is fully utilized, further, the automatic classification of the commodity category can be accurately realized, the commodity category classification is not needed to be manually performed, the commodity classification efficiency is effectively ensured, and the commodity category prediction accuracy is effectively improved.
Drawings
FIG. 1 is a schematic flow chart of an embodiment of a method for classifying commodities according to the present application;
fig. 2 is a schematic flow chart of an embodiment of a method for constructing a commodity classification model according to the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will clearly and completely describe the technical solution in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
In a first aspect, embodiments of the present application provide a method for classifying merchandise.
In an embodiment, referring to fig. 1, fig. 1 is a flow chart of an embodiment of a commodity classification method according to the present application. As shown in fig. 1, the commodity classification method includes:
step S10: acquiring commodity texts to be classified and preset commodity category codes, and performing splicing processing on the commodity texts to be classified based on a preset causal reinforcement learning template to obtain a target sequence, wherein the causal reinforcement learning template comprises a context feature object, causal words and commodity text causal reasoning feature objects.
By way of example, it should be understood that the merchandise text may preferably be unstructured merchandise description text, which may include information such as merchandise titles, merchandise details, etc., but which information is specifically included may be determined according to actual needs and is not limited herein. In this embodiment, a word vector characterization tool such as GloVe (Global Vectors for Word Representation, a word characterization tool based on global word frequency statistics) may be used to encode each item collected in advance, so as to obtain an item code corresponding to each item, that is, a preset item code is formed. Specifically, firstly, word segmentation is carried out on commodity categories, vector codes corresponding to terms are searched in a Glove term vector dictionary, and if the dictionary does not contain the current terms, random initialization is carried out; after the encoding of the term belonging to the current commodity category is completed, vector aggregation is carried out on a plurality of terms by adopting average pooling, and the aggregation result is used as the vector encoding of the commodity category, thus obtaining the commodity category encoding h e . It should be noted that the commodity category codes in practical application are the same as the historical commodity category codes used in the model training process.
In this embodiment, a causal enhancement-based prompt learning template (i.e., causal enhancement learning template) is pre-constructed, and the splicing of the commodity text Context1 to be classified is implemented through the causal enhancement learning template, so as to obtain a target sequence corresponding to the causal enhancement learning template.
The causal reinforcement learning template comprises a Context feature object, a causal word and a commodity text causal reasoning feature object, namely according to the commodity text Context1 to be classified, the [ CLS ] and [ SEP ] labels are respectively added before and after the commodity text Context to be classified, meanwhile, the causal word (such as 'therefore') is added in the template, and the commodity text causal reasoning feature [ MASK ] is added after the causal word, and the causal reinforcement learning template is concretely as follows:
[ CLS ] Context1[ SEP ], therefore, this commodity is of the [ MASK ] category.
It should be appreciated that in the text classification task, [ CLS ] represents the beginning of a sentence or document, [ SEP ] represents the end of a sentence or document, i.e., [ CLS ] and [ SEP ] represent contextual feature objects, [ MASK ] is a commodity text causal reasoning feature object. The user marks keywords for predicting the commodity category for the commodity text Context1 to be classified.
According to the embodiment, the causal prompt text is added, so that the commodity classification model can more fully understand the causal relation of the text, the model is helpful to understand the part prediction content of the [ MASK ], and further the commodity category prediction performance is improved.
Step S20: inputting the target sequence and commodity category codes into a preset commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighting fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified.
In this embodiment, after the target sequence is obtained, the target sequence and the commodity category code are correlated through a trained commodity classification model, so as to implement category classification prediction of the commodity text to be classified, where the commodity classification model may be any one of language models such as BERT and RoBERTa.
Specifically, after inputting a target sequence into a trained commodity classification model, respectively acquiring characteristic representations of [ CLS ], [ SEP ] and [ MASK ] positions of the last layer of the trained commodity classification model, and performing dynamic weighted fusion to obtain fusion characteristics; then accessing the fusion features into a plurality of linear layers to map to a plurality of layers corresponding to commodity categories, taking the fusion features as multi-layer commodity semantic features, and simultaneously further mapping the multi-layer semantic features into a multi-layer hyperbolic space, and taking the multi-layer semantic features as commodity layer features; for commodity categories with a hierarchical structure, the embodiment extracts the dependency characteristics among the categories by using a graph attention network and commodity category codes, and further maps the extracted category dependency characteristics into a hyperbolic space to obtain category hierarchical characteristics; respectively calculating Euclidean space distance between commodity semantic features and category dependent features, and hyperbolic space distance between commodity hierarchical features and category hierarchical features; and finally, carrying out dynamic weighted fusion on the Euclidean space distance and the hyperbolic space distance, taking the fusion result as the prediction confidence coefficient of each category under the multi-space, and selecting the category with the highest confidence coefficient as the final prediction category of the commodity text to be classified, namely, realizing the classification prediction of the commodity category by a dynamic weighted multi-space answer prediction mode.
Therefore, in the embodiment, the commodity text to be classified is spliced through the causal reinforcement learning template comprising the context feature object, the causal word and the commodity text causal reasoning feature object, so that the commodity classification model can fully understand the prediction target, and the dynamic semantic fusion of the context level and the causal reasoning level is realized through dynamically weighting the target sequence; meanwhile, the distance weighting of the European space and the hyperbolic space is introduced, so that the semantic and hierarchical structure information of the commodity label is fully utilized, further, the automatic classification of the commodity category can be accurately realized, the commodity category classification is not needed to be manually performed, the commodity classification efficiency is effectively ensured, and the commodity category prediction accuracy is effectively improved. In addition, it can be understood that in the conventional prompt learning method, the tag mapper is often required to be constructed manually after predicting the feature of the [ MASK ] position, and the complex manual design and the limited tag space severely limit the effect of prompt learning, but the embodiment avoids the complexity and limitation of selecting the tag space according to experience based on the dynamic weighted multi-space answer prediction method, and reduces the complexity of manual design while improving the prediction accuracy.
Further, in an embodiment, the performing feature extraction and dynamic weighted fusion on the target sequence to obtain a fused feature includes:
performing feature extraction on the target sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
Exemplary, in the present embodiment, the [ CLS ] of the last layer of the commodity classification model will be acquired respectively]、[SEP]AND [ MASK]Characterization of position to obtain AND [ CLS ]]And [ SEP ]]Corresponding target context feature and AND [ MASK ]]Target causal reasoning features corresponding to the positions; and the target context characteristics are maximally pooled, and then the pooled result and the target causal reasoning characteristics are dynamically weighted and fused to obtain fusion characteristics X t The method is characterized by comprising the following steps:
X t =W 1 (MaxPooling(X cls ,X sep ))+W 2 X mask
wherein X is cls 、X sep 、X mask Respectively represent [ CLS ]]、[SEP]And [ MASK ]]Is embedded in the representation of W 1 And W is 2 The dynamic weight matrix is used for controlling the contribution degree of the context feature and the commodity text causal reasoning feature, and the specific value setting can be determined according to the actual requirement and is not limited herein. It can be seen that this embodiment Dynamic semantic fusion of a context layer and a causal reasoning layer is realized by dynamically weighting the features of different positions, so that the accuracy of the classification prediction result is improved.
Further, in an embodiment, the performing multi-level semantic and hierarchical feature mapping on the fusion feature, and performing commodity category dependency and hierarchical feature mapping based on commodity category encoding includes:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
and taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
Exemplary, in the present embodiment, the fusion feature X after dynamic weighted fusion is t Accessing multiple linear layers to obtain semantic features (i.e. commodity semantic features) of Euclidean space commodity text corresponding to each layer category) The method is characterized by comprising the following steps:
in the method, in the process of the invention,characteristic representation representing the first layer of the corresponding commodity category, W' l And W is l Respectively representing the linear transformation matrix of the first layer, wherein, when l=0, +.>
Then, commodity semantic features of various eye layers based on Euclidean spaceIt is mapped into the hyperbolic space respectively, and the mapping result is used as the hierarchical structure characteristic (namely commodity hierarchical characteristic) of the space. In view of the extremely high complexity and the conversion difficulty caused by the operation of converting the euclidean space operation (including addition, subtraction, multiplication, division and the like) of the whole deep neural network into the hyperbolic space, the conversion of the euclidean space and the hyperbolic space is simplified in the embodiment.
Specifically, the semantic features of the commodity to be obtainedThe stability of the network is ensured by a linear layer and an activation function layer respectively, and the method comprises the following steps:
in the method, in the process of the invention,representing commodity semantic features->The feature obtained by processing the linear layer and the activation function layer>And->Representing the linear transformation matrix and the bias term, respectively.
For the above featuresThe hyperbolic space mapping is implemented by poincare mapping in hyperbolic spaceThe commodity hierarchy characteristics can be obtained by the following formula:
in the method, in the process of the invention,representing the hierarchical features of the commodity.
In the present embodiment, h is encoded based on the category of the commodity e And further extracting dependency characteristics among categories by adopting a graph attention network to obtain category dependency characteristics Specifically, for each category, the similarity coefficient between the category and the neighbor and between the category and the neighbor is calculated, and normalization is performed to obtain an attention coefficient alpha ij Wherein, the "neighbor" is the association between the predefined commodity categories, and the calculation formula is as follows:
wherein a (·) is a single layer feedforward neural network, [ ·II· ]]In order for the splicing operation to be performed,coding representing class i commodity category, +.>Representing coding of category j commodity, W g Representing a weight matrix of the linear transformation.
And then based on the obtained attention coefficient alpha ij Weighting and summing the features, and summing the weighted resultsAs a final category dependent feature representation.
Wherein I represents multi-head splicing operation, K represents the number of attention heads and W k Represents the weight of the kth attention header and σ represents the activation function.
Similarly, the commodity hierarchy characteristics are the same as those described aboveThe mapping method is the same as the principle, and the dependence characteristic of commodity category is->Performing hyperbolic space mapping to obtain hierarchical features of commodity categories in hyperbolic space to obtain category hierarchical features ++>
Further, in an embodiment, the calculating the euclidean space distance and the hyperbolic space distance based on the mapping result includes:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
And calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
In this embodiment, classification prediction of commodity categories will be implemented by a dynamic weighted multi-spatial answer prediction method, for example. Specifically, first, the semantic features of commodities in each level are calculatedCategory dependent features->Is to obtain the European spatial distance +.>The method comprises the following steps:
then calculating the commodity hierarchical characteristics of each levelCategory hierarchy characteristics->Is>The method comprises the following steps:
wherein,representing the operation of the Mount Wu Sijia, taking two vectors u and v as an example, the Mount Wu Sijia is calculated as follows:
finally, to European space distanceAnd hyperbolic spatial distance->Performing weighted fusion, and taking the weighted fusion result as category prediction confidence of multi-space fusion; it should be appreciated that, as the distance is greater, the confidence level should be lower, i.e., inversely related, so that the score needs to be subjected to a negative logarithmic operation to serve as the final confidence level for the purpose, specifically as follows:
the alpha and the beta are respectively used as multi-space dynamic weighting fusion parameters, and can be dynamically adjusted continuously along with the training of the model.
In a second aspect, embodiments of the present application further provide a commodity classification device.
In one embodiment, a commodity classification device includes:
the processing unit is used for acquiring commodity texts to be classified and preset commodity category codes, and performing splicing processing on the commodity texts to be classified based on a preset causal reinforcement learning template to obtain a target sequence, wherein the causal reinforcement learning template comprises a context feature object, a causal word and a commodity text causal reasoning feature object;
the classification unit is used for inputting the target sequence and the commodity category code into a preset commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighted fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified.
Further, in an embodiment, the commodity classification model is specifically configured to:
performing feature extraction on the target sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
Carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
Further, in an embodiment, the commodity classification model is specifically configured to:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
and taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
Further, in an embodiment, the commodity classification model is specifically configured to:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
and calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
The function implementation of each module in the commodity classification device corresponds to each step in the commodity classification method embodiment, and the function and implementation process of each module are not described in detail herein.
In a third aspect, an embodiment of the present application provides a method for constructing a commodity classification model.
In an embodiment, referring to fig. 2, fig. 2 is a flow chart of an embodiment of a method for constructing a commodity classification model according to the present application. As shown in fig. 2, the commodity classification model construction method includes:
step N10: the method comprises the steps of obtaining a historical commodity text and a historical commodity category, performing splicing processing on the historical commodity text based on a preset causal reinforcement learning template to obtain an input sequence, wherein the causal reinforcement learning template comprises a context feature object, causal words and commodity text causal reasoning feature objects, encoding the historical commodity category to obtain a historical commodity category code, and the input sequence and the historical commodity category code form a data set.
Illustratively, in this embodiment, data collection and preprocessing will be performed to form a data set. Specifically, historical commodity text information and historical commodity categories are collected, wherein the commodity text information comprises commodity titles, commodity details and the like, in this embodiment, the historical commodity text is taken as a commodity title as an example, and the collected historical data is preprocessed, for example, a commodity category hierarchical structure is constructed. It should be noted that, the present embodiment may use an existing event detection data set (such as AliExpress global-speed vendor data set, etc.) that may be directly used; of course, for specific requirements, the labeling data set can also be constructed by collecting commodity data for a specific e-commerce platform and adopting a manual labeling method, for example, for predefined commodity categories, the association and the subordinate relationship (such as primary category, secondary category, … and leaf category) between the commodity data set and the category hierarchy can be constructed manually.
In this embodiment, a word vector characterization tool such as GloVe (Global Vectors for Word Representation, a word characterization tool based on global word frequency statistics) may be used to encode each historical commodity category collected in advance, so as to obtain a historical commodity category code corresponding to each historical commodity category. Specifically, firstly, word segmentation is carried out on the historical commodity category, vector codes corresponding to terms are searched in a Glove word vector dictionary, and if the dictionary does not contain the current terms, random initialization is carried out; after the encoding of the term belonging to the current commodity category is completed, vector aggregation is carried out on a plurality of terms by adopting average pooling, and the aggregation result is used as the vector encoding of the historical commodity category, thus obtaining the historical commodity category encoding h e
The embodiment also constructs a causal reinforcement learning template in advance so as to realize the splicing of the historical commodity text through the causal reinforcement learning template, and further obtains an input sequence corresponding to the causal reinforcement learning template, thereby constructing a data set based on the input sequence and the coding of the historical commodity category, and dividing the data set into a training set, a verification set and a test set. The causal reinforcement learning template comprises a Context feature object, a causal word and a commodity text causal reasoning feature object, namely according to a historical commodity text Context2, the [ CLS ] and [ SEP ] labels are respectively added before and after the Context feature object, meanwhile, a causal word (such as 'therefore') is added in the template, and the commodity text causal reasoning feature [ MASK ] is added after the causal word, and the causal reinforcement learning template specifically comprises the following steps:
[ CLS ] Context2[ SEP ], therefore, this commodity is of the [ MASK ] category.
It should be appreciated that in the text classification task, [ CLS ] represents the beginning of a sentence or document, [ SEP ] represents the end of a sentence or document, i.e., [ CLS ] and [ SEP ] represent contextual feature objects, [ MASK ] is a commodity text causal reasoning feature object.
According to the embodiment, the causal prompt text is added, so that the commodity category prediction task is converted into the complete blank filling task for prompt learning, the consistency of the pre-training and fine adjustment stages is maintained, the commodity classification model can more fully understand the causal relationship of the text, the model is facilitated to understand the [ MASK ] part prediction content, and the commodity category prediction performance is further improved. The method can fully utilize rich semantic knowledge acquired in the pre-training stage through the prompt learning method so as to provide richer and more effective feature representation for the model, and further is beneficial to improving the accuracy and generalization capability of model classification.
Step N20: the method comprises the steps of constructing a neural network model, wherein the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, and the feature extraction module is used for carrying out feature extraction and dynamic weighted fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating Euclidean space distance and hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text;
For example, in this embodiment, any one of the language models such as BERT and RoBERTa may be used as a prototype to construct a neural network model; the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, wherein the feature extraction module is used for carrying out feature extraction and dynamic weighted fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating the Euclidean space distance and the hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text.
Specifically, the feature extraction module is used for respectively obtaining feature representations of [ CLS ], [ SEP ] and [ MASK ] positions of the last layer of the neural network model, and performing dynamic weighted fusion to obtain fusion features; then accessing the fusion features into a plurality of linear layers through a feature mapping module to map to a plurality of layers corresponding to commodity categories, taking the fusion features as multi-layer commodity semantic features, and simultaneously further mapping the multi-layer semantic features into a multi-layer hyperbolic space, and taking the multi-layer semantic features as commodity layer features; for commodity categories with a hierarchical structure, the embodiment extracts the dependency characteristics among the categories by using a graph attention network and historical commodity category codes, and further maps the extracted category dependency characteristics into a hyperbolic space to obtain category hierarchical characteristics; and then, respectively calculating Euclidean space distance between commodity semantic features and category dependent features and hyperbolic space distance between commodity hierarchical features and category hierarchical features through a classification prediction module, carrying out dynamic weighted fusion on the Euclidean space distance and the hyperbolic space distance, taking the fusion result as the prediction confidence coefficient of each category under multiple spaces, and selecting the category with the highest confidence coefficient as the final prediction category of the commodity text to be classified, namely, realizing classification prediction of the commodity category through a dynamic weighted multiple-space answer prediction mode.
Step N30: training the neural network model based on the data set to obtain a commodity classification model so as to realize commodity classification through the commodity classification model.
In this embodiment, the training set in the data set is used to train the constructed neural network, and the training results are respectively verified and tested by the verification set and the test set, so that the commodity classification model for realizing commodity classification can be obtained after the training is completed. It should be understood that the present embodiment relates to classifying commodities according to commodity text information, and specifically, classifying commodities of a current hierarchy with a category having the highest confidence in a predicted result for each category of the hierarchy.
It should be noted that, in the network training process of this embodiment, the cross entropy may be used as a loss function, that is, the cross entropy of each hierarchical prediction category and the real category in the calculation example is then averaged. In addition, in this embodiment, adamW may be used as an optimizer of the network, and compared with a neural network based on hyperbolic space entirely, which needs manifold optimization, such as a Riemannian-SGD or Riemannian-Adam optimizer, the learnable parameters in this embodiment are still located in euclidean space, so AdamW suitable for optimization of parameters in euclidean space may be used as an optimizer.
Therefore, in the embodiment, the historical commodity text is spliced through the causal reinforcement learning template comprising the context feature object, the causal word and the commodity text causal reasoning feature object, so that consistency of a pre-training stage and a fine-tuning stage is maintained, a commodity classification model can fully understand a prediction target, and dynamic semantic fusion of a context layer and a causal reasoning layer is realized through dynamically weighting a target sequence; meanwhile, the distance weighting of the European space and the hyperbolic space is introduced, so that the semantic and hierarchical structure information of the commodity label is fully utilized, further, the automatic classification of the commodity category can be accurately realized, the commodity category classification is not needed to be manually performed, the commodity classification efficiency is effectively ensured, and the commodity category prediction accuracy is effectively improved. In addition, it can be understood that in the conventional prompt learning method, the tag mapper is often required to be constructed manually after predicting the feature of the [ MASK ] position, and the complex manual design and the limited tag space severely limit the effect of prompt learning, but the embodiment avoids the complexity and limitation of selecting the tag space according to experience based on the dynamic weighted multi-space answer prediction method, and reduces the complexity of manual design while improving the prediction accuracy.
Further, in an embodiment, the performing feature extraction and dynamic weighted fusion on the input sequence to obtain a fused feature includes:
performing feature extraction on the input sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
In this embodiment, firstly, word segmentation is performed on the commodity text in the input sequence, and the commodity text is converted into data which can be processed in a vocabulary, namely, a plurality of terms; generating word vectors through the word vector layer, generating position codes of each term by utilizing sine-cosine transformation, taking the sum of the word vectors and the position codes as text vectors by the network input part, and taking the text vectors as network input; and extracting semantic information of sentences and dependency information among terms by using the self-attention module, and finally extracting the features of [ CLS ], [ SEP ], [ MASK ] positions of the last layer of the self-attention module to obtain target context features corresponding to [ CLS ] and [ SEP ] and target causal reasoning features corresponding to [ MASK ] positions.
Specifically, the purpose of word segmentation of commodity text is to convert the text into data that can be processed in a vocabulary, which can be expressed as w= { w 1 ,w 2 ,…,w n -w is i The term is expressed as the term which is positioned at the ith position in the commodity text after word segmentation; a corresponding n x D-dimensional word vector is then generated by the word vector layer, which may be represented as v= { v 1 ,v 2 ,…,v n And the position code p of the word vector v. The position code can be obtained based on sine and cosine transformation, and is specifically calculated as follows:
where D represents the D-th position in the D-dimensional vector, p i,2d And p i,2d+1 Respectively representing position codes corresponding to the 2d+1th position in the ith term; taking the sum of the constructed word vector v and the position code p as a text vector h:
h=v+p。
where the text vector h is n x D dimensions, preferably d=768.
Taking the text vector h as the input of the self-attention module to extract semantic information of sentences and dependency information among terms by using the self-attention module; the self-attention module may be preferably a multi-layer network, and each layer of network has the same structure (such as a multi-head attention calculating part and a feedforward neural network part).
In particular, the input features may be self-attentive computed by multiple heads in parallel through multiple head attentiveness. Wherein, for the ith self-attention head, based on the input feature h, they are first multiplied by a leachable weight matrix W, respectively Q 、W K And W is V To obtain matrices Q, K, V; then, attention calculation is carried out on the matrixes Q and K, and attention scores are obtained; and multiplying the attention score by V to obtain the attention characteristic Att i The method comprises the following specific steps:
each attention head focuses on different parts of input information, and the T attention heads are spliced and linearly transformed to obtain multi-head attention characteristics MulAtt:
MulAtt=Concat(Att 1 ,Att 2 ,…,Att T )W O
preferably, the number of attention heads t=12, the weight matrix W can be learned Q 、W K And W is V Dimension 768×64, a learnable weight matrix W O Is 768 by 768. Transmitting the acquired multi-head attention characteristic MulAtt into a feedforward neural network to perform further characteristic extraction so as to finishSelf-attention processing.
The present embodiment extracts the [ CLS ] from the last layer of the attention module]、[SEP]AND [ MASK]Characterization of position to obtain AND [ CLS ]]And [ SEP ]]Corresponding target context feature and AND [ MASK ]]Target causal reasoning features corresponding to the positions; and the target context characteristics are maximally pooled, and then the pooled result and the target causal reasoning characteristics are dynamically weighted and fused to obtain fusion characteristics X t The method is characterized by comprising the following steps:
X t =W 1 (MaxPooling(X cls ,X sep ))+W 2 X mask
wherein X is cls 、X sep 、X mask Respectively represent [ CLS ]]、[SEP]And [ MASK ]]Is embedded in the representation of W 1 And W is 2 The dynamic weight matrix is used for controlling the contribution degree of the context feature and the commodity text causal reasoning feature, and the specific value setting can be determined according to the actual requirement and is not limited herein. Therefore, the embodiment realizes the dynamic semantic fusion of the context level and the causal reasoning level by dynamically weighting the features of different positions so as to improve the accuracy of the classification prediction result.
Further, in an embodiment, the performing hierarchical feature mapping of multi-level semantics on the fusion feature and performing hierarchical feature mapping of commodity category dependence on the input sequence includes:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and the historical commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
and taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
Exemplary, in the present embodiment, dynamic weighted fusion will be performed Post fusion feature X t Accessing multiple linear layers to obtain semantic features (i.e. commodity semantic features) of Euclidean space commodity text corresponding to each layer category) The method is characterized by comprising the following steps:
in the method, in the process of the invention,characteristic representation representing the first layer of the corresponding commodity category, W' l And W is l Respectively representing the linear transformation matrix of the first layer, wherein, when l=0, +.>
Then, commodity semantic features of various eye layers based on Euclidean spaceIt is mapped into the hyperbolic space respectively, and the mapping result is used as the hierarchical structure characteristic (namely commodity hierarchical characteristic) of the space. In view of the extremely high complexity and the conversion difficulty caused by the operation of converting the euclidean space operation (including addition, subtraction, multiplication, division and the like) of the whole deep neural network into the hyperbolic space, the conversion of the euclidean space and the hyperbolic space is simplified in the embodiment.
Specifically, the semantic features of the commodity to be obtainedThe stability of the network is ensured by a linear layer and an activation function layer respectively, and the method comprises the following steps:
in the method, in the process of the invention,representing commodity semantic features->The feature obtained by processing the linear layer and the activation function layer>And->Representing the linear transformation matrix and the bias term, respectively.
For the above featuresThe hyperbolic space mapping is performed, and specifically, the poincare mapping in the hyperbolic space can be adopted, namely, commodity hierarchical characteristics can be obtained through the following formula:
/>
In the method, in the process of the invention,representing the hierarchical features of the commodity.
In the present embodiment, h is encoded based on the historic commodity category e And further extracting dependency characteristics among categories by adopting a graph attention network to obtain category dependency characteristicsSpecifically, for each category, the similarity coefficient between the category and the neighbor and between the category and the neighbor is calculated, and normalization is performed to obtain an attention coefficient alpha ij Wherein, the "neighbor" is the association between the predefined commodity categories, and the calculation formula is as follows:
wherein a (·) is a single layer feedforward neural network, [ ·II· ]]In order for the splicing operation to be performed,coding representing class i commodity category, +.>Representation->Representing coding of category j commodity, W g Representing a weight matrix of the linear transformation.
And then based on the obtained attention coefficient alpha ij Weighting and summing the features, and summing the weighted resultsAs a final category dependent feature representation.
Wherein I represents multi-head splicing operation, K represents the number of attention heads and W k Represents the weight of the kth attention header and σ represents the activation function.
Similarly, the commodity hierarchy characteristics are the same as those described aboveThe mapping method is the same as the principle, and the dependence characteristic of commodity category is->Performing hyperbolic space mapping to obtain hierarchical features of commodity categories in hyperbolic space to obtain category hierarchical features ++ >
Further, in an embodiment, the calculating the euclidean space distance and the hyperbolic space distance based on the mapping result includes:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
and calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
In this embodiment, classification prediction of commodity categories will be implemented by a dynamic weighted multi-spatial answer prediction method, for example. Specifically, first, the semantic features of commodities in each level are calculatedCategory dependent features->Is to obtain the European spatial distance +.>The method comprises the following steps:
then calculating the commodity hierarchical characteristics of each levelCategory hierarchy characteristics->Is>The method comprises the following steps:
wherein,representing the operation of the Mount Wu Sijia, taking two vectors u and v as an example, the Mount Wu Sijia is calculated as follows:
finally, to European space distanceAnd hyperbolic spatial distance->Performing weighted fusion, and taking the weighted fusion result as category prediction confidence of multi-space fusion; it should be appreciated that, as the distance is greater, the confidence level should be lower, i.e., inversely related, so that the score needs to be subjected to a negative logarithmic operation to serve as the final confidence level for the purpose, specifically as follows:
The alpha and the beta are respectively used as multi-space dynamic weighting fusion parameters, and can be dynamically adjusted continuously along with the training of the model.
In a fourth aspect, an embodiment of the present application further provides a device for constructing a commodity classification model.
In one embodiment, the commodity classification model construction device includes:
the data acquisition unit is used for acquiring a historical commodity text and a historical commodity category, splicing the historical commodity text based on a preset causal reinforcement learning template to obtain an input sequence, wherein the causal reinforcement learning template comprises a context feature object, a causal word and a commodity text causal reasoning feature object, the historical commodity category is coded to obtain a historical commodity category code, and the input sequence and the historical commodity category code form a data set;
the training unit is used for constructing a neural network model, the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, and the feature extraction module is used for carrying out feature extraction and dynamic weighting fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating Euclidean space distance and hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text; training the neural network model based on the data set to obtain a commodity classification model so as to realize commodity classification through the commodity classification model.
Further, in an embodiment, the feature extraction module is specifically configured to:
performing feature extraction on the input sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
Further, in an embodiment, the feature mapping module is specifically configured to:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and the historical commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
and taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
Further, in an embodiment, the classification prediction module is specifically configured to:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
And calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
The function implementation of each module in the commodity classification model construction device corresponds to each step in the commodity classification model construction method embodiment, and the function and implementation process of the function implementation are not described in detail herein.
It should be noted that, the foregoing embodiment numbers are merely for description, and do not represent the advantages and disadvantages of the embodiments.
The terms "comprising" and "having" and any variations thereof in the description and claims of the present application and in the foregoing drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The terms "first," "second," and "third," etc. are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order, and are not limited to the fact that "first," "second," and "third" are not identical.
In the description of embodiments of the present application, "exemplary," "such as," or "for example," etc., are used to indicate an example, instance, or illustration. Any embodiment or design described herein as "exemplary," "such as" or "for example" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary," "such as" or "for example," etc., is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B; the text "and/or" is merely an association relation describing the associated object, and indicates that three relations may exist, for example, a and/or B may indicate: the three cases where a exists alone, a and B exist together, and B exists alone, and in addition, in the description of the embodiments of the present application, "plural" means two or more than two.
In some of the processes described in the embodiments of the present application, a plurality of operations or steps occurring in a particular order are included, but it should be understood that these operations or steps may be performed out of the order in which they occur in the embodiments of the present application or in parallel, the sequence numbers of the operations merely serve to distinguish between the various operations, and the sequence numbers themselves do not represent any order of execution. In addition, the processes may include more or fewer operations, and the operations or steps may be performed in sequence or in parallel, and the operations or steps may be combined.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising several instructions for causing a terminal device to perform the method described in the various embodiments of the present application.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims of the present application.

Claims (10)

1. A method of classifying merchandise, the method comprising:
acquiring commodity texts to be classified and preset commodity category codes, and performing splicing processing on the commodity texts to be classified based on a preset causal reinforcement learning template to obtain a target sequence, wherein the causal reinforcement learning template comprises a context feature object, causal words and commodity text causal reasoning feature objects;
inputting the target sequence and commodity category codes into a preset commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighting fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified.
2. The method of claim 1, wherein the performing feature extraction and dynamic weighted fusion on the target sequence to obtain a fused feature comprises:
performing feature extraction on the target sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
3. The method of claim 1, wherein the multi-level semantic and hierarchical feature mapping of the fusion features and the commodity category dependent and hierarchical feature mapping based on commodity category encoding comprises:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
extracting dependency characteristics among categories based on the graph attention network and commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
And taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
4. The article classification method of claim 3, wherein said calculating the euclidean space distance and the hyperbolic space distance based on the mapping result comprises:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
and calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
5. A commodity classification device, characterized in that the commodity classification device comprises:
the processing unit is used for acquiring commodity texts to be classified and preset commodity category codes, and performing splicing processing on the commodity texts to be classified based on a preset causal reinforcement learning template to obtain a target sequence, wherein the causal reinforcement learning template comprises a context feature object, a causal word and a commodity text causal reasoning feature object;
the classification unit is used for inputting the target sequence and the commodity category code into a preset commodity classification model so as to enable the commodity classification model to conduct feature extraction and dynamic weighted fusion on the target sequence to obtain fusion features; carrying out multi-level semantic and hierarchical feature mapping on the fusion features, carrying out commodity category dependence and hierarchical feature mapping based on commodity category codes, and calculating Euclidean space distance and hyperbolic space distance based on mapping results; and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the commodity text to be classified.
6. The commodity classification model construction method is characterized by comprising the following steps of:
acquiring a historical commodity text and a historical commodity category, performing splicing processing on the historical commodity text based on a preset causal reinforcement learning template to obtain an input sequence, wherein the causal reinforcement learning template comprises a context feature object, causal words and commodity text causal reasoning feature objects, encoding the historical commodity category to obtain a historical commodity category code, and the input sequence and the historical commodity category code form a data set;
the method comprises the steps of constructing a neural network model, wherein the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, and the feature extraction module is used for carrying out feature extraction and dynamic weighted fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating Euclidean space distance and hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text;
Training the neural network model based on the data set to obtain a commodity classification model so as to realize commodity classification through the commodity classification model.
7. The method for constructing a commodity classification model according to claim 6, wherein said performing feature extraction and dynamic weighted fusion on the input sequence to obtain a fused feature comprises:
performing feature extraction on the input sequence based on the context feature object, the causal words and the commodity text causal reasoning feature object to obtain target context features and target causal reasoning features;
carrying out maximum pooling treatment on the target context characteristics to obtain pooling results;
and carrying out dynamic weighted fusion on the pooling result and the target causal reasoning feature to obtain a fusion feature.
8. The method of claim 6, wherein the performing multi-level semantic and hierarchical feature mapping on the fusion features and performing commodity category dependency and hierarchical feature mapping based on historical commodity category codes comprises:
performing linear transformation on the fusion features to obtain commodity semantic features;
carrying out hyperbolic space mapping on the commodity semantic features to obtain commodity hierarchical features;
Extracting dependency characteristics among categories based on the graph attention network and the historical commodity category codes to obtain category dependency characteristics;
hyperbolic space mapping is carried out on the category dependent features to obtain category hierarchical features;
and taking the commodity semantic features, commodity hierarchical features, category dependent features and category hierarchical features as mapping results.
9. The method of claim 8, wherein the calculating the euclidean space distance and the hyperbolic space distance based on the mapping result comprises:
calculating Euclidean space distance based on commodity semantic features and category dependent features;
and calculating hyperbolic space mapping based on the commodity hierarchical features and the category hierarchical features.
10. A commodity classification model construction apparatus, characterized in that the commodity classification model construction apparatus includes:
the data acquisition unit is used for acquiring a historical commodity text and a historical commodity category, splicing the historical commodity text based on a preset causal reinforcement learning template to obtain an input sequence, wherein the causal reinforcement learning template comprises a context feature object, a causal word and a commodity text causal reasoning feature object, the historical commodity category is coded to obtain a historical commodity category code, and the input sequence and the historical commodity category code form a data set;
The training unit is used for constructing a neural network model, the neural network model comprises a feature extraction module, a feature mapping module and a classification prediction module, and the feature extraction module is used for carrying out feature extraction and dynamic weighting fusion on an input sequence to obtain fusion features; the feature mapping module is used for carrying out multi-level semantic and hierarchical feature mapping on the fusion features and carrying out commodity category dependence and hierarchical feature mapping based on historical commodity category codes; the classification prediction module is used for calculating Euclidean space distance and hyperbolic space distance based on the mapping result, and carrying out dynamic weighting processing on the Euclidean space distance and the hyperbolic space distance to obtain a classification result corresponding to the historical commodity text; training the neural network model based on the data set to obtain a commodity classification model so as to realize commodity classification through the commodity classification model.
CN202311855495.1A 2023-12-29 2023-12-29 Commodity classification method, commodity classification model construction method and device Pending CN117807232A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311855495.1A CN117807232A (en) 2023-12-29 2023-12-29 Commodity classification method, commodity classification model construction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311855495.1A CN117807232A (en) 2023-12-29 2023-12-29 Commodity classification method, commodity classification model construction method and device

Publications (1)

Publication Number Publication Date
CN117807232A true CN117807232A (en) 2024-04-02

Family

ID=90431702

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311855495.1A Pending CN117807232A (en) 2023-12-29 2023-12-29 Commodity classification method, commodity classification model construction method and device

Country Status (1)

Country Link
CN (1) CN117807232A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118132752A (en) * 2024-05-06 2024-06-04 浙江口碑网络技术有限公司 Commodity description word classification method and device
CN118193743A (en) * 2024-05-20 2024-06-14 山东齐鲁壹点传媒有限公司 Multi-level text classification model based on pre-training model

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118132752A (en) * 2024-05-06 2024-06-04 浙江口碑网络技术有限公司 Commodity description word classification method and device
CN118193743A (en) * 2024-05-20 2024-06-14 山东齐鲁壹点传媒有限公司 Multi-level text classification model based on pre-training model

Similar Documents

Publication Publication Date Title
CN110298037B (en) Convolutional neural network matching text recognition method based on enhanced attention mechanism
CN111554268B (en) Language identification method based on language model, text classification method and device
CN112000791B (en) Motor fault knowledge extraction system and method
CN112733866B (en) Network construction method for improving text description correctness of controllable image
CN111026842A (en) Natural language processing method, natural language processing device and intelligent question-answering system
CN111159485B (en) Tail entity linking method, device, server and storage medium
CN111291188B (en) Intelligent information extraction method and system
CN117807232A (en) Commodity classification method, commodity classification model construction method and device
CN113343125B (en) Academic accurate recommendation-oriented heterogeneous scientific research information integration method and system
CN115599899B (en) Intelligent question-answering method, system, equipment and medium based on aircraft knowledge graph
CN114357120A (en) Non-supervision type retrieval method, system and medium based on FAQ
CN116975256B (en) Method and system for processing multisource information in construction process of underground factory building of pumped storage power station
CN117648429B (en) Question-answering method and system based on multi-mode self-adaptive search type enhanced large model
CN116842194A (en) Electric power semantic knowledge graph system and method
CN112988970A (en) Text matching algorithm serving intelligent question-answering system
CN116737922A (en) Tourist online comment fine granularity emotion analysis method and system
CN117828024A (en) Plug-in retrieval method, device, storage medium and equipment
CN112925983A (en) Recommendation method and system for power grid information
CN112613451A (en) Modeling method of cross-modal text picture retrieval model
CN111666375A (en) Matching method of text similarity, electronic equipment and computer readable medium
CN117151222A (en) Domain knowledge guided emergency case entity attribute and relation extraction method thereof, electronic equipment and storage medium
CN116881409A (en) Commodity information automatic question-answering method based on e-commerce knowledge graph
CN116955818A (en) Recommendation system based on deep learning
CN117216617A (en) Text classification model training method, device, computer equipment and storage medium
CN115730058A (en) Reasoning question-answering method based on knowledge fusion

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