Commodity classification method based on adaptive extensible graph Transform

The product purchase network is constructed in product classification through an adaptive scalable graph Transformer, and scalable attention and filters are used to process product data, which solves the problem of large-scale product data processing and noise, and achieves efficient and accurate product classification.

CN118779706APending Publication Date: 2024-10-15RENMIN UNIVERSITY OF CHINA
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410935212.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

The existing technology is difficult to process large-scale product data in product classification and cannot adaptively perform filtering operations on different product nodes. Moreover, the global attention method may introduce too much noise and reduce classification accuracy.

Method used

Using an adaptive scalable graph Transformer, by building a product purchase network, using predefined polynomial filters to construct scalable attention, combining feature extraction and feature dimensionality reduction networks to generate the final representation of the product, and updating model parameters through gradient descent to achieve automatic Adaptive filtering and accurate classification.

Benefits of technology

It achieves accurate commodity classification on homomatching and heteromatching commodity trading networks, reduces time and space overhead, and improves classification efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779706A_ABST
    Figure CN118779706A_ABST
Patent Text Reader

Abstract

The invention provides a commodity classification method based on a self-adaptive extensible graph Transform. Constructing a model to output the category to which the commodity of which the category needs to be predicted belongs; the construction method of the model comprises the following steps: S1, constructing a commodity purchase network G to model commodities and commodity transaction data; s2, constructing a feature vector used for representing the attribute of each commodity node; s3, constructing a commodity token for inputting expandable attention; s4, initializing parameters of neural networks such as extensible attention, a feature extraction layer and a feature dimension reduction layer; s5, adaptive filtering is carried out on the commodity representation by using the extensible attention to generate a final representation Z of the commodity; s6, constructing a loss function on a training commodity node and updating a corresponding neural network parameter; s7, repeating the steps S5 to S6; and S8, outputting the category to which the commodity to be predicted belongs. Therefore, the problems existing in the aspects of modeling identical and different matching commodity transaction networks, running speed, storage overhead and commodity classification precision in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence, and more specifically, to a commodity classification method based on an adaptive scalable graph Transformer. Background Art

[0002] In recent years, e-commerce has developed rapidly. According to the head of the e-commerce department of the Ministry of Commerce, China's annual online retail sales reached 15.42 trillion yuan in 2023, an increase of 11%, becoming the world's largest online retail market for 11 consecutive years. The popularity of the Internet and mobile technology has made online shopping more frequent and convenient. For example, the total transaction volume of Alibaba Group's e-commerce platform in 2023 exceeded 71 trillion yuan; Pinduoduo's total e-commerce transaction volume also exceeded 40 trillion yuan. These data reveal the huge scale and huge potential of China's e-commerce market.

[0003] With the rapid development of e-commerce, product classification has become one of the key services of e-commerce platforms. The goal of product classification is to classify products into a certain category in a given list of categories. This task is very common in e-commerce platforms and involves not only the classification of products in major categories, but also the classification of various attributes of products, such as applicable life scenarios and suitable groups of people. Automated product classification can greatly save resources, improve the efficiency of e-commerce platforms, and improve user experience.

[0004] The huge amount of user browsing and purchasing behavior information on e-commerce platforms provides a rich data resource for product classification. When faced with such a large amount of commodity transaction data, it is particularly appropriate to use a complex non-Euclidean structure such as a graph to model it. In a commodity graph, nodes represent commodities, and edges represent purchase and co-occurrence relationships between commodities. By applying graph neural networks for graph representation learning, we can more effectively utilize the association information between commodities and improve the accuracy of commodity classification.

[0005] According to the relationship between the characteristics and categories of adjacent nodes, the graph can show homogeneity or heterogeneity. Homogeneity means that the connected nodes in the graph have similar characteristics and categories. For example, in an academic cooperation network, scholars with the same research direction are more likely to cooperate with each other, and the adjacent nodes in the graph are likely to have similar characteristics and categories; while heterogeneity means that adjacent nodes tend to have different characteristics and categories. For example, in a dating network, male and female nodes are more likely to connect with each other, and the adjacent nodes are likely to have different characteristics and categories. In commodity trading networks, homogeneity and heterogeneity often coexist locally. There is both homogeneity when users buy the same type of goods and heterogeneity when users buy different goods in combination.

[0006] Spectral domain polynomial filters have been proposed to filter node signals on graphs, including monomial basis, Chebyshev basis and Bernstein basis, which enhance the ability to classify products on graphs to a certain extent. However, these methods use a unified filter for all nodes on the graph, and cannot adaptively filter signals on each commodity node, making it difficult to cope with the coexistence of homogeneity and heterogeneity on commodity trading network graphs. On the other hand, traditional commodity classification methods often have difficulty processing large-scale commodity data. For example, many recent commodity classification methods have attempted to introduce attention mechanisms to provide more flexible and expressive models for commodity classification. Although these methods have enhanced classification capabilities to a certain extent, their computational overhead is often too large to be extended to large-scale commodity graphs.

[0007] The prior art related to the present invention includes: GraphTransformer and GPRGNN.

