Commodity recommendation method, device and equipment, storage medium and computer program product
By obtaining information about purchased items, determining the products to be recommended based on the purchase order and calculating the similarity, and determining the target recommended items in combination with the model of attention mechanism, the cold start and data density dependence problems of the existing recommendation algorithm are solved, and the accuracy and accuracy of recommendations are improved.
Patent Information
- Application Number
- CN202510026796.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-05-30
AI Technical Summary
The existing recommendation algorithms have cold start problems and the problem that recommendation accuracy depends on data density, resulting in a decrease in the accuracy of recommendations.
By obtaining the information of purchased items, determining the products to be recommended based on the purchase order, calculating the similarity between the items, constructing a similarity map, and determining the target recommended products based on the model of attention mechanism.
It improves the accuracy of product recommendations, reduces the amount of calculations, and improves the accuracy of recommended results.
Smart Images

Figure CN120069992A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular, to a product recommendation method, device, equipment, storage medium, and computer program product. Background Art
[0002] The development of the Internet industry and the popularization of various electronic devices have led to a rapid increase in the amount of data on the network. In such a big data environment, it has become increasingly difficult for users to obtain the content they need from the vast amount of data. Therefore, many enterprises, especially online shopping platforms, have begun to use personalized recommendation algorithms to filter data and present information that users may be interested in. Among the current recommendation algorithms, collaborative filtering recommendation algorithms are still the mainstream.
[0003] However, the current recommendation algorithms still have problems such as relying on cold start and the accuracy of recommendation depending on data density. This recommendation method has obvious lag and is difficult to capture the true purchase intention of users, resulting in a decrease in the accuracy of recommendation. Summary of the Invention
[0004] Embodiments of this application provide a product recommendation method, device, equipment, storage medium, and computer program product, which can improve the accuracy of product recommendation.
[0005] The technical solution of the embodiments of this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a product recommendation method, the method including:
[0007] Obtain first data; wherein, the first data includes product information of purchased products;
[0008] Determine one or more first products to be recommended based on the purchase order of the purchased products, and calculate a first similarity between each of the first products to be recommended and the purchased products;
[0009] Determine a similarity graph based on the first similarity, and determine a target recommended product based on the similarity graph and a first model; wherein, the similarity graph is used to represent the relevance between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
[0010] In a second aspect, embodiments of this application provide a product recommendation device, the product recommendation device including: an obtaining unit, a determining unit, and a calculating unit; wherein,
[0011] The obtaining unit is configured to obtain first data; wherein, the first data includes product information of purchased products;
[0012] The determining unit is configured to determine one or more first products to be recommended based on the purchase order of the purchased products;
[0013] The calculating unit is configured to calculate a first similarity between each of the first products to be recommended and the purchased products;
[0014] The determining unit is further configured to determine a similarity graph based on the first similarity, and determine a target recommended product based on the similarity graph and a first model; wherein, the similarity graph is used to represent the correlation between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, which includes: a processor and a memory; wherein,
[0016] The memory is configured to store a computer program that can run on the processor;
[0017] The processor is configured to execute the product recommendation method as described above when running the computer program.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program code is stored, and when the computer program code is executed by a computer, the product recommendation method as described above is implemented.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the product recommendation method as described above is implemented.
[0020] An embodiment of the present application provides a product recommendation method, device, equipment, storage medium, and computer program product. The method includes: obtaining first data, where the first data includes product information of purchased products; determining one or more first products to be recommended based on the purchase order of the purchased products, and calculating a first similarity between each first product to be recommended and the purchased products; determining a similarity graph based on the first similarity, and determining target recommended products based on the similarity graph and a first model, where the similarity graph is used to represent the relevance between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism. It can be seen that after obtaining the first data, one or more first products to be recommended can be determined based on the purchase order of the purchased products, and the first similarity between each first product to be recommended and the purchased products can be calculated. That is, the first products to be recommended in the embodiments of the present application are determined based on the purchase order of the purchased products, so as to improve the accuracy of subsequent recommended products. Then, a similarity graph can be determined based on the first similarity, and target recommended products can be determined based on the similarity graph and the first model. Among them, the first model includes an attention mechanism, that is, the embodiments of the present application can determine the target recommended products through the attention mechanism in the first model, so as to improve the accuracy of the recommendation result while reducing the calculation amount. Description of the Drawings
[0021] Figure 1 Schematic diagram of the product recommendation method proposed by the embodiment of the present application Figure 1 ;
[0022] Figure 2 Schematic diagram of the product recommendation method proposed by the embodiment of the present application Figure 2 ;
[0023] Figure 3 Schematic diagram of the composition structure of the product recommendation device proposed by the embodiment of the present application;
[0024] Figure 4 Schematic diagram of the composition structure of the electronic device proposed by the embodiment of the present application. Detailed Embodiments
[0025] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. It can be understood that the specific embodiments described herein are only used to explain the related application, rather than limiting the application. In addition, it should be noted that, for the sake of description, only parts related to the related application are shown in the drawings.
[0026] The development of the Internet industry and the popularization of various electronic devices have led to a rapid growth in the amount of data on the network. In such a big data environment, it has become increasingly difficult for users to obtain the content they need from the vast amount of data. Therefore, many companies, especially online shopping platforms, have started to use personalized recommendation algorithms to filter data and present information that users may be interested in. Among the current recommendation algorithms, collaborative filtering recommendation algorithms are still the mainstream of recommendation algorithms.
[0027] However, the current recommendation algorithms still have problems such as relying on cold start and the accuracy of recommendations depending on data density. This way of recommendation has obvious lag, and it is difficult to capture the real purchase intention of users, resulting in a decrease in the accuracy of recommendations.
[0028] To solve the problem of the decrease in the accuracy of the current recommendation algorithms, the embodiments of this application provide a commodity recommendation method, device, equipment, storage medium, and computer program product. The method includes: obtaining first data; where the first data includes the commodity information of the purchased commodities; determining one or more first commodities to be recommended based on the purchase order of the purchased commodities, and calculating the first similarity between each first commodity to be recommended and the purchased commodities; determining a similarity graph based on the first similarity, and determining target recommended commodities based on the similarity graph and a first model; where the similarity graph is used to represent the correlation between the purchased commodities and one or more second commodities to be recommended, the second commodities to be recommended include the first commodities to be recommended, and the first model includes an attention mechanism. Thus, after obtaining the first data, one or more first commodities to be recommended can be determined based on the purchase order of the purchased commodities, and the first similarity between each first commodity to be recommended and the purchased commodities can be calculated. That is, the first commodities to be recommended in the embodiments of this application are determined based on the purchase order of the purchased commodities, so as to improve the accuracy of the subsequent recommended commodities. Then, a similarity graph can be determined based on the first similarity, and target recommended commodities can be determined based on the similarity graph and the first model; where the first model includes an attention mechanism, that is, the embodiments of this application can determine the target recommended commodities through the attention mechanism in the first model, so as to improve the accuracy of the recommendation results while reducing the calculation amount.
[0029] Next, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application.
[0030] The embodiments of this application provide a commodity recommendation method, Figure 1 which is a schematic diagram of the commodity recommendation method proposed in the embodiments of this application Figure 1 As Figure 1 shown, the commodity recommendation method may include the following steps:
[0031] Step 101: Obtain the first data; among them, the first data includes the product information of the purchased products.
[0032] In the embodiments of the present application, the product recommendation device may obtain the first data.
[0033] It should be noted that, in the embodiments of the present application, the first data may include the product information of the purchased products, or may include other information. The present application does not make specific limitations on the data type and data quantity included in the first data.
[0034] Step 102: Determine one or more first products to be recommended based on the purchase order of the purchased products, and calculate the first similarity between each first product to be recommended and the purchased products.
[0035] In the embodiments of the present application, after obtaining the first data, the product recommendation device may determine one or more first products to be recommended based on the purchase order of the purchased products, and calculate the first similarity between each first product to be recommended and the purchased products.
[0036] Exemplarily, in the embodiments of the present application, when the product recommendation device determines one or more first products to be recommended based on the purchase order of the purchased products, assuming that the purchased product is a computer, the first products to be recommended may be determined to include a mouse, a keyboard, a mouse pad, etc. The present application does not make specific limitations on the quantity and type of the first products to be recommended.
[0037] That is to say, in the embodiments of the present application, the product recommendation device may determine one or more first products to be recommended based on the purchase order of the purchased products. For example, a person who has bought a computer is very likely to buy a mouse again, and a person who has bought a car is very likely to buy some car decorations; on the contrary, a person who has bought a mouse is less likely to buy a computer, and a person who has bought car decorations is also less likely to buy a car again. If corresponding recommendations can be made at the right time, the conversion rate can be improved to a greater extent.
[0038] It should be noted that, in the embodiments of the present application, before calculating the first similarity between each first product to be recommended and the purchased products, the product recommendation device may obtain the first feature vector corresponding to the purchased products, and obtain the second feature vector corresponding to each first product to be recommended; among them, the first feature vector and the second feature vector include N-dimensional vectors; then the first feature vector may be subjected to a first preset process to obtain a third feature vector, and each second feature vector may be subjected to a first preset process to obtain a fourth feature vector.
[0039] It should be noted that in the embodiments of the present application, when the commodity recommendation device performs a first preset process on the first feature vector, it may perform a normalization process on the first feature vector to prevent feature vectors with too small values from being submerged, avoid the influence of outliers and extreme values, and at the same time, it can also improve the density of long-tail data and reduce the calculation error caused by low-density data. The present application does not specifically limit the manner of the first preset process.
[0040] It should be noted that in the embodiments of the present application, when the commodity recommendation device performs a first preset process on each second feature vector, it may also perform a normalization process on the second feature vector, and at the same time, it can also improve the density of long-tail data.
[0041] It should be noted that in the embodiments of the present application, after the commodity recommendation device performs a first preset process on the first feature vector to obtain a third feature vector, and performs a first preset process on each second feature vector to obtain a fourth feature vector, it may calculate a first similarity between each first commodity to be recommended and the purchased commodities.
[0042] It should be noted that in the embodiments of the present application, when the commodity recommendation device calculates the first similarity between each first commodity to be recommended and the purchased commodities, it may determine a first mean based on the third feature vector and each fourth feature vector; wherein, the first mean includes the mean of the third feature vector and each fourth feature vector in the i-th dimension, and i is a positive integer; then it may determine the first similarity based on the third feature vector, each fourth feature vector, and the first mean.
[0043] Exemplarily, in the embodiments of the present application, when the commodity recommendation device calculates the first similarity between each first commodity to be recommended and the purchased commodities, it may be calculated through the following formula (1).
[0044]
[0045] Wherein, a i represents the N-dimensional vector corresponding to the purchased commodity (i.e., the third feature vector), b i represents the N-dimensional vector corresponding to the first commodity to be recommended (i.e., the fourth feature vector), represents the first mean, and SIM(a->b) represents the first similarity between the first commodity to be recommended and the purchased commodity.
[0046] That is to say, in the embodiments of the present application, as shown in the above formula (1), when the product recommendation device calculates the first similarity between each first product to be recommended and the purchased products, it can first calculate the mean of the lengths of each feature vector (i.e., the first mean), and then calculate the cosine similarity value after subtracting the mean from each feature vector, which can reduce the problem that the calculation result accuracy is affected due to the insensitivity of the cosine function to the numerical size.
[0047] Step 103: Determine a similarity graph based on the first similarity, and determine a target recommended product based on the similarity graph and the first model; wherein, the similarity graph is used to represent the relevance between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
[0048] In the embodiments of the present application, after the product recommendation device determines one or more first products to be recommended based on the purchase order of the purchased products and calculates the first similarity between each first product to be recommended and the purchased products, it can determine a similarity graph based on the first similarity, and determine a target recommended product based on the similarity graph and the first model.
[0049] It should be noted that, in the embodiments of the present application, the similarity graph can be used to represent the relevance between the purchased products and one or more second products to be recommended. For example, if the probability of purchasing product b is very high after the user purchases product a, and the probability of purchasing product c is very high after purchasing product b, then a similarity graph in the form of a->b->c can be deduced from the data of product a. The present application does not make specific limitations on the quantity and type of the similarity graph.
[0050] It should be noted that, in the embodiments of the present application, the first model can be a Transformer model or other models. The present application does not make specific limitations on the type of the first model.
[0051] It should be noted that, in the embodiments of the present application, the first model can include an attention mechanism. The present application does not make specific limitations on the number and type of modules included in the first model.
[0052] It should be noted that, in the embodiments of the present application, when the commodity recommendation device determines the similarity graph based on the first similarity, it may screen out the second similarity based on the first similarity; wherein, the second similarity includes the top L similarities in the first similarity, and L is a positive integer; then it may determine the third recommended commodity corresponding to each second similarity, and determine the corresponding fourth recommended commodity based on the third recommended commodity; wherein, the first recommended commodity includes the third recommended commodity, and the second recommended commodity includes the fourth recommended commodity; generate the first data set based on the purchased commodity, the third recommended commodity, and the fourth recommended commodity; wherein, the first data set includes Q similarity graphs, and Q is a positive integer.
[0053] Exemplarily, in the embodiments of the present application, the commodity recommendation device may screen out the second similarity based on the first similarity. Assuming that L is 3, then the top 3 similarities in the first similarity may be screened out as the second similarity. Then it may determine the third recommended commodity corresponding to each second similarity, and further determine the corresponding fourth recommended commodity based on the third recommended commodity, so as to generate the first data set based on the purchased commodity, the third recommended commodity, and the fourth recommended commodity.
[0054] It should be noted that, in the embodiments of the present application, when the commodity recommendation device determines the corresponding fourth recommended commodity based on the third recommended commodity, for each third recommended commodity, it may determine the third similarity between the third recommended commodity and P fifth recommended commodities; then it may perform a screening process on the third similarity to obtain the top L fourth similarities; wherein, the third similarity includes the fourth similarity; and further determine the recommended commodity corresponding to each fourth similarity as the fourth recommended commodity.
[0055] Exemplarily, in the embodiments of the present application, assuming that the purchased product is a computer, the third recommended commodities may include a keyboard, a mouse, and a computer stand; for each third recommended commodity, it may determine the third similarity between the third recommended commodity and P fifth recommended commodities. Assuming that L is 3, perform a screening process on the third similarity to obtain the top 3 fourth similarities, and then it may determine the recommended commodity corresponding to each fourth similarity as the fourth recommended commodity. For the keyboard among the third recommended commodities, assuming that the corresponding fourth recommended commodities may include a keyboard cleaning brush, a keyboard sticker, etc., and further generate the first data set based on the purchased commodity, the third recommended commodity, and the fourth recommended commodity. For example, one of the similarity graphs may be computer -> keyboard -> keyboard cleaning brush. The present application does not make specific limitations on the quantity and structure of the similarity graphs.
[0056] It should be noted that in the embodiments of the present application, after the product recommendation device determines the similarity graph based on the first similarity, it can determine the target recommended product based on the similarity graph and the first model.
[0057] Further, in the embodiments of the present application, when the product recommendation device determines the target recommended product based on the similarity graph and the first model, it can input the first data set into the first model, and then calculate the first node feature corresponding to the third product to be recommended based on the attention mechanism, and calculate the second node feature corresponding to the fourth product to be recommended; furthermore, it can determine the target recommended product based on the first node feature and the second node feature.
[0058] It should be noted that in the embodiments of the present application, when the product recommendation device calculates the first node feature corresponding to the third product to be recommended based on the attention mechanism, it can determine the first weight parameter between the purchased product and the third product to be recommended based on the second similarity, the first function, and the second function; then it can determine the first attention weight corresponding to the third product to be recommended based on the first weight parameter, the first preset threshold, and the second similarity; furthermore, it can determine the first node feature corresponding to the third product to be recommended based on the first attention weight and the second similarity.
[0059] It should be noted that in the embodiments of the present application, the first function can be an activation function, such as the LeakyReLu function, and the present application does not specifically limit the type of the first function.
[0060] It should be noted that in the embodiments of the present application, the second function can be a join function for connection operations, and the present application does not specifically limit the type of the second function.
[0061] It should be noted that in the embodiments of the present application, the first preset threshold can be any value greater than 0, and the present application does not specifically limit the size of the first preset threshold.
[0062] Exemplarily, in the embodiments of the present application, when the product recommendation device determines the first weight parameter between the purchased product and the third product to be recommended based on the second similarity, the first function, and the second function, it can be calculated through the following formula (2).
[0063] Arg ab =LeakyReLu(join(r a ,SIM(a->b))) (2)
[0064] where Arg ab represents the first weight parameter, LeakyReLu represents the first function, join represents the second function, r a represents the node feature of the purchased product, and SIM(a->b) represents the second similarity.
[0065] It should be noted that, in the embodiments of the present application, when the commodity recommendation device determines the first attention weight corresponding to the third to-be-recommended commodity based on the first weight parameter, the first preset threshold, and the second similarity, it may perform a screening process on the second similarity based on the first preset threshold to obtain a first screening result; wherein, the first screening result includes a fifth similarity, and the fifth similarity includes the similarities in the second similarity that are greater than the first preset threshold; then the first attention weight may be determined based on the fifth similarity and the first weight parameter.
[0066] Exemplarily, in the embodiments of the present application, when the commodity recommendation device determines the first attention weight corresponding to the third to-be-recommended commodity based on the first weight parameter, the first preset threshold, and the second similarity, it can be obtained by calculating using the following formula (3).
[0067]
[0068] where, w ab represents the first attention weight, β represents the first preset threshold, c is the set of all products with SIM(a->b)>β (i.e., the fifth similarity), and Arg ab represents the first weight parameter.
[0069] Exemplarily, in the embodiments of the present application, when the commodity recommendation device determines the first node feature corresponding to the third to-be-recommended commodity based on the first attention weight and the second similarity, it can be obtained by calculating using the following formula (4).
[0070]
[0071] It should be noted that, in the embodiments of the present application, when the commodity recommendation device calculates the second node feature corresponding to the fourth to-be-recommended commodity, it may determine the second weight parameter between the purchased commodity and the fourth to-be-recommended commodity based on the fourth similarity, the first function, and the second function; then it may determine the second attention weight corresponding to the fourth to-be-recommended commodity based on the second weight parameter, the second preset threshold, and the fourth similarity; and further, it may determine the second node feature corresponding to the fourth to-be-recommended commodity based on the second attention weight and the fourth similarity.
[0072] It should be noted that, in the embodiments of the present application, when the commodity recommendation device determines the second attention weight corresponding to the fourth to-be-recommended commodity based on the second weight parameter, the second preset threshold, and the fourth similarity, it may perform a screening process on the fourth similarity based on the second preset threshold to obtain a second screening result; wherein, the second screening result includes a sixth similarity, and the sixth similarity includes the similarities in the fourth similarity that are greater than the second preset threshold; then the second attention weight may be determined based on the sixth similarity and the second weight parameter.
[0073] It should be noted that in the embodiments of the present application, when the product recommendation device determines the second weight parameter between the purchased product and the fourth product to be recommended based on the fourth similarity, the first function, and the second function, it can be obtained by calculating using the above formula (2).
[0074] It should be noted that in the embodiments of the present application, when the product recommendation device determines the second attention weight corresponding to the fourth product to be recommended based on the second weight parameter, the second preset threshold, and the fourth similarity, it can be obtained by calculating using the above formula (3).
[0075] It should be noted that in the embodiments of the present application, when the product recommendation device determines the second node feature corresponding to the fourth product to be recommended based on the second attention weight and the fourth similarity, it can be obtained by calculating using the above formula (4).
[0076] Furthermore, in the embodiments of the present application, after the product recommendation device calculates the first node feature corresponding to the third product to be recommended based on the attention mechanism and calculates the second node feature corresponding to the fourth product to be recommended, it can determine the target recommended product based on the first node feature and the second node feature.
[0077] It should be noted that in the embodiments of the present application, when the product recommendation device determines the target recommended product based on the first node feature and the second node feature, it can calculate the association rules between each product and the purchased product based on the first node feature and the second node feature, and then recommend the products of the user based on the association rules.
[0078] That is to say, in the embodiments of the present application, through the attention mechanism in the first model, the first model can adaptively learn the attention weights of different region vectors in the sequence. In this way, the first model can pay more attention to important products, such as product vectors with a high similarity to the products that the user intends to purchase, so as to generate more accurate recommendation results.
[0079] In summary, the product recommendation device can determine one or more first products to be recommended based on the purchase order of the purchased products. Then, it can obtain the first feature vectors corresponding to the purchased products and the second feature vectors corresponding to each first product to be recommended. It can perform a first preset process on the first feature vectors to obtain third feature vectors, and perform a first preset process on each second feature vector to obtain fourth feature vectors. Furthermore, it can determine a first mean value based on the third feature vectors and each fourth feature vector, and determine a first similarity based on the third feature vectors, each fourth feature vector, and the first mean value. That is, when calculating the first similarity between each first product to be recommended and the purchased products, the product recommendation device can first calculate the mean value of the lengths of each feature vector (i.e., the first mean value), and then calculate the cosine similarity value after subtracting the mean value from each feature vector. This can reduce the problem that the calculation result accuracy is affected due to the insensitivity of the cosine function to the numerical size. Finally, it can determine a similarity graph based on the first similarity, and determine the target recommended products based on the similarity graph and the first model. Through the attention mechanism in the first model, it can pay more attention to important products, such as product vectors with a higher similarity to the products that the user intends to purchase, so as to generate more accurate recommendation results.
[0080] An embodiment of the present application provides a product recommendation method, which includes: obtaining first data; where the first data includes the product information of the purchased products; determining one or more first products to be recommended based on the purchase order of the purchased products, and calculating the first similarity between each first product to be recommended and the purchased products; determining a similarity graph based on the first similarity, and determining the target recommended products based on the similarity graph and the first model; where the similarity graph is used to represent the correlation between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism. It can be seen that after obtaining the first data, one or more first products to be recommended can be determined based on the purchase order of the purchased products, and the first similarity between each first product to be recommended and the purchased products can be calculated. That is, the first products to be recommended in the embodiment of the present application are determined based on the purchase order of the purchased products, so as to improve the accuracy of the subsequent recommended products. Then, a similarity graph can be determined based on the first similarity, and the target recommended products can be determined based on the similarity graph and the first model; where the first model includes an attention mechanism, that is, the embodiment of the present application can determine the target recommended products through the attention mechanism in the first model, so as to improve the accuracy of the recommendation results while reducing the calculation amount.
[0081] Based on the above embodiment, another embodiment of the present application provides a product recommendation method. Figure 2 Schematic diagram of the product recommendation method proposed in the embodiment of the present application Figure 2 , such as Figure 2As shown, the product recommendation method may include the following steps: (1) obtaining a data set and preprocessing the obtained data (i.e., the first preset processing); (2) using an improved similarity algorithm to calculate the similarity value (i.e., the first similarity) between the user's intended purchase product a and the associated product b; (3) based on the similarity value (i.e., the first similarity), obtaining a product similarity graph based on the purchase order (i.e., the similarity graph), and using an improved Transformer model with an optimized attention mechanism (i.e., the first model) to calculate the association rules of each product for personalized recommendation of users.
[0082] It should be noted that in the embodiments of the present application, the recommendation algorithm is improved from two aspects to improve the accuracy of the recommendation result. On the one hand, the similarity algorithm is optimized to improve the accuracy of similarity calculation; on the other hand, the concept of a recommendation graph (i.e., the similarity graph) is proposed, the Transformer model (i.e., the first model) is introduced, and the attention algorithm is optimized to improve the accuracy of the recommendation result while reducing the computational complexity. Next, the two improvement points will be introduced in detail respectively.
[0083] It should be noted that in the embodiments of the present application, the improvement of the similarity algorithm mainly includes the following content. The similarity algorithm is an indispensable part of the recommendation algorithm and has a great impact on the accuracy of the recommendation result. Currently, the mainstream cosine similarity calculation method is shown in the following formula (5).
[0084]
[0085] where a and b represent two different products, and a i and b i respectively represent the vectors of the i-th dimension of product a and product b.
[0086] It should be noted that in the embodiments of the present application, in order to improve the calculation accuracy, it is necessary to preprocess the input data (i.e., the first preset processing) before similarity calculation: on the one hand, the data is normalized to prevent feature vectors with too small values from being submerged and avoid the influence of outliers and extreme values; on the other hand, it is necessary to increase the density of long-tail data and reduce the calculation error caused by low-density data. And because the cosine function is not sensitive to the absolute value of specific values, this algorithm has a large error when processing data with large numerical differences.
[0087] It should be noted that in the embodiments of the present application, the process of the commodity recommendation device optimizing the similarity algorithm may include the following steps: 1. Calculate the mean value of the lengths of each vector (i.e., the first mean value), and calculate the cosine similarity value after subtracting the mean value from each vector; First of all, in addition to the direction, the vector also has a length attribute, and the lengths of each vector are inconsistent. The mean value of the lengths of each vector (i.e., the third feature vector and each fourth feature vector) can be calculated first, and then the cosine similarity value can be calculated after subtracting the mean value from each vector. The specific formula is shown in the following formula (6); 2. Combine the purchase order to calculate the similarity value (i.e., the first similarity value) between the user's intended purchase product and the associated product. As we all know, there is a certain order when purchasing many products. For example, people who buy a computer are very likely to buy a mouse again, and people who buy a car are very likely to buy some car accessories; on the contrary, people who buy a mouse are less likely to buy a computer, and people who buy car accessories are also less likely to buy a car again. If corresponding recommendations can be made at the right time, the conversion rate can be improved to a greater extent. According to the traditional similarity algorithm, the differences caused by different purchase orders cannot be calculated. Therefore, the embodiments of the present application make further changes to the similarity algorithm: If the reference product (i.e., the purchased product) is product a and the product to be recommended (i.e., the first product to be recommended) is product b, then after the user has purchased product a, the result of mapping the attributes of each dimension of product b to product a can be represented by the following formula (7), and thus the similarity formula between the user's intended purchase product and product b can be represented by the above formula (1). When SIM(a->b) is larger, it proves that after the user purchases product a, the user's intended purchase product is closer to product b.
[0088]
[0089] Wherein, represents the first mean value, a i and b i respectively represent the vectors of the i-th dimension of product a and product b.
[0090]
[0091] That is to say, in the embodiments of the present application, when the commodity recommendation device calculates the first similarity between each first product to be recommended and the purchased product, it can first calculate the mean value of the lengths of each feature vector (i.e., the first mean value), and then calculate the cosine similarity value after subtracting the mean value from each feature vector, so as to reduce the problem that the calculation result accuracy is affected due to the insensitivity of the cosine function to the numerical size.
[0092] It should be noted that in the embodiments of the present application, the product recommendation device can determine one or more first products to be recommended based on the purchase order of the purchased products. For example, people who have bought a computer are very likely to buy a mouse again, and people who have bought a car are very likely to buy some car decorations; on the contrary, people who have bought a mouse are less likely to buy a computer, and people who have bought car decorations are also less likely to buy a car again. If corresponding recommendations can be made at the right time, the conversion rate can be improved to a greater extent.
[0093] Furthermore, in the embodiments of the present application, the similarity between other products and the products that the user intends to purchase can be obtained through the above similarity algorithm, and the similarity of the same product under different purchase orders is also different. According to this characteristic, a similarity graph between products can be constructed. For example: after the user purchases product a, the probability of purchasing product b is very high, and after purchasing product b, the probability of purchasing product c is very high. Then, a similarity graph in the form of a->b->c can be deduced from the data of product a.
[0094] It should be noted that in the embodiments of the present application, if product recommendations are needed, corresponding recommendation results need to be given. Since Transformer (i.e., the first model) is very good at processing long sequence data, it can be used to assist in the recommendation. We input the similarity graph of the products into the encoder of the Transformer model (i.e., the first model) to generate more accurate recommendation results. The specific steps are as follows: 1. Construct the required training set according to the calculation results of the similarity (i.e., the first similarity), mainly including the similarity graph of the products, etc.; 2. Adopt an improved Transformer model that optimizes the attention mechanism; 3. Input the training set (i.e., the first data set) into the Transformer model, and according to the attention mechanism, focus on more important products, calculate the association rules between each product and the products purchased by the user, and use them for product recommendations for the user.
[0095] It should be noted that in the embodiments of the present application, Transformer (i.e., the first model) consists of an encoder and a decoder, including multiple layers of encoders and decoders. Each layer will project the query vector, key vector, and value vector into multiple subspaces respectively, and then calculate the attention in each subspace respectively, and the calculation is relatively cumbersome; and during the calculation process, long-distance information will be weakened. In the similarity sequence, the farther the vector is from the starting position of the sequence, the lower the accuracy during the calculation, just like memory fades with the passage of time. Therefore, it is necessary to improve the Transformer model and optimize the attention mechanism so that the model can adaptively learn the attention weights of vectors in different regions of the sequence. In this way, the model can pay more attention to important products, such as product vectors with a higher similarity to the products that the user intends to purchase.
[0096] It should be noted that in the embodiments of the present application, the specific implementation of the attention mechanism optimization is as follows. Assume that in the attention mechanism, the node feature of product a is r a , and the node feature of product b is r b . Then, the weight parameter formula between product a and product b can be obtained through the above formula (2). The attention weight from product a to product b can be calculated through the above formula (3), and the node feature of product b can be calculated through the above formula (4).
[0097] That is to say, in the embodiments of the present application, through the attention mechanism in the first model, the first model can adaptively learn the attention weights of different region vectors in the sequence. In this way, the first model can pay more attention to important products, such as product vectors with a high similarity to the products that the user intends to purchase, so as to generate more accurate recommendation results.
[0098] In summary, the commodity recommendation device can determine one or more first products to be recommended based on the purchase order of the purchased commodities. Then, it can obtain the first feature vectors corresponding to the purchased commodities and the second feature vectors corresponding to each first product to be recommended. It can perform a first preset process on the first feature vectors to obtain third feature vectors, and perform a first preset process on each second feature vector to obtain fourth feature vectors. Furthermore, it can determine a first mean based on the third feature vectors and each fourth feature vector, and determine a first similarity based on the third feature vectors, each fourth feature vector, and the first mean. That is, when the commodity recommendation device calculates the first similarity between each first product to be recommended and the purchased commodities, it can first calculate the mean of the lengths of each feature vector (i.e., the first mean), and then calculate the cosine similarity value after subtracting the mean from each feature vector. This can reduce the problem that the calculation result accuracy is affected due to the insensitivity of the cosine function to the numerical size. Finally, it can determine a similarity graph based on the first similarity, and determine the target recommended commodities based on the similarity graph and the first model. Through the attention mechanism in the first model, it can pay more attention to important products, such as product vectors with a high similarity to the products that the user intends to purchase, so as to generate more accurate recommendation results.
[0099] An embodiment of the present application provides a product recommendation method, which includes: obtaining first data; wherein the first data includes product information of purchased products; determining one or more first products to be recommended based on the purchase order of the purchased products, and calculating a first similarity between each first product to be recommended and the purchased products; determining a similarity graph based on the first similarity, and determining target recommended products based on the similarity graph and a first model; wherein the similarity graph is used to represent the correlation between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism. It can be seen that after obtaining the first data, one or more first products to be recommended can be determined based on the purchase order of the purchased products, and the first similarity between each first product to be recommended and the purchased products can be calculated, that is, the first products to be recommended in the embodiments of the present application are determined based on the purchase order of the purchased products, thereby improving the accuracy of subsequent recommended products. Then, a similarity graph can be determined based on the first similarity, and target recommended products can be determined based on the similarity graph and the first model; wherein the first model includes an attention mechanism, that is, the embodiments of the present application can determine target recommended products through the attention mechanism in the first model, thereby improving the accuracy of the recommendation result while reducing the calculation amount.
[0100] Based on the above embodiments, an embodiment of the present application provides a product recommendation device Figure 3 which is a schematic structural diagram of the product recommendation device, as Figure 3 shown. The device 10 includes: an obtaining unit 11, a determining unit 12, and a calculating unit 13; wherein,
[0101] The obtaining unit 11 is configured to obtain first data; wherein the first data includes product information of purchased products;
[0102] The determining unit 12 is configured to determine one or more first products to be recommended based on the purchase order of the purchased products;
[0103] The calculating unit 13 is configured to calculate a first similarity between each first product to be recommended and the purchased products;
[0104] The determining unit 12 is further configured to determine a similarity graph based on the first similarity, and determine target recommended products based on the similarity graph and a first model; wherein the similarity graph is used to represent the correlation between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
[0105] In an embodiment of the present application, further, Figure 4 which is a schematic structural diagram of an electronic device, as Figure 4As shown, the electronic device 20 proposed in the embodiment of the present application may further include a processor 14, a memory 15 storing executable instructions of the processor 14. Further, the electronic device 20 may further include a communication interface 16 and a bus 17 for connecting the processor 14, the memory 15, and the communication interface 16.
[0106] In the embodiment of the present application, the above-mentioned processor 14 may be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic devices for implementing the above-mentioned processor functions may be others, and the embodiments of the present application do not make specific limitations. The electronic device 20 may further include a memory 15, and the memory 15 may be connected to the processor 14. Among them, the memory 15 is used to store executable program codes, and the program codes include computer operation instructions. The memory 15 may include a high-speed RAM memory and may also include a non-volatile memory, for example, at least two disk memories.
[0107] In the embodiment of the present application, the bus 17 is used to connect the communication interface 16, the processor 14, and the memory 15 and for mutual communication between these devices.
[0108] In the embodiment of the present application, the memory 15 is used to store instructions and data.
[0109] Further, in the embodiment of the present application, the above-mentioned processor 14 is used to obtain first data; wherein, the first data includes the product information of the purchased products; determine one or more first products to be recommended based on the purchase order of the purchased products, and calculate the first similarity between each of the first products to be recommended and the purchased products; determine a similarity graph based on the first similarity, and determine a target recommended product based on the similarity graph and a first model; wherein, the similarity graph is used to characterize the relevance between the purchased products and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
[0110] In practical applications, the above-mentioned memory 15 can be a volatile memory, such as a Random-Access Memory (RAM); or a non-volatile memory, such as a Read-Only Memory (ROM), a flash memory, a Hard Disk Drive (HDD), or a Solid-State Drive (SSD); or a combination of the above types of memories, and provides instructions and data to the processor 14.
[0111] An embodiment of the present application provides a commodity recommendation device. The commodity recommendation device obtains first data; wherein, the first data includes the commodity information of the purchased commodities; determines one or more first commodities to be recommended based on the purchase order of the purchased commodities, and calculates the first similarity between each first commodity to be recommended and the purchased commodities; determines a similarity graph based on the first similarity, and determines a target recommended commodity based on the similarity graph and a first model; wherein, the similarity graph is used to represent the correlation between the purchased commodities and one or more second commodities to be recommended, the second commodities to be recommended include the first commodities to be recommended, and the first model includes an attention mechanism. It can be seen that after obtaining the first data, one or more first commodities to be recommended can be determined based on the purchase order of the purchased commodities, and the first similarity between each first commodity to be recommended and the purchased commodities can be calculated. That is, the first commodities to be recommended in the embodiment of the present application are determined based on the purchase order of the purchased commodities, so as to improve the accuracy of the subsequent recommended commodities. Then, a similarity graph can be determined based on the first similarity, and a target recommended commodity can be determined based on the similarity graph and the first model; wherein, the first model includes an attention mechanism. That is, the embodiment of the present application can determine the target recommended commodity through the attention mechanism in the first model, so as to improve the accuracy of the recommendation result while reducing the calculation amount.
[0112] An embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, the commodity recommendation method described above is implemented.
[0113] Specifically, the program instructions corresponding to a commodity recommendation method in this embodiment can be stored on a storage medium such as an optical disc, a hard disk, a USB flash drive, etc. When the program instructions corresponding to a commodity recommendation method in the storage medium are read or executed by an electronic device, the following steps are included:
[0114] Obtain first data; wherein, the first data includes the commodity information of the purchased commodities;
[0115] Determine one or more first recommended products based on the purchase order of the purchased products, and calculate the first similarity between each of the first recommended products and the purchased products;
[0116] Determine a similarity graph based on the first similarity, and determine target recommended products based on the similarity graph and a first model; wherein, the similarity graph is used to represent the relevance between the purchased products and one or more second recommended products, the second recommended products include the first recommended products, and the first model includes an attention mechanism.
[0117] An embodiment of the present application also provides a computer program product, including a computer program, which can be executed by a processor 14 of an electronic device 20 to complete the steps of any of the foregoing methods.
[0118] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0119] The present application is described with reference to the implementation flow diagrams and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the implementation flow diagrams and / or block diagrams can be implemented by computer program instructions, and the combination of the processes and / or blocks in the implementation flow diagrams and / or block diagrams can also be implemented. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a machine for realizing the functions specified in one or more of the following processes Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the functions specified in one block or multiple blocks.
[0120] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing devices to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device realizes the functions specified in one or more of the following processes Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the functions specified in one block or multiple blocks.
[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process or multiple processes and / or boxes Figure 1 one process or multiple processes and / or boxes Figure 1 steps of the functions specified in one box or multiple boxes.
[0122] As described above, the above are only the preferred embodiments of the present application, and are not intended to limit the protection scope of the present application.
Claims
1. A product recommendation method, characterized in that: The method comprises: Acquire first data; wherein the first data includes commodity information of purchased commodities; Determine one or more first commodities to be recommended based on the purchase order of the purchased commodities, and calculate a first similarity between each of the first commodities to be recommended and the purchased commodities; A similarity graph is determined based on the first similarity, and a target recommended product is determined based on the similarity graph and the first model; wherein the similarity graph is used to characterize the association between the purchased product and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
2. The method according to claim 1, characterized in that: Before calculating the first similarity between each of the first to-be-recommended products and the purchased products, the method further includes: Obtaining a first feature vector corresponding to the purchased product, and obtaining a second feature vector corresponding to each of the first products to be recommended; wherein the first feature vector and the second feature vector include N-dimensional vectors; The first preset processing is performed on the first eigenvector to obtain a third eigenvector, and the first preset processing is performed on each of the second eigenvectors to obtain a fourth eigenvector.
3. The method according to claim 2, characterized in that The calculating the first similarity between each of the first to-be-recommended products and the purchased products includes: Determine a first mean based on the third eigenvector and each of the fourth eigenvectors; wherein the first mean includes the mean of the third eigenvector and each of the fourth eigenvectors in the i-th dimension, where i is a positive integer; The first similarity is determined based on the third eigenvector, each of the fourth eigenvectors, and the first mean.
4. The method according to claim 3, characterized in that The determining a similarity graph based on the first similarity includes: Filter out a second similarity based on the first similarity; wherein the second similarity includes similarities ranked in the top L of the first similarities, where L is a positive integer; Determine a third commodity to be recommended corresponding to each of the second similarities, and determine a corresponding fourth commodity to be recommended based on the third commodity to be recommended; wherein the first commodity to be recommended includes the third commodity to be recommended, and the second commodity to be recommended includes the fourth commodity to be recommended; A first data set is generated based on the purchased product, the third product to be recommended, and the fourth product to be recommended; wherein the first data set includes Q similarity graphs, where Q is a positive integer.
5. The method according to claim 4, characterized in that The determining a corresponding fourth commodity to be recommended based on the third commodity to be recommended includes: For each of the third commodities to be recommended, determining a third similarity between the third commodities to be recommended and P fifth commodities to be recommended; Screening the third similarities to obtain the top L fourth similarities; wherein the third similarities include the fourth similarities; Determine a to-be-recommended commodity corresponding to each of the fourth similarities as the fourth to-be-recommended commodity.
6. The method according to claim 5, characterized in that The determining the target recommended product based on the similarity graph and the first model includes: After inputting the first data set into the first model, calculating the first node feature corresponding to the third product to be recommended based on the attention mechanism, and calculating the second node feature corresponding to the fourth product to be recommended; The target recommended product is determined based on the first node feature and the second node feature.
7. The method according to claim 6, characterized in that The calculating the first node feature corresponding to the third to-be-recommended product based on the attention mechanism includes: Determine a first weight parameter between the purchased product and the third product to be recommended based on the second similarity, the first function and the second function; Determine a first attention weight corresponding to the third to-be-recommended product based on the first weight parameter, the first preset threshold, and the second similarity; A first node feature corresponding to the third product to be recommended is determined based on the first attention weight and the second similarity.
8. The method according to claim 7, characterized in that The determining the first attention weight corresponding to the third to-be-recommended product based on the first weight parameter, the first preset threshold, and the second similarity includes: The second similarities are screened based on the first preset threshold to obtain a first screening result; wherein the first screening result includes a fifth similarity, and the fifth similarity includes similarities in the second similarities that are greater than the first preset threshold; The first attention weight is determined based on the fifth similarity and the first weight parameter.
9. The method according to claim 6, characterized in that The calculating the second node feature corresponding to the fourth to-be-recommended product includes: Determine a second weight parameter between the purchased product and the fourth product to be recommended based on the fourth similarity, the first function and the second function; Determine a second attention weight corresponding to the fourth to-be-recommended product based on the second weight parameter, the second preset threshold, and the fourth similarity; A second node feature corresponding to the fourth item to be recommended is determined based on the second attention weight and the fourth similarity.
10. The method according to claim 9, characterized in that The determining the second attention weight corresponding to the fourth to-be-recommended product based on the second weight parameter, the second preset threshold, and the fourth similarity includes: The fourth similarity is screened based on the second preset threshold to obtain a second screening result; wherein the second screening result includes a sixth similarity, and the sixth similarity includes similarities in the fourth similarities that are greater than the second preset threshold; The second attention weight is determined based on the sixth similarity and the second weight parameter.
11. A commodity recommendation device, characterized in that: The commodity recommendation device comprises: an acquisition unit, a determination unit and a calculation unit; wherein, The acquisition unit is used to acquire first data; wherein the first data includes commodity information of purchased commodities; The determining unit is used to determine one or more first commodities to be recommended based on the purchase order of the purchased commodities; The calculation unit is used to calculate the first similarity between each of the first to-be-recommended products and the purchased products; The determination unit is also used to determine a similarity graph based on the first similarity, and to determine a target recommended product based on the similarity graph and the first model; wherein the similarity graph is used to characterize the association between the purchased product and one or more second products to be recommended, the second products to be recommended include the first products to be recommended, and the first model includes an attention mechanism.
12. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; wherein, The memory is used to store a computer program that can be run on the processor; The processor is configured to execute the method according to any one of claims 1 to 10 when running the computer program.
13. A computer-readable storage medium, characterized in that: The storage medium stores computer program codes, and when the computer program codes are executed by a computer, the method according to any one of claims 1 to 10 is executed.
14. A computer program product comprising a computer program, characterized in that The computer program implements the method according to any one of claims 1 to 10 when executed by a processor.