An item recommendation method and apparatus
By training an item recommendation network to extract features and perform cosine similarity analysis on selected items, the shortcomings of e-commerce recommendation in recommending new items and items without common purchase records are solved, achieving a more comprehensive and higher matching recommendation effect.
Patent Information
- Application Number
- CN202211740296.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2042-12-30
AI Technical Summary
In existing e-commerce recommendation systems, newly listed items and items without shared purchase records cannot be accurately recommended, resulting in incomplete recommendations and low matching accuracy.
A trained item recommendation network is used to extract feature vectors from selected items. Cosine similarity is used to determine the feature vectors of items that meet preset conditions, and items with high matching degree with the selected items are recommended.
It enables more comprehensive recommendations of items that are highly relevant to the selected items in e-commerce recommendations, thus improving the accuracy of recommendations.
Smart Images

Figure CN115907929B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of article application, and more particularly to an article recommendation method and apparatus. Background Technology
[0002] In e-commerce recommendation scenarios, after a user purchases an item or places an order, related items need to be recommended to the user based on the currently purchased item. In related technologies, item recommendations are usually based on the principle of co-purchase. However, this means that newly listed items and items not purchased together cannot be recommended, which makes it impossible to recommend a comprehensive and accurate selection of items. Summary of the Invention
[0003] In view of this, embodiments of this application provide a method and apparatus for recommending items.
[0004] The technical solution of this application is implemented as follows:
[0005] This application provides a method for recommending items, the method comprising:
[0006] Get the selected item;
[0007] A trained item recommendation network is used to extract feature vectors from the selected items to obtain the feature vectors to be processed.
[0008] Determine the item feature vectors whose cosine similarity with the feature vector to be processed satisfies a preset condition;
[0009] The item represented by the item feature vector is determined as the recommended item corresponding to the selected item.
[0010] This application provides an item recommendation device, the device comprising:
[0011] The acquisition module is used to acquire the selected items;
[0012] The feature extraction module is used to extract feature vectors from the selected items using a trained item recommendation network to obtain feature vectors to be processed.
[0013] The first determining module is used to determine the item feature vector whose cosine similarity with the feature vector to be processed satisfies a preset condition;
[0014] The second determining module is used to determine the item represented by the item feature vector as the recommended item corresponding to the selected item.
[0015] The item recommendation method and apparatus provided in this application first acquire selected items; then, using a trained item recommendation network, feature vectors are extracted from the selected items to obtain feature vectors to be processed; and item feature vectors whose cosine similarity with the feature vectors to be processed meets a preset condition are determined; finally, the items represented by the item feature vectors are determined as the recommended items corresponding to the selected items. In this way, by using a trained item recommendation network to sequentially extract feature vectors from selected items and select item feature vectors whose cosine similarity with the feature vectors to be processed meets a preset condition, recommended items corresponding to the selected items are determined; thus, it is possible to achieve a more comprehensive recommendation of items with a high degree of matching with the selected items in the item recommendation process. Attached Figure Description
[0016] Figure 1 A flowchart illustrating an item recommendation method provided in an embodiment of this application;
[0017] Figure 2 A flowchart illustrating another item recommendation method provided in this application embodiment;
[0018] Figure 3 A flowchart illustrating the training process of a trained item recommendation network provided in an embodiment of this application;
[0019] Figure 4 A schematic diagram illustrating the construction of effective sample pairs based on multiple users;
[0020] Figure 5 A schematic diagram of a framework for recommending networks for training items;
[0021] Figure 6 This is a schematic diagram of the structure of an item recommendation device provided in an embodiment of this application;
[0022] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0023] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0024] It should be understood that the phrases "embodiments of this application" or "foreign embodiments" throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment is included in at least one embodiment of this application. Therefore, "embodiments of this application" or "in the foreign embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0025] Unless otherwise specified, any step in the embodiments of this application performed by the electronic device may be executed by the processor of the electronic device. It is also worth noting that the embodiments of this application do not limit the order in which the electronic device performs the following steps. Furthermore, the methods used to process data in different embodiments may be the same or different methods. It should also be noted that any step in the embodiments of this application can be executed independently by the electronic device; that is, when the electronic device performs any step in the following embodiments, it may not depend on the execution of other steps.
[0026] To better understand the embodiments of this application, the shortcomings of the related technologies will first be explained.
[0027] In e-commerce recommendation scenarios, related technologies typically recommend items after purchase or order placement based on the principle of joint purchase or item association rules. However, this can lead to situations where newly listed items or items not purchased together cannot be recommended, making it difficult to recommend items that are highly accurate and closely matched to related items.
[0028] To address the problems existing in related technologies, this application provides an item recommendation method, which is applied to a processing device or electronic device. The item recommendation method provided in this embodiment can be implemented by a computer program, which, when executed, completes each step of the item recommendation method provided in this embodiment. In some embodiments, the computer program can be executed by a processor in a processing device. Figure 1 This is a flowchart illustrating an item recommendation method provided in an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0029] Step 101: Obtain the selected item.
[0030] In this application embodiment, the selected item can be any item that can be traded normally; for example, the selected item can be a backpack or computer of a certain brand.
[0031] Here, the number of selected items can be one, two, or more; at the same time, the number of selected items is related to their corresponding unit of measurement.
[0032] It should be noted that the selected items can be items purchased by the user on any shopping platform, items that have been clicked to view, or items that have been added to the shopping cart.
[0033] Step 102: Using the trained item recommendation network, feature vectors are extracted from the selected items to obtain the feature vectors to be processed.
[0034] In this embodiment of the application, the supervision information of the trained item recommendation network during the training process includes at least: the cosine similarity between the feature vectors of the two items in the training item pair, and the supervision information between the feature vectors and the label values corresponding to the training item pair; the training item pair consists of two items whose time difference between being accessed by the same user within a specified interval satisfies a preset difference; the label values corresponding to the training item pair are determined based on the item value and item type of the two items constituting the training item pair.
[0035] Here, the trained item recommendation network can be a model obtained by fusing a Bidirectional Encoder Representation from Transformers (BERT) model with a collaborative filtering operation.
[0036] In this embodiment, the trained item recommendation network can be obtained by inputting a preset training item pair into the item recommendation network to be trained and adjusting the network parameters. The training item pair can be constructed based on relevant item access records or user access logs on relevant shopping platforms, consisting of two items, according to the corresponding accessing user and access time. Furthermore, the training item pair also has sample labels during training, i.e., corresponding label values, which can be determined based on the item value and item type of the two items in the training item pair.
[0037] It should be noted that the feature vector to be processed includes, but is not limited to: the word vector, text vector, and position vector corresponding to the selected item; among them, the feature vector to be processed is usually a one-dimensional vector.
[0038] Step 103: Determine the item feature vectors whose cosine similarity with the feature vector to be processed meets the preset conditions.
[0039] In this embodiment, the trained item recommendation network can be used to obtain and determine the item feature vectors whose cosine similarity with the feature vector to be processed meets the preset condition; wherein, the preset condition can be that the cosine similarity is greater than the preset threshold; in this embodiment, the preset threshold can be a pre-set value, such as 0.7, 0.85, etc.
[0040] It should be noted that the number of item feature vectors is usually two or more; at the same time, the item feature vectors can also be feature vectors obtained by a trained item recommendation network for extracting feature vectors of relevant items.
[0041] Step 104: Determine the item represented by the item feature vector as the recommended item corresponding to the selected item.
[0042] In this embodiment of the application, the item represented by the item feature vector can be determined as a recommended item that matches the selected item, as determined by a trained item recommendation network.
[0043] The recommended items are usually two or more; for example, if the selected item is a computer of brand A, the corresponding recommended items could be a computer bag of brand A or a computer of brand B.
[0044] In the embodiments of this application, the relationship between the selected item and its corresponding recommended item can be complementary goods, or goods of the same type but different models, different manufacturers, or different brands.
[0045] In this embodiment, the system may obtain items added to a user's shopping cart on a relevant shopping platform, such as a mobile phone of brand A. Then, a trained item recommendation network is used to obtain items matching the selected item, i.e., the mobile phone of brand A, such as headphones belonging to the same brand as A, mobile phones from different brands than A, or other mobile phone models. Alternatively, it may recommend both headphones belonging to the same brand as A and mobile phones from different brands. Thus, a trained item recommendation network, including at least the cosine similarity between the feature vectors of two items in a training item pair and the supervision information between the feature vectors and the corresponding label values of the training item pair, is used to determine recommended items matching the selected item. This makes the recommended items more comprehensive and accurate, i.e., a higher degree of matching with the selected item. This matching degree includes, but is not limited to, matching degrees of complementary items and matching degrees of similar items.
[0046] The item recommendation method provided in this application first obtains selected items; then, using a trained item recommendation network, feature vectors are extracted from the selected items to obtain feature vectors to be processed; and item feature vectors whose cosine similarity with the feature vectors to be processed meets a preset condition are determined; finally, the items represented by the item feature vectors are determined as the recommended items corresponding to the selected items. In this way, by using a trained item recommendation network to sequentially extract feature vectors from the selected items and select item feature vectors whose cosine similarity with the feature vectors to be processed meets a preset condition, the recommended items corresponding to the selected items are determined; thus, it is possible to achieve a more comprehensive recommendation of items with a high degree of matching with the selected items in the item recommendation process.
[0047] Based on the foregoing embodiments, this application also provides an item recommendation method, applied to an item recommendation device, such as... Figure 2 The diagram shown is a flowchart illustrating another item recommendation method provided in this application embodiment. Figure 1 and Figure 2 As shown, the method includes the following steps:
[0048] Step 201: For the feature vectors to be screened whose cosine similarity with the feature vector to be processed is greater than or equal to a preset threshold, sort them from largest to smallest according to their cosine similarity with the feature vector to be processed to obtain a sequence of feature vectors to be screened.
[0049] In this embodiment, feature vectors to be screened with a cosine similarity greater than or equal to a preset threshold with the feature vector to be processed can be obtained first. Then, the feature vectors to be screened can be further sorted from largest to smallest according to the cosine similarity with the feature vector to be processed, thereby obtaining a sequence of feature vectors to be screened.
[0050] The preset threshold can be a pre-set value.
[0051] Step 202: Based on the preset selection number, select the item feature vector that ranks first from the sequence of feature vectors to be filtered.
[0052] In this embodiment of the application, the item feature vectors that are ranked first in the sequence of feature vectors to be filtered and whose quantity is a preset selection number can be selected.
[0053] It should be noted that the preset selection number in the feature vector sequence to be filtered is related to the number of feature vectors to be filtered included in the feature vector sequence to be filtered; for example, if the feature vector sequence to be filtered includes 20 feature vectors to be filtered, then the preset selection number can be 10 or 5, that is, less than or equal to 20; if the feature vector sequence to be filtered includes 50 feature vectors to be filtered, then the preset selection number can be 10 or 30, that is, less than or equal to 50.
[0054] It should be noted that by filtering and sorting and then selecting based on a preset number of items, the feature vector of the item is obtained; this makes the matching degree between the subsequent items represented by the feature vector and the selected items higher.
[0055] Based on the foregoing embodiments, the training process of the trained item recommendation network involved in this application embodiment can be achieved by constructing sample pairs and training the network parameters of the item recommendation network to be trained based on the constructed sample pairs, such as... Figure 3 The diagram shown illustrates the training process of a trained item recommendation network according to an embodiment of this application. Figure 3 As shown, the training process includes the following steps:
[0056] Step 301: Obtain the set of accessed items corresponding to the item access records within the specified time interval.
[0057] In this embodiment of the application, multiple accessed items corresponding to the item access records within a specified time interval can be obtained, thereby obtaining the accessed item set; wherein, the item access records can be the item access records or user access logs corresponding to any shopping platform; wherein, the item access records can be represented in any file format.
[0058] In the embodiments of this application, the specified time interval can be a time period with a preset duration, such as: 00:00 on December 30, 2022 to 00:00 on December 31, 2022.
[0059] It should be noted that the accessed item set includes multiple accessed items. Among these multiple accessed items, the item type, item model, item brand, and the accessing user corresponding to the item can be the same or different.
[0060] Step 302: Based on the attribute information of the items, combine and label the accessed items in the accessed item set to obtain a set of positive sample item pairs and a set of negative sample item pairs.
[0061] In this embodiment of the application, based on the attribute information of the items, such as the type of the item, the value of the item, and the user who accesses the item, the accessed items in the accessed item set can be combined and labeled to obtain the corresponding positive sample item pair set and negative sample item pair set.
[0062] Here, the number of positive sample item pairs and the number of negative sample item pairs included in the positive sample item pair set and the negative sample item pair set can be the same or different.
[0063] It should be noted that the attribute information of an item includes, but is not limited to: the item's value, the item's type or model, the user who accessed the item, and the access time of the item.
[0064] In some feasible implementations, firstly, two accessed items belonging to the same user and whose access time difference meets a preset difference are combined; then, based on the item type and item value, the combined item pairs are classified and labeled to obtain a set of positive sample item pairs and a set of negative sample item pairs. That is, step 302 provided in the above embodiment can be implemented by the following steps 3021 and 3022 (not shown in the figure):
[0065] Step 3021: In the set of accessed items, two accessed items belonging to the same user and whose access time difference meets a preset difference are combined to obtain a set of items to be processed.
[0066] In this embodiment of the application, two accessed items belonging to the same user and whose access time difference meets a preset difference are combined to obtain multiple pairs of items to be processed, thereby forming the set of items to be processed.
[0067] The set of items to be processed can include one, two, or more pairs of items. The preset difference can be expressed as a time period, such as 30 seconds or 100 seconds.
[0068] It should be noted that the accessed items can be grouped together, and any two accessed items belonging to the same user, such as user A, whose access time difference is less than 3 minutes, can be combined to obtain multiple first pairs of items to be processed. Then, any two accessed items belonging to user B, whose access time difference is less than 3 minutes, can be combined to obtain multiple second pairs of items to be processed. Then, based on the multiple first pairs of items to be processed and the multiple second pairs of items to be processed, the set of items to be processed can be formed.
[0069] Step 3022: Based on the item type and item value, classify and label the items to be processed in the set of items to be processed to obtain the set of positive sample items and the set of negative sample items.
[0070] In this embodiment of the application, each pair of items to be processed in the set of items to be processed can be further classified and labeled based on the item type and item value, thereby obtaining a set of positive sample items and a set of negative sample items with different labels; here, it means that the labels or marks corresponding to the positive sample items in the set of positive sample items and the negative sample items in the set of negative sample items are different.
[0071] Here, we can first classify the pairs of items to be processed in the set of items to be processed based on the item type, and then label the classified results based on the item value, thereby obtaining the positive sample item pair set and the negative sample item pair set. That is, step 3022 above can be achieved through steps A1 and A2:
[0072] Step A1: Based on the item type, classify the items to be processed in the set of items to be processed to obtain a first set of items and a second set of items.
[0073] The first item pair in the first item pair set includes two items of different types; the second item pair in the second item pair set includes two items of the same type.
[0074] In this embodiment of the application, multiple pairs of items to be processed in the set of items to be processed are classified according to whether the two items they include are of the same or different types, thereby obtaining a first pair of items consisting of two items of different types, i.e., a first set of items consisting of multiple first pairs of items, and a second pair of items consisting of two items of the same type, i.e., a second set of items consisting of multiple second pairs of items.
[0075] Step A2: Based on the value of the items, mark the first item pairs in the first item pair set and the second item pairs in the second item pair set respectively to obtain the positive sample item pair set and the negative sample item pair set.
[0076] In this embodiment of the application, the first item pair in the first item pair set and the second item pair in the second item pair set can be labeled according to the item value of the items included in the first item pair and the second item pair respectively, thereby obtaining the positive sample item pair set and the negative sample item pair set respectively.
[0077] In one feasible implementation, based on the value of each item, the first item pairs in the first item pair set are labeled sequentially, and then the second item pairs in the second item pair set are labeled, thus obtaining the positive sample item pair set and the negative sample item pair set. That is, step A2 above can be implemented through the following process:
[0078] The first step is to label the first item pairs in the first item pair set with the first label and the second label based on the value of the items, thereby obtaining the positive sample item pair set and the first negative sample item pair subset.
[0079] In this embodiment of the application, for the first item in the first item pair set, it can be marked based on the item value, using both a first label and a second label, thereby obtaining the corresponding positive sample item pair set and the first negative sample item pair set.
[0080] Here, we can first determine the value ratio between the two items in each item pair in the first item pair set based on the item value. Then, based on this value ratio and a preset ratio, we can use a first label and a second label to mark the corresponding first item pairs, thereby obtaining a positive sample item pair set and a first negative sample item pair subset. That is, the first step above, "based on the item value, using a first label and a second label to mark the first item pairs in the first item pair set to obtain the positive sample item pair set and the first negative sample item pair subset", can be achieved through the following process:
[0081] First, based on the value of the items, obtain the value ratio between the two items in the first item pair in the first item pair set.
[0082] Wherein, the value ratio represents the ratio between the first value and the second value corresponding to the items in the first item pair; the first value is greater than the second value.
[0083] In this embodiment of the application, the value ratio between the two items in the first item pair can be the ratio between the first value corresponding to item A and the second value corresponding to item B in the first item pair; for example, the first item pair consists of item A and item B, the value of item A is A1, the value of item B is B1, and the corresponding value ratio is A1 / B1.
[0084] It should be noted that the value ratio between the two items in different first item pairs in the first item pair set can be the same or different.
[0085] Then, using the first label, the first item pairs in the first item pair set whose value ratio is less than the preset ratio are marked, thus obtaining the positive sample item pair set.
[0086] In the embodiments of this application, the preset ratio can be a pre-set value, such as 50 or 100.
[0087] Finally, the second label is used to mark the second item pairs in the first item pair set whose value ratio is greater than or equal to the preset ratio, thus obtaining the first negative sample item pair subset.
[0088] Here, the first item pairs in the first item pair set are distinguished and labeled differently by the ratio between the value ratio and the preset ratio, namely the first label and the second label, so as to obtain the positive sample item pair set and the first negative sample item pair subset.
[0089] The second step is to use the second label to mark the second item pairs in the second item pair set to obtain the second negative sample item pair subset.
[0090] The first subset of negative sample item pairs and the second subset of negative sample item pairs constitute the negative sample item pair set.
[0091] In this embodiment of the application, a second label is directly used to label each second item pair in the second item pair set, i.e., to mark it, thereby obtaining a second negative sample item pair subset.
[0092] Here, the first negative sample item pair subset and the second negative sample item pair subset can be merged to obtain the negative sample item pair set.
[0093] Step 303: Based on the set of positive sample items and the set of negative sample items, train the network parameters of the item recommendation network to be trained to obtain the trained item recommendation network.
[0094] In this embodiment, positive sample item pairs and negative sample item pairs can be used as training samples to train the network parameters of the item recommendation network to be trained, thereby obtaining a trained item recommendation network; here, the loss corresponding to the recommended items output by the obtained trained item recommendation network satisfies the convergence condition.
[0095] In one feasible implementation, item pairs in the positive sample item pair set and the negative sample item pair set can be extracted according to a preset ratio to obtain an intermediate positive sample item pair set composed of some positive sample item pairs and an intermediate negative sample item pair set composed of some negative sample item pairs. Then, target sample item pairs, namely the target positive sample item pair set and the target negative sample item set, are constructed accordingly. Then, the network parameters of the item recommendation network to be trained are trained based on the target positive sample item pair set and the target negative sample item set. In this way, when using the trained item recommendation network for item recommendation, the recommended items associated with relevant items are more comprehensive and accurate. That is, step 303 provided in the above embodiment can be implemented by the following steps 3031 to 3033 (not shown in the figure):
[0096] Step 3031: According to the preset positive and negative sample ratio, extract positive sample item pairs from the positive sample item pair set and negative sample item pairs from the negative sample item pair set to obtain intermediate positive sample item pair set and intermediate negative sample item pair set.
[0097] In this embodiment of the application, the preset positive and negative sample ratio can be 10:1 between positive sample item pairs and negative sample item pairs, or it can be 100:5, etc.
[0098] For example, 100 positive sample item pairs can be randomly selected from the set of positive sample item pairs to obtain an intermediate set of positive sample item pairs, and 10 negative sample item pairs can be randomly selected from the set of negative sample item pairs to obtain an intermediate set of negative sample item pairs.
[0099] It should be noted that the selection can be random, or it can be determined according to the value ratio between the two corresponding items.
[0100] Step 3032: Using preset prompt templates, construct templates for the intermediate positive sample item pairs in the intermediate positive sample item pair set and the intermediate negative sample item pairs in the intermediate negative sample item pair set, respectively, to obtain the target positive sample item pair set and the target negative sample item pair set.
[0101] In this embodiment of the application, a preset prompt template can be used to construct templates for intermediate positive sample item pairs in the intermediate positive sample item pair set and intermediate negative sample item pairs in the intermediate negative sample item pair set, respectively, to obtain the target positive sample item pair set and the target negative sample item pair set; for example, the target positive sample item pairs in the target positive sample item pair set and the target negative sample item pairs in the target negative sample item pair set can be exemplified by a template such as: "Query term: item 1, result: item 2".
[0102] Step 3033: Using the target positive sample item pair set and the target negative sample item pair set, train the network parameters of the item recommendation network to be trained to obtain the trained item recommendation network.
[0103] In this embodiment of the application, multiple target positive sample item pairs from the target positive sample item pair set and multiple target negative sample item pairs from the target negative sample item pair set are further input into the item recommendation network to be trained for model training, thereby obtaining the trained item recommendation network.
[0104] The training process can be implemented through the following steps:
[0105] First, the target positive sample item pair set and the target negative sample item pair set are input into the item recommendation network to be trained for feature vector extraction, so as to obtain the sample vector of each item in the training item pair.
[0106] The training item pairs include each target positive sample item pair in the target positive sample item pair set and each target negative sample item pair in the target negative sample item pair set.
[0107] Next, determine the cosine similarity between the sample vectors of the two items in the training item pair.
[0108] Then, the loss value between the cosine similarity and the corresponding label value of the training item pair is determined;
[0109] Finally, based on the loss value, the network parameters of the item recommendation network to be trained are trained to obtain the trained item recommendation network.
[0110] In this way, firstly, by using the full-space behavior data of users corresponding to relevant items, effective item combinations, i.e., corresponding item pairs, are filtered out; secondly, based on the type relationship and value ratio between the two items in the item pair, the item pairs are labeled, thus obtaining positive sample item pairs and negative sample item pairs; finally, based on the proportion between the positive and negative sample pairs, target positive sample item pairs and target negative sample item pairs are selected for input into the item recommendation network to be trained, making the training data used in the training process of the item recommendation network more comprehensive and more in line with reality, thereby making the recommended items obtained by using the trained item recommendation network more comprehensive and accurate; compared with the recommended items determined by co-purchase or association rules in the prior art, it has a higher matching degree with relevant items and a wider coverage of item types.
[0111] The above-mentioned method for recommending items will be described below with reference to a specific embodiment. However, it is worth noting that this specific embodiment is only for better illustrating the embodiments of this application and does not constitute an improper limitation on the embodiments of this application.
[0112] In e-commerce shopping recommendation scenarios, related items need to be recommended after a user places an order or makes a purchase. Related technologies typically use recommendation methods based on shared purchases or association rules; however, shared purchases or association rules have the following drawbacks: 1. Asymmetric recommendation, such as recommending ink cartridges when buying a printer, but conversely, recommending a printer when buying ink cartridges may not be reasonable; 2. Cold-start complementary recommendation, such as newly listed products without purchase activity; 3. Complementary recommendation beyond purchase circles, such as recommendations only for products jointly purchased by users, and products not jointly purchased cannot be recommended.
[0113] To address the aforementioned issues, this application provides an item recommendation method. This method employs a trained item recommendation network to recommend relevant selected items, such as products added to the shopping cart on a relevant shopping platform. This can refer to recommending complementary items. The trained item recommendation network can be based on the BertCF model, i.e., a network obtained by fusing the Bert model with collaborative filtering. The training process of the item recommendation network to be trained corresponding to the trained item recommendation network is as follows:
[0114] The first step is to construct sample pairs: Based on the same user's valid access time series, construct valid sample pairs for products with time intervals shorter than a preset time value, such as 30 seconds (when interest has not shifted). Figure 4 The diagram illustrates the construction of effective sample pairs based on multiple users; where time is plotted on the x-axis and users on the y-axis. Figure 4 This illustrates user 1 and user 2, with multiple corresponding sample pairs constructed based on preset time intervals. Dashed lines represent sample pairs composed of two items of the same type, while solid lines represent sample pairs composed of two items of different types. Here, Figure 4 The multiple products accessed by user 2, such as i1 and i3, i1 and i2, i2 and i3, i4 and i5, i4 and i6, and i5 and i6, constitute corresponding sample pairs. The multiple products accessed by user 1, such as i1 and i2, i2 and i3, i4 and i5, i4 and i6, and i5 and i6, constitute corresponding sample pairs.
[0115] The second step is to label the sample pairs constructed in the first step, that is, to assign labels and then reverse the labels: for example... Figure 4 As shown, for user 2's click sequence i1-i2-i3, if the sample pair is of the same type of label, the label is 0; if it is of different types of labels, if the price range of the product is greater than a certain threshold, the product label is 1, otherwise the label is 0.
[0116] For example: i1: A brand laptop computer, i2: A brand silent mouse, i3: A brand laptop computer. Then the tag pair is...<i1,i2,1> ,<i2,i3,1> ,<i1,i3,0> .
[0117] The third step is to construct a positive and negative sample dataset. Here, a prompt template can be added to the samples constructed in the second step, such as "Query term: Sample 1, Result: Sample 2". As shown in Table 1, this is an example of constructing the corresponding positive and negative sample pairs.
[0118] Table 1 Examples of positive and negative sample pairs
[0119] Sample 1 Sample 2 Label Search term: Brand A laptop computer Result: Brand B laptop 0 Search term: Brand A laptop computer Result: Brand A silent mouse 1 Search term: Brand A silent mouse Result: Brand B laptop 1
[0120] The fourth step involves training the item recommendation network to be trained using the positive and negative sample pair dataset constructed in the third step, thereby obtaining the trained item recommendation network; where, for example... Figure 5 The diagram shows the framework for training the item recommendation network. 501 represents the input training sample pairs, including positive and negative sample pairs, with the query "sample 1" and result "sample 2" as an example. 502 extracts feature vectors from the two samples in each training sample pair, including word vectors, text vectors, and position vectors. 503 fuses the feature vectors extracted in 502 and performs function calculations in the model to determine the corresponding vector matrix, i.e., 504. Finally, the cosine similarity of this vector matrix is calculated to obtain the corresponding value, and the loss between this value and the corresponding label (0 or 1) of the sample pair is determined. Based on this loss, the network parameters of the item recommendation network are adjusted to obtain the trained item recommendation network.
[0121] In other words, the training process of the item recommendation network to be trained mainly consists of the following steps: First, obtain the sequence of unique product codes (Identity Documents, IDs) clicked by the user according to time from the user click log table, and construct valid sample pairs according to the definition of relevant valid sample pairs, as shown above. Figure 4 As shown; secondly, determine the labels for each valid sample pair according to the label definition rules; then, extract training and test samples according to a certain ratio of positive to negative samples; finally, according to... Figure 5 The network is trained in the manner shown.
[0122] Here, the network training process provided in this application embodiment can solve the asymmetric problem of recommended products by using prompt templates. It employs the BERTCF model, which incorporates the corpus data distribution of the current dataset, allowing it to map new product-related content onto the corresponding semantic space. This enables the learning of complementary product recommendations. Furthermore, it uses full-space user behavior data to filter effective data combinations, and uses the BERT network combined with user behavior data to construct a full-space data recommendation system. Finally, it utilizes label inversion to learn complementary product sample labels to acquire complementary information. This makes the training data used in the training process of the item recommendation network more comprehensive and realistic, resulting in more complete and accurate recommended items. Compared to existing technologies that use co-purchase or association rules to determine recommended items, this method achieves a higher degree of matching with related items and a wider coverage of item types.
[0123] As shown in Table 2, Example 1 of product recommendation, and Table 3, Example 2 of product recommendation, respectively, are examples of complementary product recommendations using a trained item recommendation network when the current product is "A brand A model notebook" and "C brand backpack". The results are multiple recommended products and the cosine similarity values between the multiple recommended products and the current product.
[0124] It should be noted that the example only recommends 10 products, and the number of recommended products in actual applications can be determined according to actual needs.
[0125] Table 2 Example of Product Recommendation 1
[0126]
[0127] Table 3 Example of Product Recommendation 2
[0128]
[0129] In this way, firstly, by using the full-space behavior data of users corresponding to relevant items, effective item combinations, i.e., corresponding item pairs, are filtered out; secondly, based on the type relationship and value ratio between the two items in the item pair, the item pairs are labeled, thus obtaining positive sample item pairs and negative sample item pairs; finally, based on the proportion between the positive and negative sample pairs, target positive sample item pairs and target negative sample item pairs are selected for input into the item recommendation network to be trained, making the training data used in the training process of the item recommendation network more comprehensive and more in line with reality, thereby making the recommended items obtained by using the trained item recommendation network more comprehensive and accurate; compared with the recommended items determined by co-purchase or association rules in the prior art, it has a higher matching degree with relevant items and a wider coverage of item types.
[0130] Based on the foregoing embodiments, this application also provides an item recommendation device 600, which can be applied to... Figures 1 to 3 In a corresponding embodiment of the item recommendation method, refer to Figure 6 As shown, the item recommendation device 600 includes:
[0131] Module 601 is used to retrieve selected items;
[0132] The feature extraction module 602 is used to extract feature vectors from the selected items using a trained item recommendation network to obtain feature vectors to be processed.
[0133] The first determining module 603 is used to determine the item feature vector whose cosine similarity with the feature vector to be processed satisfies a preset condition.
[0134] The second determining module 604 is used to determine the item represented by the item feature vector as the recommended item corresponding to the selected item.
[0135] In some embodiments, the supervision information of the trained item recommendation network during the training process includes at least: the cosine similarity between the feature vectors of the two items in the training item pair, and the supervision information between the feature vectors and the label values corresponding to the training item pair; the training item pair consists of two items whose time difference between visits by the same user within a specified interval satisfies a preset difference; the label values corresponding to the training item pair are determined based on the item value and item type of the two items constituting the training item pair.
[0136] In some embodiments, the first determining module 603 is further configured to sort the feature vectors to be screened that have a cosine similarity to the feature vector to be processed that is greater than or equal to a preset threshold in descending order of cosine similarity to the feature vector to be processed, thereby obtaining a sequence of feature vectors to be screened; and select the item feature vector that ranks first from the sequence of feature vectors to be screened based on a preset selection number.
[0137] In some embodiments, the item recommendation device further includes: a second acquisition module, configured to acquire a set of accessed items corresponding to item access records within a specified time interval; a combination and labeling module, configured to combine and label the accessed items in the set of accessed items based on the attribute information of the items, to obtain a set of positive sample item pairs and a set of negative sample item pairs; and a training module, configured to train the network parameters of the item recommendation network to be trained based on the set of positive sample item pairs and the set of negative sample item pairs, to obtain the trained item recommendation network.
[0138] In some embodiments, the combination marking module is further configured to combine two accessed items belonging to the same accessing user and whose access time difference meets a preset difference in the accessed item set to obtain a set of items to be processed; and to classify and mark the items to be processed in the set of items to be processed based on the item type and item value to obtain the set of positive sample items and the set of negative sample items.
[0139] In some embodiments, the combined labeling module is further configured to classify the pairs of items to be processed in the set of pairs of items to be processed based on the item type, to obtain a first set of items and a second set of items; the first pair of items in the first set of items includes two items of different types; the second pair of items in the second set of items includes two items of the same type; and to label the first pair of items in the first set of items and the second pair of items in the second set of items based on the item value, respectively, to obtain the positive sample set of items and the negative sample set of items.
[0140] In some embodiments, the combined labeling module is further configured to, based on the value of the items, label the first item pairs in the first item pair set using a first label and a second label to obtain the positive sample item pair set and the first negative sample item pair subset; and to, label the second item pairs in the second item pair set using the second label to obtain the second negative sample item pair subset; wherein the first negative sample item pair subset and the second negative sample item pair subset constitute the negative sample item pair set.
[0141] In some embodiments, the combined labeling module is further configured to obtain the value ratio between two items in a first item pair in the first item pair set based on the item value; wherein the value ratio represents the ratio between a first value and a second value corresponding to an item in the first item pair; the first value is greater than the second value; using the first label, the first item pair in the first item pair set whose value ratio is less than the preset ratio is labeled to obtain the positive sample item pair set; using the second label, the second item pair in the first item pair set whose value ratio is greater than or equal to the preset ratio is labeled to obtain the first negative sample item pair subset.
[0142] In some embodiments, the training module is configured to extract positive sample item pairs from the positive sample item pair set and negative sample item pairs from the negative sample item pair set according to a preset positive-negative sample ratio, respectively, to obtain an intermediate positive sample item pair set and an intermediate negative sample item pair set; construct templates for the intermediate positive sample item pairs from the intermediate positive sample item pair set and the intermediate negative sample item pair from the intermediate negative sample item pair set using a preset prompt template, respectively, to obtain a target positive sample item pair set and a target negative sample item pair set; and train the network parameters of the item recommendation network to be trained using the target positive sample item pair set and the target negative sample item pair set, to obtain the trained item recommendation network.
[0143] It should be noted that the specific implementation process of the steps performed by each module in this embodiment can be referred to Figures 1 to 3 The implementation process of the item recommendation method provided in the corresponding embodiment will not be described in detail here.
[0144] Based on the foregoing embodiments, embodiments of this application also provide an electronic device 7, which can be applied to... Figures 1 to 3 In a corresponding embodiment of the item recommendation method, refer to Figure 7 As shown, the electronic device 7 may include: a processor 71, a memory 72, and a communication bus 73, wherein:
[0145] The communication bus 73 is used to realize the communication connection between the processor 71 and the memory 72.
[0146] The processor 71 executes a program of a processing method stored in the memory 72 to implement the reference. Figures 1 to 3 The corresponding implementation provides an item recommendation method.
[0147] Based on the foregoing embodiments, embodiments of this application provide a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to achieve the following: Figures 1 to 3 The corresponding implementation provides an item recommendation method.
[0148] It should be noted that the aforementioned computer-readable storage media can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc-read-only memory (CD-ROM), etc.; or it can be various electronic devices that include one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0149] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0150] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0151] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0152] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0153] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0154] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0155] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for recommending items, the method comprising: Get the selected item; A trained item recommendation network is used to extract feature vectors from the selected items to obtain the feature vectors to be processed. Determine the item feature vectors whose cosine similarity with the feature vector to be processed satisfies a preset condition; The item represented by the item feature vector is determined as the recommended item corresponding to the selected item; The training process of the trained item recommendation network includes: Retrieve the set of items accessed within a specified time interval according to the item access records; In the set of accessed items, two accessed items belonging to the same user and whose access time difference meets a preset difference are combined to obtain a set of items to be processed; Based on the item type, the items to be processed in the set of items to be processed are classified to obtain a first set of items and a second set of items; the first item pair in the first set of items includes two items of different types; the second item pair in the second set of items includes two items of the same type. Based on the value of the items, the first item pairs in the first item pair set are labeled using a first label and a second label, resulting in a positive sample item pair set and a first negative sample item pair subset. Using the second label, the second item pairs in the second item pair set are labeled to obtain the second negative sample item pair subset; Wherein, the first subset of negative sample item pairs and the second subset of negative sample item pairs constitute the negative sample item pair set; Based on the set of positive sample item pairs and the set of negative sample item pairs, the network parameters of the item recommendation network to be trained are trained to obtain the trained item recommendation network.
2. The method according to claim 1, wherein the supervision information for the trained item recommendation network during the training process includes at least: The cosine similarity between the feature vectors of two items in a training item pair, and the supervision information between the label values corresponding to the training item pair; The training item pair consists of two items whose access time difference within a specified time interval meets a preset difference value; the tag value corresponding to the training item pair is determined based on the item value and item type of the two items constituting the training item pair.
3. The method according to claim 1, wherein determining the item feature vector whose cosine similarity with the feature vector to be processed satisfies a preset condition includes: For feature vectors to be screened whose cosine similarity with the feature vector to be processed is greater than or equal to a preset threshold, they are sorted from largest to smallest according to their cosine similarity with the feature vector to be processed to obtain a sequence of feature vectors to be screened. Based on a preset selection number, the item feature vector that ranks first is selected from the sequence of feature vectors to be filtered.
4. The method according to claim 1, wherein the step of labeling the first item pairs in the first item pair set with a first label and a second label based on the item value to obtain the positive sample item pair set and the first negative sample item pair subset includes: Based on the value of the items, obtain the value ratio between the two items in the first item pair set; wherein, the value ratio represents the ratio between the first value and the second value corresponding to the items in the first item pair; the first value is greater than the second value; Using the first label, mark the first item pairs in the first item pair set whose value ratio is less than a preset ratio, and obtain the positive sample item pair set; Using the second label, the first item pairs in the first item pair set whose value ratio is greater than or equal to the preset ratio are marked, thus obtaining the first negative sample item pair subset.
5. The method according to claim 1, wherein training the network parameters of the item recommendation network to be trained based on the positive sample item pair set and the negative sample item pair set to obtain the trained item recommendation network includes: According to the preset positive and negative sample ratio, positive sample item pairs in the positive sample item pair set and negative sample item pairs in the negative sample item pair set are extracted respectively to obtain intermediate positive sample item pair set and intermediate negative sample item pair set. Using preset prompt templates, templates are constructed for intermediate positive sample item pairs in the intermediate positive sample item pair set and intermediate negative sample item pairs in the intermediate negative sample item pair set, respectively, to obtain the target positive sample item pair set and the target negative sample item pair set; The network parameters of the item recommendation network to be trained are obtained by using the target positive sample item pair set and the target negative sample item pair set.
6. An item recommendation device, the device comprising: The acquisition module is used to acquire the selected items; The feature extraction module is used to extract feature vectors from the selected items using a trained item recommendation network to obtain feature vectors to be processed. The second acquisition module is used to acquire the set of accessed items corresponding to the item access records within a specified time interval; A combination tagging module is used to combine two accessed items belonging to the same user and whose access time difference meets a preset difference in the accessed item set to obtain a set of item pairs to be processed; based on item type, classify the item pairs to be processed in the set of item pairs to obtain a first item pair set and a second item pair set; the first item pair in the first item pair set includes two items of different types; the second item pair in the second item pair set includes two items of the same type; based on item value, use a first tag and a second tag to tag the first item pair in the first item pair set to obtain a set of positive sample item pairs and a subset of first negative sample item pairs; use the second tag to tag the second item pair in the second item pair set to obtain a subset of second negative sample item pairs; wherein, the subset of first negative sample item pairs and the subset of second negative sample item pairs constitute a set of negative sample item pairs; The training module is used to train the network parameters of the item recommendation network to be trained based on the set of positive sample item pairs and the set of negative sample item pairs, so as to obtain the trained item recommendation network. The first determining module is used to determine the item feature vector whose cosine similarity with the feature vector to be processed satisfies a preset condition; The second determining module is used to determine the item represented by the item feature vector as the recommended item corresponding to the selected item.
Citation Information
Patent Citations
Recommended item determination method and device, electronic equipment and storage medium
CN113763080A