[0008] Graph Transformer is a classification technology based on the attention mechanism. Specifically, in a supervised commodity classification scenario, for a given commodity trading network, the node represents the commodity, each node has a vector representation that describes its own attribute characteristics, and the association between commodities (such as being purchased at the same time) is defined as the edge in the graph. Graph Transformer uses a multi-layer Transformer structure to capture the complex interactions and long-range dependencies between commodities through a global attention mechanism, thereby obtaining a more expressive high-level commodity representation. In a supervised learning scenario, the final representation of the commodity is input into the classifier to predict the category of the commodity. For the commodities used to train the network, GraphTransformer uses a cross-entropy loss function to measure the error between the predicted category and the true category of the commodity, and updates the model parameters through a back-propagation algorithm. Finally, the Graph Transformer model with specific parameters classifies commodities according to the characteristics and edges of commodities in the commodity trading network.

[0009] GPRGNN is a supervised commodity classification technology based on filters. For a given commodity trading network, GPRGNN transmits messages through the generalized PageRank (GPR) propagation mechanism to capture local relationships and neighbor information between nodes. In the supervised learning process, the final representation of the commodity is input into the classifier to obtain the corresponding commodity prediction value. This method also uses the cross entropy loss function to measure the prediction error and updates the model parameters through the back propagation algorithm. Finally, GPRGNN processes the commodity information based on the learned filter and classifies the commodities accordingly.

[0010] The disadvantages of existing technologies are: (1) They have high time and space overhead and are difficult to scale to large-scale product graphs. Taking the attention-based Graph Transformer model as an example, when calculating the interactions between products, O(n 2 ), where n is the number of commodities. Therefore, when faced with a large-scale commodity network, the attention-based method is not applicable in terms of storage and computational efficiency. (2) It is impossible to adaptively implement different filter operations for different commodities. The current polynomial filter method learns a unified filter for all nodes in the graph, that is, the same filtering operation is implemented for all commodities in the commodity trading network. This unified filter design is difficult to flexibly adapt to the local homogeneity or heterogeneity of the graph, which limits the expressive power of the model. The homogeneity and heterogeneity characteristics in the commodity network require a more flexible filter mechanism to accurately model, but the existing methods are insufficient in this regard. (3) The global attention method may introduce too much noise. When calculating the global attention, the existing technology needs to pay attention to the interactions between all nodes, which may introduce too much noise and reduce the accuracy of commodity classification. In a large commodity network, not all relationships between nodes are equally important, so the global attention mechanism may capture a large amount of irrelevant or interfering information, affecting the classification performance of the model. Summary of the invention

[0011] The purpose of the embodiments of the present disclosure is to provide a commodity classification method based on an adaptive and scalable graph transformer, aiming to address the limitations of existing technologies in supervised commodity classification tasks. By proposing a scalable attention mechanism, the graph transformer is suitable for large-scale commodity graphs. At the same time, through adaptive filters, the graph transformer can generate more accurate commodity representations on commodity transaction graphs with local homogeneity and heterogeneity, and obtain more accurate commodity classification results.

[0012] In a general aspect, a commodity classification method based on an adaptive scalable graph Transformer is provided, which uses input existing commodity information and transaction information to construct a model including steps S1-S8, and finally uses the model to output the category to which the commodity to be predicted belongs;

[0013] Specifically, the model is constructed as follows:

[0014] S1, based on the product information and transaction information, construct a product purchase network G to model the product and product transaction data, where the nodes in G represent different products, the edges represent two products being purchased or sold at the same time, and the structural information of G is represented by the adjacency matrix A;

[0015] S2, constructs a feature vector to represent the attributes of each product node, generates a product feature matrix X, and constructs a product category matrix for training the model

[0016] S3, constructs a commodity token for inputting scalable attention based on a predefined polynomial filter and stores it;

[0017] S4, initialize the parameters of the scalable attention, feature extraction layer and feature dimension reduction layer neural networks;

[0018] S5, reads the product token, uses scalable attention to adaptively filter the product representation, and uses feature extraction and feature dimension reduction networks to generate the final representation Z of the product;

[0019] S6, constructs a loss function on the training product node, and updates the parameters of the neural network such as the scalable attention layer, feature extraction layer, and feature dimension reduction layer through the gradient descent method;

[0020] S7, repeating steps S5 to S6 to perform model optimization and parameter update until the supervised optimization loss converges or reaches a preset maximum number of iterations, and storing the learned model parameters to disk;

[0021] S8, loads the product token and model parameters from the disk, generates the final product representation Z based on S5, and finally outputs the category of the product to be predicted according to the scoring function.

[0022] The specific method for constructing the commodity purchase network G described in S1 is as follows: for the commodity classification task in the commodity transaction network, V is used to represent the commodity node set, |V|=n, which represents the number of commodities in the graph; each commodity in the commodity transaction network is set with a unique number from 1 to n, and the user's commodity purchase history is extracted from the transaction information database, and the common purchase behavior between commodities is constructed as an edge in the commodity transaction graph; E is used to represent the relationship set between the common purchase behavior of commodities, |E|=m, which represents the number of edges of the common purchase relationship between commodities; the network structure G is represented by the adjacency matrix A, and if commodities i and j have been purchased at the same time in the transaction history database, then it is defined in the graph G that there is a connection between commodities i and j, and the corresponding position a in the adjacency matrix ij =1; if there is no common purchase record, i and j are not connected in G, and the corresponding position a in the adjacency matrix ij =0.

[0023] The specific method for constructing the feature vector of the attribute of the commodity node itself in S2 is: collect the description information of commodity i in the graph G, including the key information related to the attribute of the commodity itself, and generate a real-valued vector representation x with a dimension of d for each commodity based on the commodity description and the pre-trained model i, for n commodities, we get an n*d dimensional commodity attribute matrix X, where each row represents the attribute vector representation of a commodity, and each column represents the attribute information of different dimensions. In the supervised commodity classification scenario, we mark the categories of some commodities for subsequent training of the neural network, and record these category labels as Where N t is the number of products used for training, and C is the number of product types.

