Movie recommendation method and system based on deep reinforcement learning
By preprocessing the user's positive and negative feedback sequences and using a contrastive loss function, combined with Actor and Critic network optimization, the sparsity and variability of positive and negative feedback in movie recommendation are solved, improving the accuracy and performance of recommendations.
Patent Information
- Application Number
- CN202311862480.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-12-29
AI Technical Summary
Existing deep reinforcement learning methods have failed to effectively alleviate the problems of sparsity of positive and negative feedback data and the differences between fine-grained positive and negative feedback in movie recommendation.
By preprocessing the user's positive and negative feedback sequences, the user's interest state is obtained using GRU layers and self-attention layers. The contrastive loss function is combined to increase the difference between positive and negative feedback, and the movie recommendation list is optimized using Actor and Critic networks.
It improves the accuracy and performance of movie recommendations, makes more comprehensive use of user feedback, alleviates data sparsity issues, and generates recommendation lists that better match user interests.
Smart Images

Figure CN117725318B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning recommendation technology, specifically a movie recommendation method and system based on deep reinforcement learning. Background Technology
[0002] Deep reinforcement learning (DRL) technology has been successfully applied in fields such as autonomous driving and recommendation systems. Among these, policy optimization-based DRL is a crucial research area in recommendation. DDPG combines deep neural networks and deterministic policy gradient methods to train reinforcement learning agents capable of handling high-dimensional state spaces and continuous action spaces. PPO utilizes proximal policy optimization and policy gradient methods to train agents to maximize cumulative rewards, and improves training stability and efficiency by introducing mechanisms such as importance ratio pruning and advantage functions. The DRR algorithm proposes four state representation learning schemes that can explicitly model the interaction between users and items. The LSIC algorithm uses policy gradient algorithms to update the generator model parameters in the generative adversarial network framework, solving the problem that discrete sampling cannot directly use gradient descent in the task of generating recommendation lists. These methods can adapt well to users' personalized needs, continuously interacting and learning from users, and adjusting recommendation strategies based on user feedback and behavior. However, these methods only consider positive feedback and ignore the information implicit in the negative feedback state representation, and suffer from a certain degree of data sparsity.
[0003] Therefore, in the process of movie recommendation, how to alleviate the sparsity of positive and negative feedback data and increase the difference between fine-grained positive and negative feedback is a technical problem that urgently needs to be solved. Summary of the Invention
[0004] The technical objective of this invention is to provide a movie recommendation method and system based on deep reinforcement learning to address the problems of mitigating the sparsity of positive and negative feedback data and increasing the differences between fine-grained positive and negative feedback during the movie recommendation process.
[0005] The technical objective of this invention is achieved as follows: a movie recommendation method based on deep reinforcement learning, the specific method of which is as follows:
[0006] Preprocessing: Obtain user rating data and user attributes from the movie-related dataset. Preprocess the historical data of user ratings and user attributes to obtain the positive and negative feedback sequence embedding representation and user vector. Then, concatenate the output of the user's positive and negative feedback sequence after network processing with the user vector to form the user's interest state after giving evaluation feedback on any movie.
[0007] Obtain the contrastive loss function: Increase the difference between the positive and negative feedback sequence representations by using the contrastive loss function to reduce the impact of data sparsity;
[0008] Generating a movie recommendation list: The user's positive and negative feedback sequence, user vector, and user's interest state after giving feedback on any movie are processed by the Actor network to obtain action vectors, and then a movie recommendation list is generated.
[0009] Optimize and update the movie recommendation list: After a user provides feedback on any movie, their interest state, user vector, and action vector are used by the Critic network to generate a state-action value function under a given state and action. This function updates the parameters of the Actor network, thereby obtaining an optimized movie recommendation list.
[0010] As a preferred option, the preprocessing is as follows:
[0011] Read historical data of user movie ratings and user attributes from the Movielens-1m dataset, and perform data preprocessing to obtain user positive and negative feedback sequences and user vectors; among them, user attributes include user ID, gender, age and occupation;
[0012] For the user's initial positive feedback sequence, the movies that the user has rated and that have a rating of 3 points or higher are sorted by the timestamp of the user's rating and used as the user's initial positive feedback sequence.
[0013] For the user's initial negative feedback sequence, random sampling is performed on movies with user ratings below 3 points and movies that the user has not rated. The sampled movies are sorted according to the timestamp of the last time they were rated by other users as the user's initial negative feedback sequence.
[0014] User vectors are obtained by preprocessing user attributes from movie recommendation platforms;
[0015] The user vector and positive and negative feedback sequences are passed through a GRU layer to capture the potential temporal relationship between the movies in the user's positive and negative feedback sequences:
[0016] z n =σ(i n W z +U z h n-1 );
[0017] r n =σ(i n W r +U r h n-1 );
[0018]
[0019]
[0020] Among them, in This represents the negative feedback sequence embedding representation formed by inputting movies with user ratings below 3 or no rating into the GRU layer; σ represents the sigmoid function; W z h represents the weight matrix associated with the update gate. n-1 This represents the hidden state at the previous time step; z n Indicates updating the gate's output; W r This represents the weight matrix associated with the reset gate; r n Indicates that the output of the reset gate is being reset; Represents the candidate hidden state at the current time step; W represents the weight matrix associated with the candidate hidden state; h n This indicates the hidden state at the current time step;
[0021] The method for obtaining the embedding representation of the user's positive feedback sequence using the GRU layer is the same as the method for obtaining the embedding representation of the negative feedback sequence.
[0022] Set the hidden state h at the current time step n After being combined with user embedding and passed through a self-attention layer, the weight W is generated to indicate the user's liking for each movie in the positive and negative feedback sequence. i To highlight the most important parts and reduce the impact of noisy information;
[0023] To reduce computational load and noise interference, the weighted positive and negative feedback item features are further processed by an average pooling layer to obtain optimized positive and negative feedback item features.
[0024] The optimized positive and negative feedback project features are concatenated with the user vector to obtain the user's interest state s after giving a rating to any movie. + and s - .
[0025] More preferably, the contrastive loss function is obtained as follows:
[0026] During preprocessing, the dataset is used to obtain the movie attributes that users like; movie attributes include movie title and movie category.
[0027] The auxiliary contrastive loss function used to increase the difference between positive and negative feedback is as follows: (This is achieved by narrowing the feature distance between the user's favorite movie features and the user's positive feedback augmented sequence, and widening the feature distance between the user's favorite movie features and the user's negative feedback augmented sequence.)
[0028]
[0029] in, Indicates the state s + Positive feedback augmented sequences obtained after data augmentation through masking operations; Indicates the state s - The negative feedback augmented sequence obtained after data augmentation by masking; d represents the cosine similarity between the positive feedback augmented sequence and the negative feedback augmented sequence.
[0030] Even better, the movie recommendation list is generated as follows:
[0031] A dual-tower structure is used in the input part of the Actor network for state s. + and state s - The inputs are processed using MLPs with identical structures but different parameters to calculate their respective weights, and then processed by another MLP to obtain the final state s. The calculation method for the positive feedback weights is as follows:
[0032]
[0033] Where W1, W2, W3, and W4 represent weight matrices; b1, b2, b3, and b4 represent bias terms; and the negative feedback state s - The calculation method and positive feedback state s + same;
[0034] The processed state s + and s - After being concatenated with the user vector, it is input into the Actor network. The Actor network outputs a continuous vector parameter action vector a = π. θ (s + ,u,s - );
[0035] Redesign the loss function J for Actor network training iterations π (φ), the formula is as follows:
[0036]
[0037] Wherein, the loss function J of the Actor network training iteration π (φ) is used to better adapt to the input of the positive and negative feedback dual sequences to update the network parameters; Indicates the expected value; Represents the experience pool; the f(·) function outputs the mean and variance; ∈ represents noise; L c Let represent the auxiliary contrast loss function for positive and negative feedback samples; λ represents a parameter used to control the weights of the auxiliary contrast loss function; α represents an auto-adjustment parameter, and the loss function for parameter α is... a represents a continuous parameter vector;
[0038] The continuous parameter vector 'a' is multiplied by all movie embedding spaces to obtain the predicted ranking score of the user's liking for all movies in the entire movie space. The movie space is then sorted according to the ranking score of liking to form a movie recommendation list corresponding to the user's state.
[0039] Furthermore, the movie recommendation list has been optimized and updated as follows:
[0040] The Critic network uses continuous state vectors s + s - Using the user vector u and the action value a obtained from the Actor network as input, we obtain the estimated value Q(s) of the state-action value function given the state and action. + ,u,s - , a);
[0041] According to Q(s) + ,u,s - a) Value: The parameters of the Actor network are gradually optimized to increase the probability of recommending movies that users like more.
[0042] The Critic network consists of two Q-networks with identical structures but different parameters. During each training step, the minimum Q-value between the two Q-networks is calculated as the estimate of the state-action value function, Q(s). + ,u,s - a) The formula is as follows:
[0043]
[0044]
[0045] Q(s + ,u,s - , a)=min(Q1(s + ,u,s - ,a),Q2(s + ,u,s - ,a))
[0046] Among them, s ’+ s represents the positive feedback sequence in the next state representation; ’- This represents the negative feedback sequence in the next state representation; π(a'|s ’+ ,u,s ’- ) indicates that in state (s) ’+ ,u,s ’- The probability of taking action a' under condition ).
[0047] Another Q-network is used to validate and stabilize the estimation results of the first Q-network. The reason for using a double Q-network is to mitigate the overestimation problem.
[0048] To accommodate both positive and negative feedback inputs and to better suit the parameters of the improved Actor network, the loss function J for the training iterations of the Critic network was redesigned. Q (θ), the formula is as follows:
[0049]
[0050] Where θ represents the parameters of the Q-network; V represents the state-value function, which is the expected cumulative reward for the recommended movie under the current movie recommendation strategy and value network estimation in state s'. Similar to DDPG, the Critic network also constructs a target soft Q-network parameter. parameter It is obtained through the parameters θ of the Q-network.
[0051] A movie recommendation system based on deep reinforcement learning, the system comprising:
[0052] The preprocessing module is used to obtain user rating data and user attributes in the movie-related dataset. It preprocesses the historical data of user ratings and user attributes to obtain the user's positive and negative feedback sequence embedding representation and user vector. Then, it concatenates the output of the user's positive and negative feedback sequence after network processing with the user vector to form the user's interest state after giving evaluation feedback on any movie.
[0053] The acquisition module is used to increase the difference between positive and negative feedback sequence representations by comparing loss functions, thereby reducing the impact of data sparsity.
[0054] The generation module is used to process the user's positive and negative feedback sequences, user vectors, and user interest states after giving feedback on any movie through the Actor network to obtain action vectors, and then generate a movie recommendation list.
[0055] The optimization and update module is used to generate a state-action value function for a given state and action based on the user's interest state, user vector, and action vector after the user provides feedback on any movie. This function updates the parameters of the Actor network and thus obtains an optimized movie recommendation list.
[0056] Preferably, the preprocessing module includes:
[0057] The acquisition submodule is used to read historical data of user movie ratings and user attributes from the Movielens-1m dataset, and perform data preprocessing to obtain the user's positive and negative feedback sequences and user vectors. The user attributes include user ID, gender, age, and occupation; details are as follows:
[0058] ① For the user's initial positive feedback sequence, the movies that the user has rated and that have a rating of 3 points or higher are sorted by the timestamp of the user's rating as the user's initial positive feedback sequence;
[0059] ② For the user's initial negative feedback sequence, randomly sample movies that the user has rated below 3 points and movies that the user has not rated. Sort the sampled movies according to the timestamp of the last time they were rated by other users as the user's initial negative feedback sequence.
[0060] ③ Obtain user vectors by preprocessing the user attributes in the movie recommendation platform;
[0061] The GRU layer is used to capture the sequence relationship of the user on the movie time series using the user vector and the positive and negative feedback sequences:
[0062] z n =σ(i n W z +U z h n-1 );
[0063] r n =σ(i n W r +U r h n-1 );
[0064]
[0065]
[0066] Among them, i n This represents the negative feedback sequence embedding representation formed by inputting movies with user ratings below 3 or no rating into the GRU layer; σ represents the sigmoid function; W z h represents the weight matrix associated with the update gate. n-1 This represents the hidden state at the previous time step; z n Indicates updating the gate's output; W r This represents the weight matrix associated with the reset gate; r n Indicates that the output of the reset gate is being reset; Represents the candidate hidden state at the current time step; W represents the weight matrix associated with the candidate hidden state; h n This indicates the hidden state at the current time step;
[0067] The method for obtaining the embedding representation of the user's positive feedback sequence using the GRU layer is the same as the method for obtaining the embedding representation of the negative feedback sequence.
[0068] A self-attention layer is used to store the hidden state h at the current time step. n Combined with user embedding, it generates the user's liking for each movie in the positive and negative feedback sequence, i.e., the weight W. i To highlight the most important parts and reduce the impact of noisy information;
[0069] Average pooling layer is used to obtain positive and negative feedback item features using weighted features;
[0070] The concatenation submodule is used to concatenate the positive and negative feedback item features with the user vector to obtain the user's interest state s after giving a rating to any movie. + and s - ;
[0071] The acquisition module includes:
[0072] The data augmentation submodule is used to obtain augmented sequences for both positive and negative feedback sequences using data augmentation.
[0073] The contrast loss value acquisition submodule is used to obtain the corresponding cosine similarity from the augmented sequences of the positive and negative feedback sequences to calculate the contrast loss value, which is then used to optimize the parameters together with the loss function of the Actor network.
[0074] More preferably, the generating module uses an Actor network to receive state s when user behavior changes. + and s - The user vector u is taken as input, and a value in state s = (s + ,u,s - The probability value of each movie is recommended, and the recommended movie list is obtained after sorting the movies according to the probability value.
[0075] The optimization and update module uses the Critic network to receive the output action vector 'a' and state 's' from the Actor network. + s - Using the user vector u as input, we obtain the estimated value Q(s) of the state-action value function given the state and action. + ,u,s - , a), through Q(s + ,u,s - a) Predict the cumulative reward obtained by recommending movies under the corresponding state.
[0076] An electronic device includes: a memory and at least one processor;
[0077] The memory contains computer programs;
[0078] The at least one processor executes the computer program stored in the memory, causing the at least one processor to perform the movie recommendation method based on deep reinforcement learning as described above.
[0079] A computer-readable storage medium storing a computer program that can be executed by a processor to implement the deep reinforcement learning-based movie recommendation method described above.
[0080] The movie recommendation method and system based on deep reinforcement learning of the present invention have the following advantages:
[0081] (i) This invention obtains the potential relationship between users and projects by modeling the positive and negative feedback sequences generated during the interaction between users and intelligent agents in the movie recommendation platform. In order to alleviate the problem of sparsity of positive feedback data and the differences between fine-grained positive and negative feedback, a comparison auxiliary task is also added.
[0082] (ii) Compared with existing deep reinforcement learning-based recommendation methods, this invention can comprehensively combine user feedback information to obtain deeper user interests and preferences, and can also alleviate the problem of data sparsity.
[0083] (iii) The positive and negative feedback sequences given by users to movies are used to extract the potential relationship between users and movies. Contrastive learning is used to alleviate the data sparsity problem and fine-grained positive and negative feedback differences. Then, the Actor is used to generate the recommendation probability of each movie. The Critic network is used to optimize the recommendation strategy, which effectively improves the recommendation performance.
[0084] (iv) This invention is the first to simultaneously represent the positive and negative feedback given by users to the movies recommended by the platform during the recommendation process. It also incorporates attention mechanisms and contrast-assisted tasks into the state representation module. The user and movie embedding vectors are combined as the input to the state representation module. Finally, the potential relationship and feature representation between the user and the movies with positive and negative feedback are used as the input to the network for interactive recommendation, which greatly improves the prediction results of the movie recommendation platform. Attached Figure Description
[0085] The invention will be further described below with reference to the accompanying drawings.
[0086] Appendix Figure 1 This is a flowchart of a movie recommendation method based on deep reinforcement learning.
[0087] Appendix Figure 2 This is a block diagram of a movie recommendation system based on deep reinforcement learning. Detailed Implementation
[0088] The following detailed description of the movie recommendation method and system based on deep reinforcement learning of the present invention is provided with reference to the accompanying drawings and specific embodiments.
[0089] Example 1:
[0090] As attached Figure 1 As shown in the figure, this embodiment provides a movie recommendation method based on deep reinforcement learning, which is as follows:
[0091] S1. Preprocessing: Obtain user rating data and user attributes from the movie-related dataset. Preprocess the historical data of user ratings and user attributes to obtain the positive and negative feedback sequence embedding representation and user vector. Then, concatenate the output of the user's positive and negative feedback sequence after network processing with the user vector to form the user's interest state after giving evaluation feedback on any movie.
[0092] S2. Obtain the contrastive loss function: Increase the difference between the positive and negative feedback sequence representations by using the contrastive loss function to reduce the impact of data sparsity;
[0093] S3. Generate a movie recommendation list: The user's positive and negative feedback sequence, user vector, and user's interest state after giving feedback on any movie are processed by the Actor network to obtain action vectors, and then a movie recommendation list is generated.
[0094] S4. Optimize and update the movie recommendation list: After a user gives feedback on any movie, their interest state, user vector, and action vector are used by the Critic network to generate a state-action value function under a given state and action. This updates the parameters of the Actor network, thereby obtaining an optimized movie recommendation list.
[0095] The preprocessing in step S1 of this embodiment is as follows:
[0096] S101. Read the historical data of user movie ratings and user attributes from the Movielens-1m dataset, and perform data preprocessing to obtain the positive and negative feedback sequences and user vectors of users; among which, user attributes include user ID, gender, age and occupation;
[0097] Movielens-1m was selected as the dataset, which contains 6040 users, 3952 movies, and 1,000,209 user ratings for the movies. User attributes in the Movielens dataset include user ID, gender, age, and occupation, while movie attributes include title and movie category.
[0098] ① For the user's initial positive feedback sequence, the movies that the user has rated and that have a rating of 3 points or higher are sorted by the timestamp of the user's rating as the user's initial positive feedback sequence;
[0099] ② For the user's initial negative feedback sequence, randomly sample movies that the user has rated below 3 points and movies that the user has not rated. Sort the sampled movies according to the timestamp of the last time they were rated by other users as the user's initial negative feedback sequence.
[0100] ③ Obtain user vectors by preprocessing the user attributes in the movie recommendation platform;
[0101] S102. Capture the potential temporal relationship between the user vector and the positive and negative feedback sequences in the user's positive and negative feedback sequences through a GRU layer:
[0102] z n =σ(i n W z +U z h n-1 );
[0103] r n =σ(i n W r +U r h n-1 );
[0104]
[0105]
[0106] Among them, in 表 This is an example of a negative feedback sequence embedding representation formed by inputting movies with user ratings below 3 or no rating into the GRU layer; σ represents the sigmoid function; W z h represents the weight matrix associated with the update gate. n-1 This represents the hidden state at the previous time step; z n Indicates updating the gate's output; W r This represents the weight matrix associated with the reset gate; r n Indicates that the output of the reset gate is being reset; Represents the candidate hidden state at the current time step; W represents the weight matrix associated with the candidate hidden state; h n This indicates the hidden state at the current time step;
[0107] S103. The method for obtaining the embedded representation of the user's positive feedback sequence using the GRU layer is the same as the method for obtaining the embedded representation of the negative feedback sequence.
[0108] S104. Hide the current time step's hidden state h.n After being combined with user embedding and passed through a self-attention layer, the weight W is generated to indicate the user's liking for each movie in the positive and negative feedback sequence. i To highlight the most important parts and reduce the impact of noisy information;
[0109] S105. In order to reduce computation and noise interference, the weighted positive and negative feedback item features are further processed by the average pooling layer to obtain the optimized positive and negative feedback item features.
[0110] S106. Concatenate the optimized positive and negative feedback item features with the user vector to obtain the user's interest state s after giving a rating to any movie. + and s - .
[0111] The specific steps for obtaining the contrastive loss function in step S2 of this embodiment are as follows:
[0112] S201. During preprocessing, the dataset is used to obtain the movie attributes that users like; movie attributes include movie title and movie category.
[0113] S202. The feature distance between the user's favorite movie features and the user's positive feedback augmented sequence is reduced, while the feature distance between the user's favorite movie features and the user's negative feedback augmented sequence is increased to enhance the difference between positive and negative feedback. The auxiliary contrastive loss function used is as follows:
[0114]
[0115] in, Indicates the state s + Positive feedback augmented sequences obtained after data augmentation through masking operations; Indicates the state s - The negative feedback augmented sequence obtained after data augmentation by masking; d represents the cosine similarity between the positive feedback augmented sequence and the negative feedback augmented sequence.
[0116] The specific steps for generating the movie recommendation list in step S3 of this embodiment are as follows:
[0117] S301. Unlike existing Actor networks, the improved Actor network receives two consecutive current state vectors s after a user provides a movie rating. + and s - Furthermore, considering that recommended items with positive and negative feedback have different weights for policy improvement, failing to distinguish between them would prevent the agent from finely differentiating between the two, potentially leading to the use of a negative feedback recommendation policy after receiving positive feedback. Therefore, a dual-tower structure is used in the input part of the Actor network for state s. +and state s - The inputs are processed using MLPs with identical structures but different parameters to calculate their respective weights, and then processed by another MLP to obtain the final state s. The calculation method for the positive feedback weights is as follows:
[0118]
[0119] Where W1, W2, W3, and W4 represent weight matrices; b1, b2, b3, and b4 represent bias terms; and the negative feedback state s - The calculation method and positive feedback state s + same;
[0120] S302, The processed state s + and s - After being concatenated with the user vector, it is input into the Actor network. The Actor network outputs a continuous vector parameter action vector a = π. θ (s + ,u,s - );
[0121] S303, Redesign the loss function J for Actor network training iterations. π (φ), the formula is as follows:
[0122]
[0123] Wherein, the loss function J of the Actor network training iteration π (φ) is used to better adapt to the input of the positive and negative feedback dual sequences to update the network parameters; Indicates the expected value; Represents the experience pool; the f(·) function outputs the mean and variance; ∈ represents noise; L c Let represent the auxiliary contrast loss function for positive and negative feedback samples; λ represents a parameter used to control the weights of the auxiliary contrast loss function; α represents an auto-adjustment parameter, and the loss function for parameter α is... a represents a continuous parameter vector;
[0124] S304. Multiply the continuous parameter vector a with all movie embedding spaces to obtain the predicted ranking score of the user's liking for all movies in the entire movie space. Sort the movie space according to the ranking score of liking to form a movie recommendation list corresponding to the user's state.
[0125] The specific steps for optimizing and updating the movie recommendation list in step S4 of this embodiment are as follows:
[0126] In the SAC algorithm, the S401 Critic network is a neural network used to estimate the action-state value function. It outputs a metric that evaluates the performance of the current movie recommendation strategy, thus prompting optimization of the strategy. The Critic network uses a continuous state vector s. + s - Using the user vector u and the action value a obtained from the Actor network as input, we obtain the estimated value Q(s) of the state-action value function given the state and action. + ,u,s - , a);
[0127] S402, according to Q(s) + ,u,s - a) Value: The parameters of the Actor network are gradually optimized to increase the probability of recommending movies that users like more.
[0128] The S403 Critic network consists of two Q-networks with identical structures but different parameters. During each training step, the minimum Q-value between the two Q-networks is calculated as the estimate of the state-action value function, Q(s). + ,u,s - a) The formula is as follows:
[0129]
[0130]
[0131] Q(s + ,u,s - , a)=min(Q1(s + ,u,s - ,a),Q2(s + ,u,s - ,a))
[0132] Among them, s ’+ s represents the positive feedback sequence in the next state representation; ’- This represents the negative feedback sequence in the next state representation; π(a'|s ’+ ,u,s ’- ) indicates that in state (s) ’+ ,u,s ’- The probability of taking action a' under condition ).
[0133] Another Q-network is used to validate and stabilize the estimation results of the first Q-network. The reason for using a double Q-network is to mitigate the overestimation problem.
[0134] S404. To accommodate both positive and negative feedback inputs and to better align with the improved Actor network parameters, the loss function J for the training iterations of the Critic network was redesigned. Q (θ), the formula is as follows:
[0135]
[0136] Where θ represents the parameters of the Q-network; V represents the state-value function, which is the expected cumulative reward for the recommended movie under the current movie recommendation strategy and value network estimation in state s'. Similar to DDPG, the Critic network also constructs a target soft Q-network parameter. parameter It is obtained through the parameters θ of the Q-network.
[0137] Example 2:
[0138] As attached Figure 2 As shown, this embodiment provides a movie recommendation system based on deep reinforcement learning, which includes:
[0139] The preprocessing module is used to obtain user rating data and user attributes in the movie-related dataset. It preprocesses the historical data of user ratings and user attributes to obtain the user's positive and negative feedback sequence embedding representation and user vector. Then, it concatenates the output of the user's positive and negative feedback sequence after network processing with the user vector to form the user's interest state after giving evaluation feedback on any movie.
[0140] The acquisition module is used to increase the difference between positive and negative feedback sequence representations by comparing loss functions, thereby reducing the impact of data sparsity.
[0141] The generation module is used to process the user's positive and negative feedback sequences, user vectors, and user interest states after giving feedback on any movie through the Actor network to obtain action vectors, and then generate a movie recommendation list.
[0142] The optimization and update module is used to generate a state-action value function for a given state and action based on the user's interest state, user vector, and action vector after the user provides feedback on any movie. This function updates the parameters of the Actor network and thus obtains an optimized movie recommendation list.
[0143] The preprocessing module in this embodiment includes:
[0144] The acquisition submodule is used to read historical data of user movie ratings and user attributes from the Movielens-1m dataset, and perform data preprocessing to obtain the user's positive and negative feedback sequences and user vectors. The user attributes include user ID, gender, age, and occupation; details are as follows:
[0145] ① For the user's initial positive feedback sequence, the movies that the user has rated and that have a rating of 3 points or higher are sorted by the timestamp of the user's rating as the user's initial positive feedback sequence;
[0146] ② For the user's initial negative feedback sequence, randomly sample movies that the user has rated below 3 points and movies that the user has not rated. Sort the sampled movies according to the timestamp of the last time they were rated by other users as the user's initial negative feedback sequence.
[0147] ③ Obtain user vectors by preprocessing the user attributes in the movie recommendation platform;
[0148] The GRU layer is used to capture the sequence relationship of the user on the movie time series using the user vector and the positive and negative feedback sequences:
[0149] z n =σ(i n W z +U z h n-1 );
[0150] r n =σ(i n W r +U r h n-1 );
[0151]
[0152]
[0153] Among them, i n This represents the negative feedback sequence embedding representation formed by inputting movies with user ratings below 3 or no rating into the GRU layer; σ represents the sigmoid function; W z h represents the weight matrix associated with the update gate. n-1 This represents the hidden state at the previous time step; z n Indicates updating the gate's output; W r This represents the weight matrix associated with the reset gate; r n Indicates that the output of the reset gate is being reset; Represents the candidate hidden state at the current time step; W represents the weight matrix associated with the candidate hidden state; h n This indicates the hidden state at the current time step;
[0154] The method for obtaining the embedding representation of the user's positive feedback sequence using the GRU layer is the same as the method for obtaining the embedding representation of the negative feedback sequence.
[0155] A self-attention layer is used to store the hidden state h at the current time step. n Combined with user embedding, it generates the user's liking for each movie in the positive and negative feedback sequence, i.e., the weight W. i To highlight the most important parts and reduce the impact of noisy information;
[0156] Average pooling layer is used to obtain positive and negative feedback item features using weighted features;
[0157] The concatenation submodule is used to concatenate the positive and negative feedback item features with the user vector to obtain the user's interest state s after giving a rating to any movie. + and s - .
[0158] The acquisition module in this embodiment includes:
[0159] The data augmentation submodule is used to obtain augmented sequences for both positive and negative feedback sequences using data augmentation.
[0160] The contrast loss value acquisition submodule is used to obtain the corresponding cosine similarity from the augmented sequences of the positive and negative feedback sequences to calculate the contrast loss value, which is then used to optimize the parameters together with the loss function of the Actor network.
[0161] In this embodiment, the generation module uses an Actor network to receive state s when user behavior changes. + and s - The user vector u is taken as input, and a value in state s = (s + ,u,s - The probability value of each movie is recommended, and the recommended movie list is obtained after sorting the movies according to the probability value.
[0162] In this embodiment, the optimization and update module uses the Critic network to receive the output action vector a and state s of the Actor network. + s - Using the user vector u as input, we obtain the estimated value Q(s) of the state-action value function given the state and action. + ,u,s - , a), through Q(s + ,u,s - a) Predict the cumulative reward obtained by recommending movies under the corresponding state.
[0163] Example 3:
[0164] This embodiment also provides an electronic device, including: a memory and a processor;
[0165] The memory stores the instructions executed by the computer.
[0166] The processor executes computer execution instructions stored in the memory, causing the processor to perform the movie recommendation method based on deep reinforcement learning in any embodiment of the present invention.
[0167] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can be a microprocessor or any conventional processor.
[0168] Memory is used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, memory can also include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart memory cards (SMC), secure digital cards (SD cards), flash memory cards, at least one disk storage device, flash memory devices, or other volatile solid-state storage devices.
[0169] Example 4:
[0170] This embodiment also provides a computer-readable storage medium storing multiple instructions, which are loaded by a processor to cause the processor to execute the deep reinforcement learning-based movie recommendation method of any embodiment of the present invention. Specifically, a system or apparatus equipped with a storage medium may be provided, on which software program code implementing the functions of any of the above embodiments is stored, and the computer (or CPU or MPU) of the system or apparatus may read and execute the program code stored in the storage medium.
[0171] In this case, the program code read from the storage medium can itself implement the function of any of the above embodiments, and therefore the program code and the storage medium storing the program code constitute part of the present invention.
[0172] Storage media embodiments for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer via a communication network.
[0173] Furthermore, it should be clear that not only can the program code read by the computer be executed, but also the operating system or other components operating on the computer can be instructed based on the program code to perform some or all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0174] Furthermore, it is understood that the program code read from the storage medium is written to the memory set in the expansion board inserted into the computer or to the memory set in the expansion unit connected to the computer. Then, based on the instructions of the program code, the CPU or other components installed on the expansion board or expansion unit execute some and all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A movie recommendation method based on deep reinforcement learning, characterized in that, The method is as follows: Preprocessing: Obtain user rating data and user attributes from the movie-related dataset. Preprocess the historical data of user ratings and user attributes to obtain the positive and negative feedback sequence embedding representation and user vector. Then, concatenate the output of the user's positive and negative feedback sequence after network processing with the user vector to form the user's interest state after giving evaluation feedback on any movie. Obtain the contrastive loss function: Increase the difference between the positive and negative feedback sequence representations by using the contrastive loss function; Generating a movie recommendation list: The user's positive and negative feedback sequence, user vector, and user's interest state after giving feedback on any movie are processed by the Actor network to obtain action vectors, and then a movie recommendation list is generated. Optimize and update the movie recommendation list: After a user provides feedback on any movie, their interest state, user vector, and action vector are used by the Critic network to generate a state-action value function under a given state and action. This function updates the parameters of the Actor network, thereby obtaining an optimized movie recommendation list.
2. The movie recommendation method based on deep reinforcement learning according to claim 1, characterized in that, The preprocessing is as follows: Read historical data of user movie ratings and user attributes from the Movielens-1m dataset, and perform data preprocessing to obtain user positive and negative feedback sequences and user vectors; among them, user attributes include user ID, gender, age and occupation; For the user's initial positive feedback sequence, the movies that the user has rated and that have a rating of 3 points or higher are sorted by the timestamp of the user's rating and used as the user's initial positive feedback sequence. For the user's initial negative feedback sequence, random sampling is performed on movies with user ratings below 3 points and movies that the user has not rated. The sampled movies are sorted according to the timestamp of the last time they were rated by other users as the user's initial negative feedback sequence. User vectors are obtained by preprocessing user attributes from movie recommendation platforms; The user vector and positive and negative feedback sequences are passed through a GRU layer to capture the potential temporal relationship between the movies in the user's positive and negative feedback sequences: With n =σ(i n IN z +u z h n-1 ); r n =σ(i n W r +U r h n-1 ); Among them, i n This represents the negative feedback sequence embedding representation formed by inputting movies with user ratings below 3 or no rating into the GRU layer; σ represents the sigmoid function; W z h represents the weight matrix associated with the update gate. n-1 This represents the hidden state at the previous time step; z n Indicates updating the gate's output; W r This represents the weight matrix associated with the reset gate; r n Indicates that the output of the reset gate is being reset; Represents the candidate hidden state at the current time step; W represents the weight matrix associated with the candidate hidden state; h n This indicates the hidden state at the current time step; The method for obtaining the embedding representation of the user's positive feedback sequence using the GRU layer is the same as the method for obtaining the embedding representation of the negative feedback sequence. Set the hidden state h at the current time step n After being combined with user embedding and passed through a self-attention layer, the weight W is generated to indicate the user's liking for each movie in the positive and negative feedback sequence. i ; The weighted positive and negative feedback item features are further processed by an average pooling layer to obtain optimized positive and negative feedback item features. The optimized positive and negative feedback project features are concatenated with the user vector to obtain the user's interest state s after giving a rating to any movie. + and s - .
3. The movie recommendation method based on deep reinforcement learning according to claim 1 or 2, characterized in that, The specific steps for obtaining the contrastive loss function are as follows: During preprocessing, the dataset is used to obtain the movie attributes that users like; movie attributes include movie title and movie category. The auxiliary contrastive loss function used to increase the difference between positive and negative feedback is as follows: (This is achieved by narrowing the feature distance between the user's favorite movie features and the user's positive feedback augmented sequence, and widening the feature distance between the user's favorite movie features and the user's negative feedback augmented sequence.) in, Indicates the state s + Positive feedback augmented sequences obtained after data augmentation through masking operations; Indicates the state s - The negative feedback augmented sequence obtained after data augmentation by masking; d represents the cosine similarity between the positive feedback augmented sequence and the negative feedback augmented sequence.
4. The movie recommendation method based on deep reinforcement learning according to claim 3, characterized in that, The movie recommendation list is generated as follows: A dual-tower structure is used in the input part of the Actor network for state s. + and state s - The inputs are processed using MLPs with identical structures but different parameters to calculate their respective weights, and then processed by another MLP to obtain the final state s. The calculation method for the positive feedback weights is as follows: Where W1, W2, W3, and W4 represent weight matrices; b1, b2, b3, and b4 represent bias terms; and the negative feedback state s - The calculation method and positive feedback state s + same; The processed state s + and s - After being concatenated with the user vector, it is input into the Actor network. The Actor network outputs a continuous vector parameter action vector a = π. θ (s + ,u,s - ); Redesign the loss function J for Actor network training iterations π (φ), the formula is as follows: Wherein, the loss function J of the Actor network training iteration π (φ) is used to better adapt to the input of the positive and negative feedback dual sequences to update the network parameters; Indicates the expected value; Represents the experience pool; the f(·) function outputs the mean and variance; ∈ represents noise; L c Let represent the auxiliary contrast loss function for positive and negative feedback samples; λ represents a parameter used to control the weights of the auxiliary contrast loss function; α represents an auto-adjustment parameter, and the loss function for parameter α is... a represents a continuous parameter vector; The continuous parameter vector 'a' is multiplied by all movie embedding spaces to obtain the predicted ranking score of the user's liking for all movies in the entire movie space. The movie space is then sorted according to the ranking score of liking to form a movie recommendation list corresponding to the user's state.
5. The movie recommendation method based on deep reinforcement learning according to claim 4, characterized in that, The movie recommendation list has been optimized and updated as follows: The Critic network uses continuous state vectors s + s - Using the user vector u and the action value a obtained from the Actor network as input, we obtain the estimated value Q(s) of the state-action value function given the state and action. + ,u,s - , a); According to Q(s) + ,u,s - a) Value: The parameters of the Actor network are gradually optimized to increase the probability of recommending movies that users like more. The Critic network consists of two Q-networks with identical structures but different parameters. During each training step, the minimum Q-value between the two Q-networks is calculated as the estimate of the state-action value function, Q = (s...). + ,u,s - a) The formula is as follows: Q(s + ,u,s - ,a)=min(Q1(s + ,u,s - ,a),Q2(s + ,u,s - ,a)) Among them, s' + s' represents the positive feedback sequence in the next state representation; - This represents the negative feedback sequence in the next state representation; π(a'|s') + ,u,s' - ) indicates that in state (s' + ,u,s' - The probability of taking action a' under condition ). Another Q-network is used to validate and stabilize the estimation results of the previous Q-network; Redesign the loss function J for the training iterations of the Critic network Q (θ), the formula is as follows: Where θ represents the parameters of the Q-network; V represents the state-value function, which is the expected cumulative reward for the recommended movie in state s', based on the current movie recommendation strategy and value network estimation. The Critic network also constructs a target soft Q-network parameter. parameter It is obtained through the parameters θ of the Q-network.
6. A movie recommendation system based on deep reinforcement learning, characterized in that, The system includes: The preprocessing module is used to obtain user rating data and user attributes in the movie-related dataset. It preprocesses the historical data of user ratings and user attributes to obtain the user's positive and negative feedback sequence embedding representation and user vector. Then, it concatenates the output of the user's positive and negative feedback sequence after network processing with the user vector to form the user's interest state after giving evaluation feedback on any movie. The acquisition module is used to increase the difference between positive and negative feedback sequence representations by comparing loss functions, thereby reducing the impact of data sparsity. The generation module is used to process the user's positive and negative feedback sequences, user vectors, and user interest states after giving feedback on any movie through the Actor network to obtain action vectors, and then generate a movie recommendation list. The optimization and update module is used to generate a state-action value function for a given state and action based on the user's interest state, user vector, and action vector after the user provides feedback on any movie. This function updates the parameters of the Actor network and thus obtains an optimized movie recommendation list.
7. The movie recommendation system based on deep reinforcement learning according to claim 6, characterized in that, The preprocessing module includes: The acquisition submodule is used to read historical data of user movie ratings and user attributes from the Movielens-1m dataset, and perform data preprocessing to obtain the user's positive and negative feedback sequences and user vectors. The user attributes include user ID, gender, age, and occupation; details are as follows: ① For the user's initial positive feedback sequence, the movies that the user has rated and that have a rating of 3 points or higher are sorted by the timestamp of the user's rating as the user's initial positive feedback sequence; ② For the user's initial negative feedback sequence, randomly sample movies that the user has rated below 3 points and movies that the user has not rated. Sort the sampled movies according to the timestamp of the last time they were rated by other users as the user's initial negative feedback sequence. ③ Obtain user vectors by preprocessing the user attributes in the movie recommendation platform; The GRU layer is used to capture the sequential relationship between the user and the positive and negative feedback sequences on the movie time series using the user vector and the positive and negative feedback sequences: With n =σ(i n IN z +U z h n-1 ); r n =σ(i n W r +U r h n-1 ); Among them, i n This represents the negative feedback sequence embedding representation formed by inputting movies with user ratings below 3 or no rating into the GRU layer; σ represents the sigmoid function; W z h represents the weight matrix associated with the update gate. n-1 This represents the hidden state at the previous time step; z n Indicates updating the gate's output; W r This represents the weight matrix associated with the reset gate; r n Indicates that the output of the reset gate is being reset; Represents the candidate hidden state at the current time step; W represents the weight matrix associated with the candidate hidden state; h n This indicates the hidden state at the current time step; The method for obtaining the embedding representation of the user's positive feedback sequence using the GRU layer is the same as the method for obtaining the embedding representation of the negative feedback sequence. A self-attention layer is used to store the hidden state h at the current time step. n Combined with user embedding, it generates the user's liking for each movie in the positive and negative feedback sequence, i.e., the weight W. i ; Average pooling layer is used to obtain positive and negative feedback item features using weighted features; The concatenation submodule is used to concatenate the positive and negative feedback item features with the user vector to obtain the user's interest state s after giving a rating to any movie. + and s - ; The acquisition module includes: The data augmentation submodule is used to obtain augmented sequences for both positive and negative feedback sequences using data augmentation. The contrast loss value acquisition submodule is used to obtain the corresponding cosine similarity from the augmented sequences of the positive and negative feedback sequences to calculate the contrast loss value, which is then used to optimize the parameters together with the loss function of the Actor network.
8. The movie recommendation system based on deep reinforcement learning according to claim 6 or 7, characterized in that, The generation module uses an Actor network to receive state s when user behavior changes. + and s - The user vector u is taken as input, and a value in state s = (s + ,u,s - The probability value of each movie is recommended, and the recommended movie list is obtained after sorting the movies according to the probability value. The optimization and update module uses the Critic network to receive the output action vector 'a' and state 's' from the Actor network. + s - Using the user vector u as input, we obtain the estimated value Q(s) of the state-action value function given the state and action. + ,u,s - , a), through Q(s + ,u,s - a) Predict the cumulative reward obtained by recommending movies under the corresponding state.
9. An electronic device, characterized in that, include: Memory and at least one processor; The memory contains computer programs; The at least one processor executes the computer program stored in the memory, causing the at least one processor to perform the movie recommendation method based on deep reinforcement learning as described in any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed by a processor to implement the movie recommendation method based on deep reinforcement learning as described in any one of claims 1 to 5.
Citation Information
Patent Citations
User preference recommendation method and device based on neural network set operation
CN114637922A
Sequence recommendation method for enhancing long-term income based on reinforcement learning
CN116244522A
