An item recommendation method and system based on counterfactual reasoning
By introducing counterfactual reasoning and self-supervised learning in the recommendation system, extracting internal and external factors of the session, the problem of existing recommendation systems ignoring dynamic preferences and external factors of the session is solved, and the accuracy of item recommendation is improved.
Patent Information
- Application Number
- CN202211741377.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-22
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-12-22
AI Technical Summary
Existing recommendation systems ignore the dynamic changes in user preferences in sequence sessions and rely on the assumption that the reason why the user selects items is only related to items in the session, ignoring factors outside the session.
The item recommendation method based on counterfactual reasoning is adopted to extract the session internal and session external factors of user sessions through neural networks, consider short-term dynamic preferences and long-term static preferences, and use counterfactual reasoning and self-supervised learning to improve prediction accuracy.
Improve the accuracy of predicting user clicks, avoiding mixed problems and false data problems caused by external events, especially in short sessions and small sample data scenarios.
Smart Images

Figure CN116245600B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and particularly to an item recommendation method and system based on counterfactual reasoning. Background Art
[0002] Recommendation systems can assist people in selecting suitable items and provide recommendations and references for people's decision-making. The existing research on recommendation systems mainly focuses on predicting all interaction information between users and items. The algorithms learn the static preferences of users in the process of selecting items, but ignore the fact that users' preferences in the real world change dynamically over time in a sequence of sessions. To address this problem, session recommendation has been proposed and has received increasing attention in the academic community in recent years. Existing session recommendation algorithms usually formulate the problem of predicting the next item in a session as a supervised learning problem. Given a session to be predicted, the session recommendation model takes the known items in the session as input and then outputs the probability distribution of the next item in the session. Existing sequential recommendation algorithms rely on a strong assumption that the reason a user selects an item is only because this item is related to the known items in the corresponding session. However, this assumption ignores the situation where a user may select an item for reasons outside the session. For example, on an e-commerce website, a user may select an item due to his short-term preferences, previous preferences, or because the item is on sale or is a popular trend. In these cases, the reason the item is selected is not that it is related to other items in the session. Summary of the Invention
[0003] The purpose of the present invention is to provide an item recommendation method and system based on counterfactual reasoning, which improves the accuracy of predicting user clicks on items.
[0004] To achieve the above purpose, the present invention provides the following solutions:
[0005] An item recommendation method based on counterfactual reasoning, comprising:
[0006] Obtaining a dataset of user-item interactions; the sample data in the dataset is the sessions of the user within a first set time period and the items clicked by the user at the next moment within the first set time period;
[0007] Using the dataset, taking the sessions of the user within a first set time period as input and the items clicked by the user at the next moment within the first set time period as output to train a neural network, and obtaining a trained neural network;
[0008] The neural network includes a first attention neural network, a second attention neural network, and an item recommendation neural network; the first attention neural network is used to obtain the external session factors of each user in the dataset within a first set time period; the second attention neural network is used to obtain the internal session factors of each user in the dataset within a first set time period; the external session factors include short-term dynamic preferences and long-term static preferences, the long-term static preferences are the feature vectors of the users, and the short-term dynamic preferences are the set of feature vectors of the items interacted by the users within a second set time period; the internal session factor is the correlation between the item clicked at the next moment and the session within the first set time period; the item recommendation neural network is used to predict the item clicked by the user at the next moment within the first set time period according to the external session factors and internal session factors of the user within the first set time period;
[0009] Obtain the session of the user to be predicted;
[0010] According to the similarity between sessions, obtain a set number of sessions similar to the session of the user to be predicted from a preset dataset, denoted as neighbor sessions;
[0011] Use the first attention neural network to obtain the external session factors of each of the neighbor sessions;
[0012] Use the second attention neural network to obtain the internal session factor of the session of the user to be predicted;
[0013] Respectively combine the external session factors of each of the neighbor sessions with the internal session factor of the session of the user to be predicted to form a plurality of inputs to be predicted; each input to be predicted includes the external session factor of one of the neighbor sessions and the internal session factor of the session of the user to be predicted;
[0014] Input each of the inputs to be predicted into an item recommendation model to obtain a plurality of prediction outputs; the item recommendation model is the trained item recommendation neural network in the trained neural network;
[0015] Fuse each of the prediction outputs to obtain the item clicked by the user at the next moment corresponding to the session to be predicted.
[0016] The present invention discloses an item recommendation system based on counterfactual reasoning, including:
[0017] A dataset acquisition module, configured to acquire a dataset of user-item interactions; the sample data in the dataset is the session of the user within a first set time period and the item clicked by the user at the next moment within the first set time period;
[0018] A neural network training module, which is used to adopt the said data set, take the user's session within the first set time period as the input, and the item clicked by the user at the next moment within the first set time period as the output to train the neural network, and obtain a trained neural network;
[0019] The neural network includes a first attention neural network, a second attention neural network, and an item recommendation neural network; the first attention neural network is used to obtain the external session factors of each user in the data set within the first set time period; the second attention neural network is used to obtain the internal session factors of each user in the data set within the first set time period; the external session factors include short-term dynamic preferences and long-term static preferences, the long-term static preferences are the feature vectors of the user, and the short-term dynamic preferences are the set of feature vectors of the items interacted by the user within the second set time period; the internal session factor is the correlation between the item clicked at the next moment and the session within the first set time period; the item recommendation neural network is used to predict the item clicked by the user at the next moment within the first set time period according to the external session factors and internal session factors of the user within the first set time period;
[0020] A module for obtaining a user session to be predicted, which is used to obtain a user session to be predicted;
[0021] A neighbor session obtaining module, which is used to obtain a set number of sessions similar to the user session to be predicted from a preset data set according to the similarity between sessions, and record them as neighbor sessions;
[0022] An external session factor extraction module, which is used to obtain the external session factors of each of the neighbor sessions by using the first attention neural network;
[0023] An internal session factor extraction module, which is used to obtain the internal session factors of the user session to be predicted by using the second attention neural network;
[0024] A plurality of modules for determining inputs to be predicted, which are used to respectively form a plurality of inputs to be predicted by combining the external session factors of each of the neighbor sessions with the internal session factors of the user session to be predicted; each input to be predicted includes the external session factor of one of the neighbor sessions and the internal session factor of the user session to be predicted;
[0025] A plurality of modules for determining prediction outputs, which are used to input each of the inputs to be predicted into an item recommendation model to obtain a plurality of prediction outputs; the item recommendation model is the trained item recommendation neural network in the trained neural network;
[0026] A final prediction output module, which is used to fuse each of the prediction outputs to obtain the item clicked by the user at the next moment corresponding to the user session to be predicted.
[0027] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0028] When training the neural network of the present invention, the internal session factors and external session factors of the user session are extracted from the user's session data. That is, the present invention takes into account the influence of the external session factors. When predicting the user session to be predicted, the internal session factors of the user session to be predicted are retained, and the external session factors of multiple similar neighbor sessions are used as the input of the external session factors, and multiple outputs are fused, avoiding the confounding problem and the problem of false associated data caused by the external session factors, and improving the accuracy of predicting the user's click on the item. Brief Description of the Drawings
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0030] Figure 1 It is a schematic flow chart of an item recommendation method based on counterfactual reasoning of the present invention;
[0031] Figure 2 It is a schematic structural diagram of an item recommendation system based on counterfactual reasoning of the present invention. Detailed Embodiments
[0032] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0033] The purpose of the present invention is to provide an item recommendation method and system based on counterfactual reasoning, which improves the accuracy of predicting the user's click on the item.
[0034] In order to make the above objects, features and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the drawings and specific embodiments.
[0035] The present invention classifies the reasons why a user selects an item in a session into two types: in - session reasons and out - of - session reasons. In - session reasons refer to the situation where the reason for a user to select an item is that it is associated with other items in the corresponding session, such as having a co - occurrence pattern or a sequence pattern. Out - of - session reasons refer to the situation where the reason for a user to select an item comes from outside the session, such as the user's long - term static preferences on an e - commerce website, the popularity trend of the item, or the discount of the item. For example, when item A and item B appear in the same session due to out - of - session reasons for a short period of time, the session recommendation model will learn based on this data and consider A and B to be similar. When the external factors change and A and B no longer appear in the same session, the trained session recommendation model will still recommend B after encountering A in a session because it believes that A is the reason for the user to select B, without realizing that A is not the real reason for the user to select B. This is the problem of false association that the recommendation model may encounter, which may lead to errors in the trained model.
[0036] Aiming at the problem of predicting user click behavior on an e - commerce website, the present invention discloses an item recommendation method based on counterfactual reasoning.
[0037] As Figure 1 shown, an item recommendation method based on counterfactual reasoning of the present invention includes the following steps:
[0038] Step 101: Obtain a dataset of user - item interactions; the sample data in the dataset is the sessions of users within a first set time period and the items clicked by the users at the next moment within the first set time period.
[0039] The present invention uses a computer to obtain a dataset of user - item interactions from the system log of an e - commerce website, and this dataset contains the logs of user clicks on items. Among them, the user set is represented by U, and the item set is represented by V. Each record in each log can be represented by a triple d=(u, v, t), which means that user u clicks on item v at time t. A session is an important structure in the user interaction log and is a set of records of user interactions within a short period of time, denoted as where represents the t - th item clicked by the user in session s. According to different needs, the interaction records between users and items within different time lengths can be used as a session. In the present invention, the daily interaction log between users and items is used as a session.
[0040] The goal of the present invention is, given a user's session to predict the (t + 1)-th item For example, on an e-commerce website, after a user logs in to the website and clicks on several items, a session s is formed. The present invention predicts the items that the user will click next based on these clicked items, that is, calculates the probability p(v|M,N) of an item being clicked. Where M represents the session internal factors and N represents the session external factors. Session internal factors refer to the influence of known items within the session on the user's selection, and session external factors refer to the influence of factors outside the session on the user's selection.
[0041] Step 102: Use the dataset to train a neural network with the user's sessions within the first set time period as the input and the items clicked by the user at the next moment within the first set time period as the output, to obtain a trained neural network.
[0042] The user's session within the first set time period is represented as
[0043] Wherein, represents the first item clicked by the user in session s, represents the t-th item clicked by the user in session s.
[0044] The neural network includes a first attention neural network, a second attention neural network, and an item recommendation neural network; the first attention neural network is used to obtain the session external factors of each user in the first set time period in the dataset; the second attention neural network is used to obtain the session internal factors of each user in the first set time period in the dataset; the session external factors include short-term dynamic preferences and long-term static preferences, the long-term static preferences are the feature vectors of the user, and the short-term dynamic preferences are the set of feature vectors of the items interacted by the user within the second set time period, and the session internal factor is the correlation between the item clicked at the next moment and the session within the first set time period; the item recommendation neural network is used to predict the items clicked by the user at the next moment within the first set time period according to the session external factors and session internal factors of the user within the first set time period.
[0045] In the present invention, the item recommendation neural network takes the session internal factors and session external factors of the user's item selection as the input and predicts the probability distribution of the next item of a session. The construction process of the item recommendation neural network is as follows.
[0046] Step 1021: Model the session external factors. Consider two common session external factors in session recommendation, namely the short-term dynamic preferences of the user and the long-term static preferences of the user. For static preferences, directly represent the static preferences according to the user's implicit feature vectors; for dynamic preferences, use the user's implicit feature vector representation as the query vector, and the vector representations corresponding to all the items that the user has interacted with as the vectors to be queried, and calculate the dynamic vector representation h according to the attention neural network N(s). Among them, the input of the attention neural network is the user implicit feature vector and the set of implicit feature vectors of the items that the user has interacted with recently, and the output is h N (s). Finally, use h N (s) as the vector representation of the session external factor.
[0047] Step 1022: Model the session internal factor. The session internal factor mainly refers to the association relationship between the item to be predicted and the items within the session. Therefore, use the vector representation of the item to be predicted as the query vector, and the vector representations of all items in the session as the vectors to be queried, and calculate the vector h according to the attention network M (s), where the input of the attention network is the set of implicit feature vectors of the items within session s. Finally, use h M (s) as the vector representation of the session internal factor.
[0048] Step 1023: Reason selection. Use a multi-layer perceptron to calculate the importance degree λ of the session external factor and the session internal factor for the user to select the commodity. Among them, the input of the multi-layer perceptron is the external factor representation h N (s) and the internal factor representation h M (s), and the output is the weight value λ between 0 and 1. The larger λ is, the more important the internal factor is. On the contrary, the more important the external factor is. When λ = 0, it means that the user mainly selects items according to the external factor. On the contrary, when λ = 1, it means that the user mainly selects items according to the internal factor.
[0049] Step 1024: Recommendation module. According to the selection weight of the reason, use the internal factor vector, the external factor vector and their weights as the input, and output the score p(v|M,N) recommended for the item to be predicted by weighted summing the internal factor vector and the external factor vector.
[0050] During the entire neural network training process, the prediction of the neural network can be regarded as a multi-classification problem. The present invention uses the cross-entropy loss function shown in formula (1) to cooperate with the optimization algorithm based on gradient descent to train the proposed neural network:
[0051]
[0052] Among them, s represents the session, c is the known part in s, c is the context of s, S b represents the set of all sessions in the training batch, V b represents all items in the training batch, v represents the item to be predicted, v′∈V b is an item in Vx, M represents the session internal factor, N represents the session external factor,. When flag is true, 1[flag] = 1, otherwise 1[flag] = 0.
[0053] The above neural network uses a multi-layer perceptron to predict the true reason why a user selects an item. However, the true reason is a hidden variable, and the model cannot identify the true reason well. To address this problem, the present invention proposes a method of self-supervised training to improve the model's ability to identify the true reason. Specifically, a pseudo-label is designed for the weights of the in-session factors and out-of-session factors, and an additional self-supervised loss function as shown in formula (2) is added, and the model is jointly trained to improve the model's ability to obtain the true reason.
[0054]
[0055] The total loss function in the training process of the neural network is expressed as:
[0056] L = l 1 + αl 2 ;
[0057] where L represents the total loss function, l 1 represents the cross-entropy loss function, l 2 represents the self-supervised loss function, α represents a hyperparameter, and λ represents a weight coefficient. BCE (Binary cross-entropy) is binary cross-entropy, which is defined as BCE(x, y) = ylogx + (1 - y)log(1 - x), where x represents the first input value of the BCE function and y represents the second input value of the BCE function. y N (s) = 1[v ∈ V u represents whether the item v is an item V that the user has interacted with u , y M (s) = 1[v ∈ c] represents whether the item v to be predicted is an item in the context c of s, and V u is the item clicked by the user u in the session s.
[0058] α is a hyperparameter used to balance the accuracy of item prediction and the weights of in-session and out-of-session factors.
[0059] The setting strategy of the pseudo-label is that if the item appears in the known items of the session, the label is set as the in-session factor; otherwise, when the item appears in the items interacted with by the user, it is set as the out-of-session factor.
[0060] Step 103: Obtain the user session to be predicted.
[0061] Step 104: According to the similarity between sessions, obtain a set number of sessions similar to the user session to be predicted from the preset dataset, and record them as neighbor sessions.
[0062] Among them, step 104 specifically includes:
[0063] Calculate the cosine similarity between the user session to be predicted and each session in the preset dataset respectively to obtain multiple cosine similarity values.
[0064] Select the set number of cosine similarity values from the multiple cosine similarity values in descending order.
[0065] Mark the sessions in the preset dataset corresponding to the selected set number of cosine similarity values as the neighbor sessions of the user session to be predicted.
[0066] Step 105: Use the first attention neural network to obtain the external session factors of each neighbor session.
[0067] Step 106: Use the second attention neural network to obtain the internal session factor of the user session to be predicted.
[0068] Step 107: Combine the external session factors of each neighbor session and the internal session factor of the user session to be predicted to form multiple inputs to be predicted; each input to be predicted includes the external session factor of one neighbor session and the internal session factor of the user session to be predicted.
[0069] Step 108: Input each input to be predicted into the item recommendation model to obtain multiple prediction outputs; the item recommendation model is the trained item recommendation neural network in the trained neural network.
[0070] Step 109: Fuse each prediction output to obtain the item that the user session to be predicted will click at the next moment.
[0071] The output layer of the item recommendation model is used to output the probabilities of the user clicking on each item at the next moment, and the item with the highest probability is used as the output.
[0072] Among them, step 109 specifically includes:
[0073] Average the probabilities of the user clicking on each item at the next moment corresponding to each prediction output as the probabilities of the user session to be predicted clicking on each item at the next moment, and the item with the highest probability is used as the output.
[0074] When the present invention uses an item recommendation model to predict a user session to be predicted, model intervention is performed. The goal of the model intervention is to predict, through counterfactual reasoning, a user's choice in a given session under internal and external session factors. The input of the algorithm includes the session s to be predicted and another session c randomly selected from the training set. The output of the algorithm is the probability distribution p(v|M,N) of items. Among them, counterfactual reasoning refers to a kind of reasoning of "what would the result be if the conditions were changed". In the present invention, counterfactual refers to: how do other users choose under the same session scenario as the target session? Specifically, according to the session to be predicted, the algorithm first samples some neighbor sessions s' similar to the session s to be predicted. Next, using the external factors of these neighbor sessions, the internal factors of these neighbor sessions are replaced with the internal factors of the session to be predicted. Then, the external factors of these neighbor sessions and the modified internal factors are used as the input for training the basic recommendation model, and the prediction result of the next item of each neighbor session is output, that is, p(v|M(s),N(s')), where M(s) is the internal factor of s and N(s') is the external factor of s'.
[0075] The prediction results of all neighbor sessions obtained in the previous step are weighted and summed according to their similarity to the session to be predicted to obtain the prediction result p(v|M(s),N(s)).
[0076] An item recommendation method based on counterfactual reasoning according to the present invention further includes:
[0077] If there are items that the user has interacted with among the items clicked by the user to be predicted at the next moment, a set value (enhancement factor) is added to the probability of the items that the user has interacted with to obtain the modified probability distribution of the items clicked by the user to be predicted at the next moment.
[0078] The modified probability distribution of the items clicked by the user to be predicted at the next moment is normalized.
[0079] The item with the largest probability after normalization is used as the output.
[0080] The present invention further improves the algorithm performance through an enhancement factor. Specifically, if a to-be-predicted item appears in the current session or the user has interacted with it, a small weight is added to the score of the item. Finally, the weights of all items are normalized to obtain the probability distribution of the next item of the session to be predicted.
[0081] The technical effects of the present invention are as follows:
[0082] 1. The present invention has a significant improvement in accuracy compared with the existing sequential session recommendation algorithm.
[0083] Reason: The algorithm proposed in the present invention takes into account the external session factors that are rarely considered in existing work, avoiding the confounding problems caused by external session factors and the incorrect modeling problems caused by data training models with false associations. This algorithm explicitly models the internal and external factors of the session respectively, uses an attention neural network to estimate the true reasons for a user to select an item, and then improves the model's ability to estimate the true reasons for a user to select an item through a specifically designed self-supervised learning method. The present invention also uses counterfactual inference to estimate the selections of other users in the same session as an important reference for prediction, and the application of counterfactual inference alleviates the data sparsity problem faced when searching for neighbor sessions. Finally, the present invention also proposes an enhancement factor to further improve the performance of the algorithm by increasing the weights of the items interacted with by the user.
[0084] 2. The present invention has excellent performance in challenging scenarios such as short sessions and small sample data.
[0085] Reason: The algorithm proposed in the present invention takes into account various reasons for a user to select an item, while existing work mainly considers the internal session factors of item selection. When faced with a short session, there are very few items in the session, and the model's ability to infer the internal session factors from the session content is greatly reduced, making it difficult to accurately predict the user's next item selection in the current scenario without considering the external session factors. However, in this work, due to the consideration of the external session factors for a user to select an item, even when the prediction of the internal session factors is insufficient, the algorithm can still make a relatively accurate judgment based on the external session factors. Therefore, in challenging scenarios such as short sessions, the proposed algorithm can accurately predict the next item selected by the user.
[0086] 3. Each module of the present invention can improve the performance of the algorithm and can be applied to other related work.
[0087] Reason: The counterfactual recommendation framework proposed in the present invention can be applied to recommendation algorithms based on collaborative filtering, potentially improving the accuracy of related algorithms. The training method based on self-supervised learning proposed in the present invention can play a role in improving the discrimination of different factors in related work on causal representation learning. The enhancement factor proposed in the present invention can be widely applied to all session recommendation algorithms, effectively improving the performance of session recommendation algorithms. Finally, the problem that the external session factors proposed in the present invention interfere with the training of the recommendation model actually widely exists in many algorithm scenarios based on supervised learning, and will have an enlightening effect on the improvement of related algorithms from the perspective of the problem.
[0088] Figure 2 This is a schematic structural diagram of an item recommendation system based on counterfactual reasoning according to the present invention, as Figure 2 shown, an item recommendation system based on counterfactual reasoning includes:
[0089] A dataset acquisition module 201 for acquiring a dataset of user-item interactions; the sample data in the dataset is the user's session within a first set time period and the item clicked by the user at the next moment within the first set time period.
[0090] A neural network training module 202 for using the dataset to train a neural network with the user's session within a first set time period as the input and the item clicked by the user at the next moment within the first set time period as the output, to obtain a trained neural network.
[0091] The neural network includes a first attention neural network, a second attention neural network, and an item recommendation neural network; the first attention neural network is used to obtain the external session factors of each user in the dataset within a first set time period; the second attention neural network is used to obtain the internal session factors of each user in the dataset within a first set time period; the external session factors include short-term dynamic preferences and long-term static preferences, the long-term static preferences are the user's feature vectors, the short-term dynamic preferences are the set of feature vectors of the items interacted with by the user within a second set time period, and the internal session factor is the correlation between the item clicked at the next moment and the session within the first set time period; the item recommendation neural network is used to predict the item clicked by the user at the next moment within the first set time period according to the external session factors and internal session factors of the user within the first set time period.
[0092] A to-be-predicted user session acquisition module 203 for acquiring a to-be-predicted user session.
[0093] A neighbor session acquisition module 204 for obtaining a set number of sessions similar to the to-be-predicted user session from a preset dataset according to the similarity between sessions, denoted as neighbor sessions.
[0094] An external session factor extraction module 205 for using the first attention neural network to obtain the external session factors of each of the neighbor sessions.
[0095] An internal session factor extraction module 206 for using the second attention neural network to obtain the internal session factor of the to-be-predicted user session.
[0096] A plurality of to-be-predicted input determination modules 207 for respectively combining the external session factors of each of the neighbor sessions with the internal session factor of the to-be-predicted user session to form a plurality of to-be-predicted inputs; each to-be-predicted input includes the external session factor of one of the neighbor sessions and the internal session factor of the to-be-predicted user session.
[0097] A plurality of prediction output determination modules 208 for inputting each of the to-be-predicted inputs into an item recommendation model to obtain a plurality of prediction outputs; the item recommendation model is the trained item recommendation neural network in the trained neural network.
[0098] The final prediction output module 209 is configured to fuse each of the prediction outputs to obtain an item to be clicked at the next moment corresponding to the user session to be predicted.
[0099] In the present specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference may be made to each other. For the system disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference may be made to the description in the method part.
[0100] In this article, specific examples are used to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation on the present invention.
Claims
1. An item recommendation method based on counterfactual reasoning, characterized in that, it includes: Obtain a dataset of user-item interactions; the sample data in the dataset is the user's session within the first set time period and the item clicked by the user at the next moment within the first set time period; Using the dataset, take the user's session within the first set time period as the input and the item clicked by the user at the next moment within the first set time period as the output to train a neural network, and obtain a trained neural network; The neural network includes a first attention neural network, a second attention neural network, and an item recommendation neural network; the first attention neural network is used to obtain the external session factors of each user in the dataset within the first set time period; the second attention neural network is used to obtain the internal session factors of each user in the dataset within the first set time period; the external session factors include short-term dynamic preferences and long-term static preferences, the long-term static preferences are the feature vectors of the user, the short-term dynamic preferences are the set of feature vectors of the items interacted by the user within the second set time period, and the internal session factor is the correlation between the item clicked at the next moment and the session within the first set time period; the item recommendation neural network is used to predict the item clicked by the user at the next moment within the first set time period according to the external session factors and internal session factors of the user within the first set time period; Obtain the session of the user to be predicted; According to the similarity between sessions, obtain a set number of sessions similar to the session of the user to be predicted from a preset dataset, denoted as neighbor sessions; Use the first attention neural network to obtain the external session factors of each of the neighbor sessions; Use the second attention neural network to obtain the internal session factors of the session of the user to be predicted; Respectively combine the external session factors of each neighbor session with the internal session factors of the session of the user to be predicted to form multiple prediction inputs; each prediction input includes the external session factor of one neighbor session and the internal session factor of the session of the user to be predicted; Input each of the prediction inputs into the item recommendation model to obtain multiple prediction outputs; the item recommendation model is the trained item recommendation neural network in the trained neural network; Fuse each of the prediction outputs to obtain the item clicked by the user at the next moment corresponding to the session of the user to be predicted.
2. The item recommendation method based on counterfactual reasoning according to claim 1, characterized in that, The output layer of the item recommendation model is used to output the probability of the user clicking each item at the next moment, and take the item with the highest probability as the output.
3. The item recommendation method based on counterfactual reasoning according to claim 2, characterized in that, The step of fusing each of the prediction outputs to obtain the item clicked by the user at the next moment corresponding to the session of the user to be predicted specifically includes: Correspondingly average the probabilities of the user clicking each item at the next moment corresponding to each of the prediction outputs as the probabilities of the user to be predicted clicking each item at the next moment, and take the item with the highest probability as the output.
4. The item recommendation method based on counterfactual reasoning according to claim 3, characterized in that, It further includes: If there is an item that the user has interacted with among the items that the to-be-predicted user will click at the next moment, then increase the probability of the item that the user has interacted with by a set value, and obtain the modified probability distribution of the items that the to-be-predicted user will click at the next moment; Normalize the modified probability distribution of the items that the to-be-predicted user will click at the next moment; Take the item with the largest probability after normalization as the output.
5. The item recommendation method based on counterfactual reasoning according to claim 1, wherein, the total loss function in the neural network training process is expressed as: L=l 1 +αl 2 ; Among them, L represents the total loss function, and l 1 represents the cross-entropy loss function, and l 2 represents the self-supervised loss function, α represents the hyperparameter, S b represents the set of all sessions in the dataset, V b represents the set of all items in the dataset, v represents the item to be predicted, v′ represents the predicted item output by the neural network, s represents the session, c is the context of s, M represents the internal cause of the session, N represents the external cause of the session, and λ represents the weight coefficient; BCE() represents the binary cross-entropy loss function, y N (s) represents whether the item v is an item V that the user has interacted with u , y M (s) represents whether the item v to be predicted is an item in the context c of s, y N (s) = 1[v ∈ V u , V u is the item clicked by the user u in the session s; y M (s) = 1[v ∈ c]; BCE(x, y) = ylogx + (1 - y)log(1 - x), where x represents the first input value of the BCE function and y represents the second input value of the BCE function.
6. The item recommendation method based on counterfactual reasoning according to claim 1, wherein, The user's session within the first set time period is represented as Among them, represents the first item clicked by the user in session s, represents the t-th item clicked by the user in session s.
7. The item recommendation method based on counterfactual reasoning according to claim 1, wherein, the step of obtaining a set number of sessions similar to the to-be-predicted user's session, denoted as neighbor sessions, from a preset data set according to the similarity between sessions specifically includes: Calculate the cosine similarity between the to-be-predicted user's session and each session in the preset data set respectively, and obtain a plurality of cosine similarity values; Select the set number of cosine similarity values from the plurality of cosine similarity values in descending order; Denote the sessions in the preset data set corresponding to the selected set number of cosine similarity values as the neighbor sessions of the to-be-predicted user's session.
8. An item recommendation system based on counterfactual reasoning, wherein, it includes: a data set acquisition module, configured to acquire a data set of user-item interactions; the sample data in the data set is the session of the user within a first set time period and the items that the user clicks at the next moment within the first set time period; a neural network training module, configured to use the data set to train a neural network with the session of the user within a first set time period as the input and the items that the user clicks at the next moment within the first set time period as the output, and obtain a trained neural network; the neural network includes a first attention neural network, a second attention neural network, and an item recommendation neural network; the first attention neural network is used to obtain the session external factors of each user in the data set within a first set time period; the second attention neural network is used to obtain the session internal factors of each user in the data set within a first set time period; the session external factors include short-term dynamic preferences and long-term static preferences, the long-term static preferences are the feature vectors of the user, the short-term dynamic preferences are the set of feature vectors of the items interacted with by the user within a second set time period, and the session internal factors are the correlation between the items clicked at the next moment and the session within the first set time period; the item recommendation neural network is used to predict the items that the user will click at the next moment within the first set time period according to the session external factors and session internal factors of the user within the first set time period; a to-be-predicted user session acquisition module, configured to acquire a to-be-predicted user session; a neighbor session acquisition module, configured to obtain a set number of sessions similar to the to-be-predicted user's session, denoted as neighbor sessions, from a preset data set according to the similarity between sessions; A session external factor extraction module, which is used to obtain the session external factors of each of the neighbor sessions by using a first attention neural network; A session internal factor extraction module, which is used to obtain the session internal factors of the user session to be predicted by using a second attention neural network; A plurality of inputs to be predicted determination modules, which are respectively used to form a plurality of inputs to be predicted by combining the session external factors of each of the neighbor sessions with the session internal factors of the user session to be predicted; each input to be predicted includes the session external factor of one of the neighbor sessions and the session internal factor of the user session to be predicted; A plurality of predicted output determination modules, which are used to input each of the inputs to be predicted into an item recommendation model to obtain a plurality of predicted outputs; the item recommendation model is an item recommendation neural network trained in a trained neural network; A final predicted output module, which is used to fuse each of the predicted outputs to obtain the item clicked at the next moment corresponding to the user session to be predicted.
Citation Information
Patent Citations
Session-based recommendation method and device
CN113222700A
E-commerce platform session awareness recommendation prediction method based on long and short term interests
CN115293812A