[0024] The key information related to the product's own attributes includes the product's specifications and size, color quality, production address, production date and price.

[0025] The process of constructing the commodity tokens for inputting scalable attention described in S3 is as follows: define the propagation matrix S. For K-order propagation, the matrix form of all commodity node tokens on the graph is X, SX, S 2 X,S 3 X,…,S K X, constructs node tokens using multiple strategies.

[0026] The strategies include monomial basis, Bernstein basis or Chebyshev basis.

[0027] The specific method described in S4 for initializing the parameters of neural networks such as scalable attention and feature extraction layers is to adopt Kaiming uniform initialization or Xavier initialization strategy.

[0028] The process of generating the final representation of the product by the neural network in S5 includes four steps: S51 calculating scalable attention, S52 adaptive filtering, S53 feature extraction, and S54 feature dimension reduction to obtain product representation:

[0029] S51, based on the commodity node token obtained in S3 or the commodity token obtained based on the commodity representation in S53 in the previous round, calculate the scalable attention. The specific steps are: project the i-th node token to the query matrix Key-value Then the attention matrix corresponding to each node is P i =tanh(Q i K i T )⊙B, where is the attention bias matrix, ⊙ is the Hadamard product symbol, which means the matrix and matrix Multiply the elements at corresponding positions;

[0030] S52, adaptively filter the nodes, and calculate the scalable attention matrix P for the i-th commodity node i , for P iSum by column to get K+1 coefficients α i,k , which is the coefficient of the adaptive filter for product i, then the node is characterized by Z' after the filter. i =∑ k α i,k g i,k (A,X);

[0031] S53, based on Z' i Perform feature extraction to further process the commodity node representation to obtain the representation Z i ”, for the i-th commodity node, the representation Z' after passing through the adaptive filter i , to I' i A nonlinear network is used for feature extraction to obtain the representation Z”=(σ(Z'W1))W2, where W1, W2 are the learnable neural network matrices of the feature extraction layer, and σ is a nonlinear activation function;

[0032] S54, repeat S51 to S53 for a specified number of times, and for the product representation Z obtained in the last iteration i ”, using the feature dimensionality reduction network W C will characterize Z i " is reduced to the dimension C of the number of product types and is characterized

[0033] The loss function constructed in S6 is completed based on the product representation generated in S5 and the real category of the training product in S2. Specifically, it can be divided into three steps: S61 predicting the label of the training product, S62 calculating the loss function of the training product, and S63 gradient updating:

[0034] S61, predict the label of the training product, specifically, for the final representation Z of the i-th product i , the probability of belonging to each category is Y i =softmax(Z i ), and finally take the category with the highest probability as the category of the training product;

[0035] S62, calculate the loss function of the training product: define cross entropy as the loss function. For the i-th sample, the cross entropy loss is defined as Where C is the total number of product categories, y m is the true label vector The mth element in y, where the element value is 0 or 1, 0 means that the product does not belong to the category, 1 means that the product belongs to the category, m is the predicted probability vector Y i The mth element in , for all training data, takes the average loss: Among them, N t is the number of training items, y n,mis the true label of the mth category of the nth product, with a value of 0 or 1, y n,m is the predicted probability of the mth category of the nth sample;

[0036] S63, updating the parameters in the neural network according to the degree of the loss function, specifically, performing gradient backpropagation to update the parameters of the entire model according to the loss function L on the training product calculated in S62.

[0037] The innovation of the embodiment of the present invention lies in:

[0038] The present invention can be widely used in supervised commodity classification tasks in commodity trading networks of e-commerce platforms, solving the problems of existing technologies in modeling homogeneous and heterogeneous commodity trading networks, operating speed, storage overhead, and commodity classification accuracy. The details are as follows:

[0039] (1) The present invention implements supervised graph representation learning for adaptive filtering on homogeneous and heterogeneous commodity trading networks. Conventional technology uses the same filtering operation for all commodity nodes. When applied to commodity trading networks with a large number of different homogeneous and heterogeneous patterns, the accuracy of commodity representation output by the model trained by conventional technology in classification tasks will drop significantly. For commodity nodes with different homogeneity and heterogeneity, the present invention improves the accuracy of commodity classification by adaptively selecting a suitable filter for each commodity node to process the commodity representation.

[0040] (2) The supervised learning method of the present invention has low time complexity and space overhead. On the one hand, the present invention can pre-calculate and store commodity node tokens in linear time in advance, saving supervised training time. On the other hand, the computational time complexity and space overhead of the scalable attention in the algorithm are linearly related to the number of nodes and edges in the graph. Considering the huge number of commodities on the e-commerce platform, the scalable attention mechanism designed by the present invention significantly reduces the resource overhead required by the traditional attention model. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and other objects and features of the present disclosure will become more apparent from the following description in conjunction with the accompanying drawings.

[0042] Figure 1 is a schematic diagram showing a flow chart of a commodity classification method based on an adaptive scalable graph Transformer according to an embodiment of the present disclosure;

[0043] Figure 2 is a schematic diagram showing steps of generating commodity node representation by a neural network according to an embodiment of the present disclosure;

[0044] Figure 3It is a schematic diagram showing the steps of constructing a loss function and updating parameters on a training commodity node according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0045] The following specific embodiments are provided to help the reader obtain a comprehensive understanding of the methods, devices and / or systems described herein. However, after understanding the disclosure of the present application, various changes, modifications and equivalents of the methods, devices and / or systems described herein will be clear. For example, the order of operations described herein is only an example and is not limited to those orders set forth herein, but can be changed as will be clear after understanding the disclosure of the present application, except for operations that must occur in a specific order. In addition, for greater clarity and simplicity, the description of features known in the art may be omitted.

[0046] The features described herein can be implemented in different forms and should not be construed as being limited to the examples described herein. Rather, the examples described herein have been provided to illustrate only some of the many possible ways to implement the methods, devices, and / or systems described herein, which will be clear after understanding the disclosure of the present application.

[0047] As used herein, the term "and / or" includes any one of the associated listed items and any combination of any two or more.

[0048] Although terms such as "first", "second", and "third" may be used herein to describe various members, components, regions, layers, or portions, these members, components, regions, layers, or portions should not be limited by these terms. Instead, these terms are only used to distinguish one member, component, region, layer, or portion from another member, component, region, layer, or portion. Therefore, without departing from the teachings of the examples described herein, the first member, first component, first region, first layer, or first portion referred to in the examples may also be referred to as the second member, second component, second region, second layer, or second portion.

[0049] In the specification, when an element (such as a layer, a region or a substrate) is described as being “on”, “connected to” or “coupled to” another element, the element may be directly “on”, “connected to” or “coupled to” another element, or one or more other elements may be present therebetween. Conversely, when an element is described as being “directly on”, “directly connected to” or “directly coupled to” another element, there may be no other elements present therebetween.

[0050] The terms used herein are only used to describe various examples and are not intended to limit the disclosure. Unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. The terms "comprise", "include" and "have" indicate the presence of the described features, quantities, operations, components, elements and / or combinations thereof, but do not exclude the presence or addition of one or more other features, quantities, operations, components, elements and / or combinations thereof.

[0051] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by a person of ordinary skill in the art to which the present disclosure belongs after understanding the present disclosure. Unless explicitly defined as such herein, terms (such as those defined in a general dictionary) should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and should not be interpreted in an idealized or overly formal manner.

[0052] Furthermore, in the description of examples, when it is considered that a detailed description of a well-known related structure or function would cause vague interpretation of the present disclosure, such a detailed description will be omitted.

[0053] Figure 1 It is a schematic diagram showing a commodity classification method based on an adaptive scalable graph Transformer according to an embodiment of the present disclosure.

[0054] Embodiment 1:

[0055] The overall scheme of the present invention includes steps S1-S8.

[0056] S1, construct a commodity purchase network G to model commodities and commodity transaction data, where the nodes in G represent different commodities, and the edges represent that two commodities are purchased or sold at the same time. The structural information of G can be represented by the adjacency matrix A;

[0057] The specific method for constructing the commodity purchase network G described in step S1 is: taking a commodity classification task in a large commodity trading network as an example, V is used to represent the commodity node set, |V|=n, which represents the number of commodities in the graph. Each commodity in the commodity network has a unique number 1,…,n. In order to simulate the commodity association relationship information in the commodity network, the user's commodity purchase history is extracted from the transaction information database. The joint purchase behavior between commodities forms edges in the commodity transaction graph. E is used to represent the relationship set between the joint purchase behavior of commodities, |E|=m, which represents the number of edges connecting the association relationship between commodities. The network structure G can also be represented by the adjacency matrix A. If commodities i and j have been purchased at the same time in the transaction history database, then a connection is defined between commodities i and j in the graph G, and the corresponding position A in the adjacency matrix. ij=1; if there is no common purchase record, i and j are not connected in graph G, and the corresponding position A in the adjacency matrix ij = 0. It should be noted that in the network G constructed using the common purchase relationship of commodities, the edges are undirected and unweighted.

[0058] S2, constructs a feature vector to represent the attributes of each product node, generates a product feature matrix X, and constructs a product category matrix for subsequent training models

[0059] The specific method for constructing the product feature vector in step S2 is: collect the description information of product i in the graph G, including the product's size, color quality, production address, production date, price and other key information related to the product's own attributes. Further, based on the product description and the pre-trained model (such as the large language model GPT4 or the visual model ViT), a real-valued vector representation x with a dimension of d is generated for each product. i For n products, we get an n*d-dimensional product attribute matrix X, where each row represents the attribute vector representation of a product and each column represents the attribute information of different dimensions. In addition, in the supervised product classification scenario, it is necessary to label the categories of some products for subsequent training of the neural network. These category labels are recorded as Where N t is the number of products used for training, and C is the number of product types.

[0060] S3, constructs the product token for inputting scalable attention based on the predefined polynomial filter and stores it to disk;

[0061] The specific process of calculating the product token based on the predefined filter in step S3 is as follows: for K-order propagation, the matrix form of all product node tokens on the graph is X, SX, S 2 X,S 3 X,…,S K X. Where S is the propagation matrix. It is worth noting that this step can use a variety of strategies to construct node tokens, including but not limited to monomial basis, Bernstein basis, Chebyshev basis, etc.

[0062] S4, initializes the parameters of neural networks such as scalable attention and feature extraction layers;

[0063] The initialization of the scalable attention and feature extraction neural network parameters in step S4 may specifically adopt Kaiming uniform initialization, and other initialization strategies such as Xavier may also be adopted as needed.

[0064] S5, reads the product token from the disk, uses scalable attention to adaptively filter the product representation, and uses the feature extraction network and feature dimension reduction network to generate the final representation Z of the product;

[0065] Step S5 reads the commodity node token or the previous round token from the disk, uses scalable attention for adaptive filtering, and combines the feature extraction neural network to generate the representation of the commodity node. The process includes four steps: calculating scalable attention, adaptive filtering, feature extraction, and feature dimensionality reduction:

[0066] S51, based on the commodity node token calculated in step S3 or the node token obtained based on the commodity representation in step S53 in the previous round, the specific steps of calculating the scalable attention are: projecting the node token to the query matrix Q i , key value K i . Then for each node, the corresponding attention matrix is ​​P i =tanh(Q i K i T )⊙B. Among them, is the attention bias matrix, ⊙ is the Hadamard product symbol, which means the matrix and matrix Multiply elements at corresponding positions.

[0067] S52, adaptively filter the nodes; for the scalable attention matrix P of the i-th commodity node i , for P i Sum by column to get K+1 coefficients α i,k , these K+1 coefficients are the coefficients of the adaptive filter for product i. So the node is represented by Z' after the filter. i =∑ k α i,k g i,k (A,X). In practice, we can first calculate Then, i V i Sum by row to get Z' i , where V i is the node token corresponding to the ith item. The two are equivalent.

[0068] S53, Z' based on the above steps i Perform feature extraction to further process the commodity node representation to obtain the representation Z i ”, for the i-th commodity node, the representation Z' after passing through the adaptive filter i , for Z' i A nonlinear network is used for feature extraction to obtain the representation Z”=(σ(Z'W1))W2, where W1, W2 are the learnable neural network matrices of the feature extraction layer, and σ is the nonlinear activation function.

[0069] S54, repeat steps S51 to S53 for a specified number of rounds (e.g., 2 times), and for the product representation Z obtained in the last iteration i ”, using the feature dimensionality reduction network W C will characterize Z i ” is reduced to the dimension C of the number of product types and is characterized The final representation of the i-th commodity is Z i .

[0070] S6, constructs the loss function on the training product node, and updates the parameters of the neural network such as the scalable attention, feature extraction layer and feature dimension reduction through the gradient descent method;

[0071] The construction of the supervised loss function described in step S6 is completed based on the product representation generated in S5 and the real category of the training product in S2. It can be specifically divided into three steps: predicting the label of the training product, calculating the loss function of the training product, and gradient updating:

[0072] S61, predict the label of the training product, specifically, for the final representation Z of the i-th product i , the probability of belonging to each category is Y i =softmax(Z i ), and finally take the category with the highest probability as the category of the training product.

[0073] S62, calculate the loss function of the training product, and define cross-entropy as the loss function. For the i-th sample, the cross-entropy loss is defined as Where C is the total number of product categories, y m is the true label vector The mth element in (0 or 1, 0 means the product does not belong to the category, 1 means the product belongs to the category), y m is the predicted probability vector Y i The mth element in . For all training data, take the average of the losses: Here N t is the number of training items, y n,m is the true label (1 or 0) of the mth category of the nth item, y n,m is the predicted probability of the mth category of the nth sample, that is, Y n The mth element in .

[0074] S63, updating the parameters in the neural network according to the degree of the loss function, specifically, according to the loss function L on the training product calculated in S62, using an optimizer such as Adam to perform gradient backpropagation and update the parameters of the entire model.

[0075] S7, repeat steps S5 to S6 to perform model optimization and parameter update until the supervised optimization loss converges or the algorithm reaches a preset maximum number of iterations, stop updating the model parameters, and store the final model parameters to disk.

[0076] S8, loads the product token and model parameters from the disk, generates the final product representation Z based on S5, and finally outputs the category to be predicted for the product based on the scoring function.

[0077] S8 generates the final product representation Z and performs the classification task. First, build the same network architecture as in step S5, and load the model parameters stored in step S7 from the disk after supervised optimization training. Next, read the product token matrix generated in step S3. Then, based on the token matrix, use the corresponding method to generate the product representation Z, and output the category corresponding to the maximum score of each product as the predicted category of the product.

[0078] Embodiment 2:

[0079] Taking the commodity classification task in a large e-commerce shopping website as an example, this embodiment will demonstrate the classification of commodities sold on the e-commerce platform through 8 steps, so as to output high-quality commodity labels in the scenario of supervised commodity labeling and predict the category of unknown commodities, as follows:

[0080] Step S1 is to construct a commodity co-purchase network G = (V, E). Taking the commodity classification task in a large commodity trading network as an example, V represents the commodity node set, |V| = n, which represents the number of commodities in the graph. Each commodity in the commodity network has a unique number 1,…, n. In order to simulate the commodity association information in the commodity network, we extract the user's commodity purchase history from the transaction information database. The co-purchase behavior between commodities forms edges in the commodity transaction graph. E represents the commodity association set, |E| = m, which represents the number of edges connecting the associations between commodities. The network structure G can also be represented by the adjacency matrix A. If commodities i and j have been purchased at the same time in the transaction history database, then a connection is defined between commodities i and j in the graph G, and the corresponding position A in the adjacency matrix. ij =1; if there is no common purchase record, i and j are not connected in graph G, and the corresponding position A in the adjacency matrix ij = 0. It should be noted that in the network G constructed using the common purchase relationship of commodities, the edges are undirected and unweighted.

[0081] Step S2 needs to construct an attribute vector for each product in step S1 and construct category labels for some products. Specifically, it is necessary to collect the description information of product i in graph G, including the product's size, color quality, production address, production date, price and other key information related to the product's own attributes. Then, based on this description information and a pre-trained model (such as a large language model GPT-4 or a visual model ViT), a real-valued vector representation x with a dimension of d is generated for each product. i For n products, we get an n*d dimensional product attribute matrix X, where each row of X i Represents the attribute vector of a product, and each column represents attribute information of different dimensions.

[0082] In addition, in the supervised product classification scenario, it is necessary to label the categories of some products for subsequent training of the neural network. These category labels are recorded as Where N t is the number of products used for training, and C is the number of product categories. It should be noted that the granularity of product category division is artificially determined. For example, if the granularity of product classification is finer, clothing can be further subdivided into categories such as shoes, tops, and pants. The finer the granularity of product labels, the higher the corresponding manual labeling cost. According to needs, the division strength of product categories is manually selected, and the categories of some products are recorded. Used for subsequent training models.

[0083] Step S3 constructs the commodity node tokens for subsequent input based on the commodity attribute matrix X and the predefined polynomial. Specifically, for K-order propagation, the matrix form of all node tokens on the graph is X, SX, S 2 X,S 3 X,…,S K X. Among them, S is the propagation matrix. For the i-th commodity node on the graph, the corresponding j node tokens t i,j =[S (j-1) X] i Among them, [S (j-1) X] i Represents the matrix S (j-1) The i-th row of X. It is worth noting that this step can use a variety of strategies to construct node tokens, including but not limited to monomial basis, Bernstein basis, Chebyshev basis, etc. Taking the monomial basis as an example, the propagation matrix S is D -1 A, where D is the degree matrix of the adjacency matrix A, that is, the diagonal matrix composed of the rows and sums of the adjacency matrix A. In this example, the time complexity of constructing all product node tokens is O(Kmd), m is the number of edges in the graph G, and d is the dimension of the product attribute vector. After constructing the tokens corresponding to all products, store them on disk for subsequent use.

[0084] Step S4 initializes the method network. This method uses Kaiming initialization by default, and other initialization methods such as Xavier can also be used as needed. For example, the `torch.nn.init` module in PyTorch provides the implementation of Kaming initialization and Xavier initialization.

[0085] Step S5 reads the calculated product token from the disk, uses scalable attention to adaptively filter the product representation, extracts features, and generates the final product node representation Z.

[0086] like Figure 2 As shown, step S5 can be specifically divided into four steps: calculating scalable attention, adaptive filtering, feature extraction, and feature dimensionality reduction;

[0087] S51, based on the commodity node token calculated in step S3 or the node token obtained based on the commodity representation in step S53 of the previous round, calculate the scalable attention;

[0088] For the calculated K+1 node token t corresponding to the i-th product i,0 ,…,t i,K If step S53 was executed in the previous round, then based on Z' i 'Carry out similar calculations as in step S3 to obtain the token node. Let's remember T i =[t i,0 ,…,t i,K ]. First, a simple two-layer perceptron MLP is used to perform a nonlinear transformation on the token, namely t' i,k =MLP k (t i,k ), record T' i =[t' i,0 ,…,t' i,K ]. Use the current scalable attention linear layer W respectively. q ,W k , get the query matrix Q corresponding to the i-th product i , key value K i The specific relationship is Q i =T i 'W q , K i =T i 'W k . Then for each node, the corresponding attention matrix is ​​P i =tanh(Q i K i T )⊙B. Where tanh is the hyperbolic tangent function, expressed as tanh(x)=(e x -e-x ) / (e x +e -x ). It should be noted that for any value x, the range of tanh(x) is [-1,1], which ensures the stability of the subsequent filter coefficients. B is the attention bias matrix, where B ij =β j , and β is the attention bias vector applicable to all products. The attention bias matrix provides flexibility for the filter coefficients. In this process, the attention matrix can be calculated for at least one node at a time, and the storage and time overhead of a single attention matrix is ​​O(d 2 ), the overall cost is O(nd 2 ), which is linear in the number of nodes. In addition, it can be trained using a mini-batch strategy. Therefore, attention is scalable and can theoretically be extended to graphs containing any number of commodity nodes.

[0089] S52, adaptively filter the product node representation; for the scalable attention matrix P of the i-th product i , for P i Sum by column to get K+1 coefficients α i,k , these K+1 coefficients are the coefficients of the adaptive filter for the i-th product. The product after filtering is represented as Z' i =Σ k α i,k g i,k (A,X). Among them, g i,k (A,X) is a filter based on a predetermined polynomial. Taking the monomial basis as an example, the k-th order polynomial filter corresponding to the i-th product is g i,k (A,X)=[(D -1 A) k X] i In practice, we can first calculate P i V i , and then P i V i The filtered product representation Z' is obtained by summing the columns. i , these two methods are equivalent. Here, the value matrix V i is T in S51 i .

[0090] S53, based on Z' in the above step, feature extraction is performed to further process the commodity node representation: Z" = (σ(Z'W1))W2, where W1, W2 are learnable neural network matrices of the feature extraction layer, and σ is a nonlinear activation function. Specifically, in practice, the ReLU activation function or the ELU activation function can be used. For example, the ReLU activation function is expressed as ReLU(x) = max(0,x). Usually, in practice, considering the stability of the model, normalization operations and residual connection operations are performed. That is, Z" = (σ(LN(Z')W1))W2+Z'. Where LN represents the layer normalization operation. For example, the layer normalization operation is provided in the `torch.nn.LayerNorm` module in PyTorch.

[0091] S54, repeating steps S51 to S53, and finally obtaining a representation Z for commodity classification. Specifically, repeating steps S51 to S53 for a specified round, for the commodity representation Z obtained in the last iteration i ”, for the product representation Z obtained in the last iteration i ”, using the feature dimensionality reduction network W C will characterize Z i " is reduced to the dimension C of the number of product types and is characterized Get the final representation Z of the i-th product i .

[0092] Step S6 is based on the marked product category in S2 And the product representation Z obtained in step S5, calculate the supervised loss function. Specifically, it can be divided into three steps: predicting the label of the training product, calculating the loss function of the training product, and updating the gradient.

[0093] S61, predict the label of the training product, specifically, for the final representation Z of the i-th product i , the probability of belonging to each category is Y i =softmax(Z i ), and finally take the category with the highest probability as the category of the training product.

[0094] S62, calculate the loss function of the training product, and define cross-entropy as the loss function. For the i-th sample, the cross-entropy loss is defined as Where C is the total number of product categories, y m is the true label vector The mth element in y m is the predicted probability vector Y i The loss is usually taken as the average of these losses for all training data: Here N tis the number of training items, y n,m is the true label (1 or 0) of the mth category of the nth item, y n,m is the predicted probability of the mth category for the nth sample.

[0095] S63, updating the parameters in the neural network according to the gradient is specifically based on the loss function L on the training product calculated in S62, using Adam and other optimizers for echelon backpropagation, and updating the parameters of the entire model. Specifically, the Adam optimizer contains two hyperparameters: the learning rate lr and the L2 regularization term. The learning rate lr determines the step size of the model parameter update, and the L2 regularization term is used to control the complexity of the model. For example, setting the learning rate lr to 0.01 means that each time the parameter is updated, the distance the parameter moves along the gradient direction is its gradient multiplied by 0.01; the L2 regularization term is 0.01, which means that when calculating the loss function, the additional regularization term added is the square of the L2 norm of the model parameter multiplied by 0.01. In the Adam optimizer, the learning rate lr and the L2 regularization term work together in model training to balance the step size of parameter updates and the complexity of the model, helping the model to converge better and avoid overfitting.

[0096] In step S7, the present invention repeats steps S5 to S6 to perform model optimization and parameter update until the supervised optimization loss converges or the algorithm reaches a preset maximum number of iterations, then stops updating the model parameters, and sets the final model parameters (including the neural network weights W of the scalable attention neural network) to q ,W k , an expandable attention bias vector β, a two-layer perceptron MLP for generating queries and key values i , the neural network weights W1, W2 for feature extraction and the neural network weights W for feature dimensionality reduction C ) to disk.

[0097] Specifically, the convergence of model parameter optimization in supervised learning means that in each round of iteration, the loss function value of the current round is recorded and compared with the historical lowest loss. If the loss does not decrease for a certain number of consecutive rounds, it means that the training has converged (for example, it can be set that the loss does not decrease for 20 consecutive rounds, which is considered as supervised learning convergence). At this time, store the model parameters obtained from the current round of training and stop training in advance. For example, a part of the products in the training set can be divided into a validation set. During the training process, the labels of this part of the training set are not used for model optimization and parameter update. Only the labels of this part of the products and the prediction results of the model are used to calculate the loss function. If the loss function on the validation set does not decrease within a certain number of rounds, it means that the training has converged. Otherwise, continue training until the preset maximum number of iterations is reached. After the training is completed, store the parameters of the model to disk.

[0098] Step S8 generates the final product representation Z for the classification task. First, the same network architecture as described in step S5 needs to be constructed, and the model parameters after supervised optimization training are loaded from the disk (stored after step S7). Secondly, the token matrix of the product is read (obtained after step S3). For a product i that needs to be predicted, the method uses the product representation Z i , the probability Y that the product belongs to each category i =softmax(Z i )=(y i,1 ,…,y i,C ). Select the highest y i,j The corresponding category j can be output as the predicted category of the unknown product.

[0099] Although some embodiments of the present disclosure have been shown and described, it will be appreciated by those skilled in the art that modifications may be made to the embodiments without departing from the principles and spirit of the present disclosure, the scope of which is defined by the claims and their equivalents.

Claims

1. A commodity classification method based on adaptive scalable graph Transformer, characterized in that: Using the input existing product information and transaction information, a model including steps S1-S8 is constructed, and finally the model is used to output the category to which the product to be predicted belongs; Specifically, the model is constructed as follows: S1, based on the product information and transaction information, construct a product purchase network G to model the product and product transaction data, where the nodes in G represent different products, the edges represent two products being purchased or sold at the same time, and the structural information of G is represented by the adjacency matrix A; S2, constructs a feature vector to represent the attributes of each product node, generates a product feature matrix X, and constructs a product category matrix for training the model S3, constructs a commodity token for inputting scalable attention based on a predefined polynomial filter and stores it; S4, initialize the parameters of the scalable attention, feature extraction layer and feature dimension reduction layer neural networks; S5, reads the product token, uses scalable attention to adaptively filter the product representation, and uses feature extraction and feature dimension reduction neural networks to generate the final representation Z of the product; S6, constructs a loss function on the training product node, and updates the parameters of the neural network of the scalable attention, feature extraction layer and feature dimension reduction layer by gradient descent method; S7, repeating steps S5 to S6 to perform model optimization and parameter update until the supervised optimization loss converges or reaches a preset maximum number of iterations, and storing the learned model parameters to disk; S8, loads the product token and model parameters from the disk, generates the final product representation Z based on S5, and finally outputs the category of the product to be predicted according to the scoring function.

2. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 1, characterized in that: The specific method for constructing the commodity purchase network G described in S1 is as follows: for the commodity classification task in the commodity transaction network, V is used to represent the commodity node set, |V|=n, which represents the number of commodities in the graph; each commodity in the commodity transaction network is set with a unique number from 1 to n, and the user's commodity purchase history is extracted from the transaction information database, and the common purchase behavior between commodities is constructed as an edge in the commodity transaction graph; E is used to represent the relationship set between the common purchase behavior of commodities, |E|=m, which represents the number of edges of the common purchase relationship between commodities; the network structure G is represented by the adjacency matrix A, and if commodities i and j have been purchased at the same time in the transaction history database, then it is defined in the graph G that there is a connection between commodities i and j, and the corresponding position A in the adjacency matrix ij =1; If there is no common purchase record, i and j are not connected in G, and the corresponding position A in the adjacency matrix ij =0.

3. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 2, characterized in that: The specific method for constructing the feature vector of the attribute of the commodity node itself in S2 is: collect the description information of commodity i in the graph G, including the key information related to the attribute of the commodity itself, and generate a real-valued vector representation x with a dimension of d for each commodity i based on the commodity description and the pre-trained model i , for n products, we get an n*d dimensional product attribute matrix X, where each row of X i Represents the attribute vector representation of a product. Each column represents attribute information of different dimensions. In the supervised product classification scenario, the categories of some products are marked for subsequent training of the neural network. These category labels are recorded as Where N t is the number of products used for training, and C is the number of product types.

4. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 3, characterized in that: The key information related to the product's own attributes includes the product's specifications and size, color quality, production address, production date and price.

5. A commodity classification method based on adaptive scalable graph Transformer as claimed in claim 4, characterized in that: The process of constructing the commodity tokens for inputting scalable attention described in S3 is as follows: define the propagation matrix S. For K-order propagation, the matrix form of all commodity node tokens on the graph is X, SX, S 2 X,S 3 X,…,S K X, constructs node tokens using multiple strategies.

6. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 5, characterized in that: The strategies include monomial basis, Bernstein basis or Chebyshev basis.

7. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 6, characterized in that: The specific method described in S4 for initializing the parameters of neural networks such as scalable attention and feature extraction layers is to adopt Kaiming uniform initialization or Xavier initialization strategy.

8. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 7, characterized in that: The process of extracting the final representation of the product generated by the neural network in S5 includes four steps: S51 calculating scalable attention, S52 adaptive filtering, S53 feature extraction, and S54 feature dimension reduction to obtain product representation: S51, based on the commodity node token obtained in S3 or the commodity token obtained based on the commodity representation in S53 in the previous round, calculate the scalable attention. The specific steps are: project the node token to the query matrix Q i , key value K i , and then each node corresponds to the attention matrix P i =tank(Q i K i T )⊙B, where is the attention bias matrix, ⊙ is the Hadamard product symbol, which means the matrix and matrix Multiply the elements at corresponding positions; S52, adaptively filter the nodes, and calculate the scalable attention matrix P for the i-th commodity node i , for P i Sum by column to get K+1 coefficients α i,k , which is the coefficient of the adaptive filter for product i, then the node is characterized by Z' after the filter i =∑ k α i,k g i,k (A,X), where g k (.) is a predefined filter; S53, based on Z' i Perform feature extraction to further process the commodity node representation to obtain the representation Z i ”, for the i-th commodity node, the representation Z' after passing through the adaptive filter i , for Z' i The nonlinear network is used for feature extraction to obtain the representation Z”=(σ(Z'w1))W2, where W1, W2 are the learnable neural network matrices of the feature extraction layer, and σ is the nonlinear activation function; S54, repeat S51 to S53 for a specified number of times, and for the product representation Z obtained in the last iteration i ”, using the feature dimensionality reduction network to represent Z i " is reduced to the dimension C of the number of product types and is characterized 9. A commodity classification method based on an adaptive scalable graph Transformer as claimed in claim 8, characterized in that: The loss function constructed in S6 is completed based on the product representation generated in S5 and the real category of the training product in S2. Specifically, it can be divided into three steps: S61 predicting the label of the training product, S62 calculating the loss function of the training product, and S63 gradient updating: S61, predict the label of the training product, specifically, for the i-th product, the final representation The probability of belonging to each category is Finally, the category with the highest probability is selected as the category of the training product; S62, calculate the loss function of the training product: define cross entropy as the loss function. For the i-th sample, the cross entropy loss is defined as Where C is the total number of product categories, y m is the true label vector The mth element in y, where the element value is 0 or 1, 0 means that the product does not belong to the category, 1 means that the product belongs to the category, m is the predicted probability vector Y i The mth element in takes the average loss for all training data: Among them, N t is the number of training items, y n,m is the true label of the mth category of the nth product, with a value of 0 or 1, y n,m is the predicted probability of the mth category of the nth sample, that is, Y n The mth element of ; S63, updating the parameters in the neural network according to the gradient of the loss function, specifically, performing gradient backpropagation to update the parameters of the entire model according to the loss function L on the training product calculated in S62.

10. A commodity classification method based on adaptive scalable graph Transformer according to claim 9, characterized in that: The specified number of times is an integer.

Citation Information

Cited By

  • Shape optimization and inversion method of geometric perception neural optimizer

    CN122197190A