A method, system and device for personalized recommendation based on deep neural network
Patent Information
- Application Number
- CN202411009154.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-26
Smart Images

Figure CN118535805B
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud shared data processing, and in particular to a method, system and device for personalized recommendation based on deep neural network. Background Art
[0002] With the development of Internet technology and the popularity of mobile devices, video platforms and short video platforms have become important channels for people to obtain information and entertainment. These platforms recommend personalized video content to users by building user portraits to improve user experience and platform participation. However, existing video recommendation systems have some limitations.
[0003] In the existing technology, user portraits mainly rely on users' historical browsing data and interactive behaviors to construct user portraits, but this method may not be able to fully capture users' changing interests and real-time needs. In addition, the method of pushing content to users through user portraits tends to recommend content that users already know or are familiar with, which causes users to fall into information cocoons and limits the diversity and innovation of content. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a method, system and device for personalized recommendation based on deep neural network, which is used to improve the push accuracy for video software users.
[0005] The first aspect of the present application provides a method for personalized recommendation based on a deep neural network, comprising:
[0006] Obtain user behavior data and video tag data;
[0007] Preprocessing the user behavior data to obtain historical viewing behavior, where the historical viewing behavior includes a video ID and viewing duration;
[0008] The video tag data is converted into a video tag value using One-Hot encoding, wherein the video tag value is numerical data;
[0009] The video tag value is converted into a high-dimensional vector space of a tag word embedding vector embedding learning model through an embedding layer, so that the video tag can be used as a feature of neural network learning;
[0010] Serializing the historical viewing behavior to obtain a viewing sequence;
[0011] Convert the video ID into a video embedding vector through the embedding layer;
[0012] Integrating the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence;
[0013] Initialize the LSTM network, input the elements in the video embedding vector sequence into the LSTM network one by one, calculate each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function, and obtain the target hidden state;
[0014] The user behavior data of the target user is obtained, and the target hidden state of the user behavior data of the target user is calculated according to the activation function in combination with the historical viewing behavior and the video tag data, so as to obtain the recommendation result of the target user.
[0015] Optionally, the initializing the LSTM network, inputting the elements in the video embedding vector sequence one by one into the LSTM network, calculating each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function, and obtaining the target hidden state includes:
[0016] Initialize the initial hidden state and initial cell state of the LSTM network;
[0017] Setting the time steps corresponding to the elements of the video embedding vector sequence to generate a time step sequence;
[0018] According to the preset parameters of the LSTM network, the initial hidden state and the initial cell state are used as initial data;
[0019] All elements in the video embedding vector sequence are calculated one by one according to the LSTM network standard process and the time step sequence to obtain the target hidden state.
[0020] Optionally, the step of calculating all elements in the video embedding vector sequence one by one according to the LSTM network standard process and the time step sequence to obtain the target hidden state includes:
[0021] Obtaining an input gate activation value, wherein the input gate activation value is a hidden state of a time step before a current time step, and an initial value of the input gate activation value is calculated by using the initial hidden state and the initial cell state;
[0022] Calculate forget gate activation values, output gate activation values and candidate cell states of all elements in the video embedding vector sequence one by one according to the time step sequence and the input gate activation value;
[0023] Calculate and update the cell state according to the forget gate activation value and the candidate cell state;
[0024] The cell state corresponding to the element in the current video embedding vector sequence is updated according to the updated cell state to obtain the current cell state;
[0025] The hidden state of the element of the video embedding vector sequence corresponding to the current time step is calculated using the current cell state, and the hidden state is calculated by the following formula:
[0026] ;
[0027] in, is the output gate activation value, the cell state of the element of the video embedding vector sequence corresponding to the current time step;
[0028] When the hidden states of all elements in the video embedding vector sequence are calculated, the hidden state of the last time step is the target hidden state.
[0029] Optionally, the method further includes:
[0030] Get the time step weight coefficient , the video label value of the element in the video embedding vector sequence at the corresponding time step , corresponding to the hidden state of the video embedding vector sequence element mapping of the time step sequence element ;
[0031] The time-weighted cross entropy loss function is calculated by the following formula to obtain the total loss of the historical viewing behavior training result:
[0032] ;
[0033] The video label value of the element in the video embedding vector sequence at the corresponding time step is , a constant of 0 or 1 indicating the selected state of the label, The hidden state of the video embedding vector sequence element mapped to the corresponding time step sequence element, wherein the hidden state is used to represent the preference state of the label corresponding to the video label value.
[0034] Optionally, after calculating the time-weighted cross entropy loss function by the following formula to obtain the total loss of the historical viewing behavior training result, the method further includes:
[0035] After the LSTM network generates the target hidden state, the loss function is calculated using the current state of the LSTM network, where the current state of the LSTM network is a training model;
[0036] Back-propagating the training model according to the chain rule and the total loss to obtain a partial derivative of the total loss with respect to the training model;
[0037] The parameters of the training model are gradient updated according to the partial derivatives to obtain a target training model.
[0038] Optionally, acquiring the user behavior data of the target user, combining the historical viewing behavior and the video tag data, calculating the target hidden state of the user behavior data of the target user according to an activation function, and obtaining the recommendation result for the target user includes:
[0039] Inputting the user behavior data of the target user into the embedding layer to obtain the historical viewing behavior sequence of the target user;
[0040] Inputting the historical viewing behavior sequence of the target user into the target training model to obtain the target hidden state of the target user;
[0041] Obtain candidate video data, and calculate the target probability that the videos in the candidate video data are liked by the target user one by one according to the following formula:
[0042] ;
[0043] in, is the predicted preference probability of the user in the next time step, σ is the Sigmoid function, and are the weight parameters of the model, is the hidden state at time step t, is the video embedding vector of the user at time step t+1, and b is the partial derivative.
[0044] Optionally, the video tag data is converted into a video tag value using One-Hot encoding, and the video tag value is numerical data including:
[0045] Parsing the video tag data to obtain a video tag class set;
[0046] Create a label column for each element included in the video label class set;
[0047] Acquire video data, and parse out video tags contained in the video data;
[0048] The video data is labeled with the label column according to the video label to obtain a video label value.
[0049] The second aspect of the present application provides a system for personalized recommendation based on a deep neural network, comprising:
[0050] A first acquisition unit, used to acquire user behavior data and video tag data;
[0051] A preprocessing unit, configured to preprocess the user behavior data to obtain historical viewing behavior, wherein the historical viewing behavior includes a video ID and viewing duration;
[0052] A conversion unit, used to convert the video tag data into a video tag value using One-Hot encoding, wherein the video tag value is numerical data;
[0053] A first embedding unit, configured to convert the video tag value into a high-dimensional vector space of a tag word embedding vector embedding learning model through an embedding layer, so that the video tag can be used as a feature of neural network learning;
[0054] A serialization unit, used for serializing the historical viewing behavior to obtain a viewing sequence;
[0055] A second embedding unit, configured to convert the video ID into a video embedding vector through an embedding layer;
[0056] an integration unit, configured to integrate the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence;
[0057] A model training unit is used to initialize the LSTM network, and input the elements in the video embedding vector sequence into the LSTM network one by one, and calculate each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function to obtain a target hidden state;
[0058] A calculation unit is used to obtain user behavior data of a target user, combine the historical viewing behavior and video tag data, calculate the target hidden state of the user behavior data of the target user according to an activation function, and obtain a recommendation result for the target user.
[0059] Optionally, the model training unit is further used for:
[0060] Initialize the initial hidden state and initial cell state of the LSTM network;
[0061] Setting the time steps corresponding to the elements of the video embedding vector sequence to generate a time step sequence;
[0062] According to the preset parameters of the LSTM network, the initial hidden state and the initial cell state are used as initial data;
[0063] All elements in the video embedding vector sequence are calculated one by one according to the LSTM network standard process and the time step sequence to obtain the target hidden state.
[0064] Optionally, the model training unit is further used for:
[0065] Obtaining an input gate activation value, wherein the input gate activation value is a hidden state of a time step before a current time step, and an initial value of the input gate activation value is calculated by using the initial hidden state and the initial cell state;
[0066] Calculate forget gate activation values, output gate activation values and candidate cell states of all elements in the video embedding vector sequence one by one according to the time step sequence and the input gate activation value;
[0067] Calculate and update the cell state according to the forget gate activation value and the candidate cell state;
[0068] The cell state corresponding to the element in the current video embedding vector sequence is updated according to the updated cell state to obtain the current cell state;
[0069] The hidden state of the element of the video embedding vector sequence corresponding to the current time step is calculated using the current cell state, and the hidden state is calculated by the following formula:
[0070] ;
[0071] in, is the output gate activation value, the cell state of the element of the video embedding vector sequence corresponding to the current time step;
[0072] When the hidden states of all elements in the video embedding vector sequence are calculated, the hidden state of the last time step is the target hidden state.
[0073] Optionally, the model training unit is further used for:
[0074] Get the time step weight coefficient , the video label value of the element in the video embedding vector sequence at the corresponding time step , corresponding to the hidden state of the video embedding vector sequence element mapping of the time step sequence element ;
[0075] The time-weighted cross entropy loss function is calculated by the following formula to obtain the total loss of the historical viewing behavior training result:
[0076] ;
[0077] The video label value of the element in the video embedding vector sequence at the corresponding time step is , a constant of 0 or 1 indicating the selected state of the label, The hidden state of the video embedding vector sequence element mapped to the corresponding time step sequence element, wherein the hidden state is used to represent the preference state of the label corresponding to the video label value.
[0078] Optionally, the model training unit is further used for:
[0079] After the LSTM network generates the target hidden state, the loss function is calculated using the current state of the LSTM network, where the current state of the LSTM network is a training model;
[0080] Back-propagating the training model according to the chain rule and the total loss to obtain a partial derivative of the total loss with respect to the training model;
[0081] The parameters of the training model are gradient updated according to the partial derivatives to obtain a target training model.
[0082] Optionally, the computing unit is further used for:
[0083] Inputting the user behavior data of the target user into the embedding layer to obtain the historical viewing behavior sequence of the target user;
[0084] Inputting the historical viewing behavior sequence of the target user into the target training model to obtain the target hidden state of the target user;
[0085] Obtain candidate video data, and calculate the target probability that the videos in the candidate video data are liked by the target user one by one according to the following formula:
[0086] ;
[0087] in, is the predicted preference probability of the user in the next time step, σ is the Sigmoid function, and are the weight parameters of the model, is the hidden state at time step t, is the video embedding vector of the user at time step t+1, and b is the partial derivative.
[0088] Optionally, the conversion unit is further used for:
[0089] Parsing the video tag data to obtain a video tag class set;
[0090] Create a label column for each element included in the video label class set;
[0091] Acquire video data, and parse out video tags contained in the video data;
[0092] The video data is labeled with the label column according to the video label to obtain a video label value.
[0093] The third aspect of the present application provides a device for personalized recommendation based on a deep neural network, the device comprising:
[0094] Processor, memory, input-output unit, and bus;
[0095] The processor is connected to the memory, the input and output unit, and the bus;
[0096] The memory stores a program, and the processor calls the program to execute the first aspect and any optional method in the first aspect.
[0097] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional method in the first aspect.
[0098] It can be seen from the above technical solutions that this application has the following advantages:
[0099] This application predicts the user's current preferences in a hidden state by inputting the user behavior data of the video software into the LSTM network. The hidden state indicates that after training the user behavior data, the purpose of the user's next behavior is predicted to ensure that the next video information obtained by the user is closer to the user's current preferences, thereby achieving the purpose of accurate push. BRIEF DESCRIPTION OF THE DRAWINGS
[0100] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0101] Figure 1 A schematic diagram of an embodiment of the method for personalized recommendation based on deep neural network in this application;
[0102] Figure 2 This is a flow chart of an embodiment of the LSTM network model training method in the method for personalized recommendation based on deep neural network in this application;
[0103] Figure 3 This is a flowchart of an embodiment of the LSTM network model training calculation process in the method for personalized recommendation based on deep neural network in this application;
[0104] Figure 4 A flowchart of an embodiment of a method for compensating a training model in an LSTM network model training method in a method for personalized recommendation based on a deep neural network in this application;
[0105] Figure 5 This is a flowchart of another embodiment of the method for personalized recommendation based on deep neural network in this application;
[0106] Figure 6 This is a schematic diagram of the structure of an embodiment of a system for personalized recommendation based on a deep neural network in this application;
[0107] Figure 7 This is a schematic diagram of the structure of an embodiment of a device for personalized recommendation based on a deep neural network in the present application. DETAILED DESCRIPTION
[0108] Based on this, the present application provides a method, system and device for personalized recommendation based on deep neural network, which is used to improve the push accuracy for video software users.
[0109] It should be noted that the method for personalized recommendation based on deep neural network provided in this application can be applied to terminals, systems, and servers. For example, the terminal can be a smart phone or computer, tablet computer, smart TV, smart watch, portable computer terminal, or a fixed terminal such as a desktop computer. For the convenience of explanation, this application uses the terminal as the execution subject for example.
[0110] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0111] See also Figure 1 , Figure 1 A flowchart of an embodiment of a method for personalized recommendation based on a deep neural network provided in this application, the method comprising:
[0112] S101, obtaining user behavior data and video tag data;
[0113] User behavior data is a data file generated based on the user's usage traces when the user uses the video software. The user behavior data at least includes the user ID information, the video ID of the video the user watches, and the user's viewing time for the video corresponding to the video ID.
[0114] The video tag data carries the video data of all videos that the video software can obtain through the server and the video tags carried by these videos. The role of video tags is to classify and summarize the video content. In actual situations, video tags include but are not limited to: food, beauty, cute pets, etc., which can point to the specific content range of the video. Each video can carry multiple tags.
[0115] S102, pre-processing the user behavior data to obtain historical viewing behavior, where the historical viewing behavior includes a video ID and viewing duration;
[0116] The purpose of preprocessing is to extract valid information from user behavior data. After preprocessing, user behavior data generates user historical viewing behaviors that can be used for model training. Specifically, the user behavior data obtained in step S101 is obtained for all user data that generate user behaviors in the video software. Therefore, the historical viewing behaviors obtained after preprocessing are also extracted from the valid data containing the user behavior of the user in the user behavior data one by one, and the historical viewing behaviors of all users are obtained with the user ID as the element label. Therefore, the historical viewing behaviors can be used as training samples for model training.
[0117] Specifically, the process of converting user behavior data into historical viewing behavior is a data cleaning process. In addition to screening out valid data, it is also used to remove data with abnormal values or incomplete records. These data are collectively referred to as invalid data. The storage method of historical viewing behavior can use CSV or database tables, which are not limited here.
[0118] S103, using One-Hot encoding to convert the video tag data into a video tag value, wherein the video tag value is numerical data;
[0119] One-Hot encoding is a solution for quantifying data such as video labels that cannot be directly used for model training. The conversion process is to use the video label as a parameter and determine whether the video carries the label corresponding to the parameter by assigning a value of 0 or 1 to the parameter.
[0120] Specifically, the terminal creates a column for each unique label. If the video has a specific label, it is marked as 1 in the corresponding column, and 0 otherwise.
[0121] S104, converting the video tag value into a tag word embedding vector into a high-dimensional vector space of a learning model through an embedding layer, so that the video tag can be used as a feature of neural network learning;
[0122] Specifically, the label vector obtained by One-Hot encoding is converted into a dense embedding vector to capture the potential relationship between labels, where the dense embedding vector is the label word embedding vector.
[0123] The terminal inputs the label word embedding vector as a learning sample into the embedding layer in the neural network, and converts the One-Hot encoded label through the embedding layer, so that the neural network learns the low-dimensional representation of the label, so that when the neural network is used for model training, these labels can be used as parameters to quantify the historical viewing behavior.
[0124] S105, serializing the historical viewing behavior to obtain a viewing sequence;
[0125] The function of the viewing sequence is to generate a corresponding time sequence for the user's historical viewing behavior. Specifically, in the actual serialization process, the order of sorting is the actual time of video playback, and one user ID corresponds to one viewing sequence.
[0126] S106, converting the video ID into a video embedding vector through an embedding layer;
[0127] Specifically, this step is to convert the video ID into a parameter that can be used by the neural network through the characteristics of the embedding layer of the neural network system. The video ID is a label for the video watched by the user. In the actual training process, the learning process for a data element is to input a user's historical viewing behavior data into the model learned by the video label value. The historical viewing behavior data includes the video ID and the viewing time. There is more than one video ID corresponding to the user, which makes it impossible to directly use the data in the model training. Therefore, the video ID needs to be converted into a video embedding vector through the embedding layer before input.
[0128] S107, integrating the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence;
[0129] The video embedding vector sequence represents the tendency vector based on the video ticket of the video ID sorted according to the time series in the user's historical viewing record, which is used to represent the changing trend of a user's video preference over a period of time.
[0130] S108, initializing the LSTM network, and inputting the elements in the video embedding vector sequence into the LSTM network one by one, calculating each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function, to obtain the target hidden state;
[0131] After completing the adaptive processing of the training model for the user-related dataset and the video labels in the video application through the above steps, the video embedding vector sequence is input into the LSTM network that has been subjected to label word embedding vector learning.
[0132] Specifically, after inputting the label word embedding vector, the LSTM network will learn all the features of the video contained in the video software and the association between the features based on the label word embedding vector, so that after inputting the video embedding vector sequence into the LSTM network trained with video labels, the LSTM network will learn based on each video embedding vector element contained in the video vector sequence, and the learning result of each element is a hidden state. When the LSTM network completes learning the hidden states of all elements in the video embedding vector sequence, the last output hidden state result is the target hidden state.
[0133] Specifically, the calculation method of the time-weighted cross entropy loss function is:
[0134] Get the time step weight coefficient , the video label value of the element in the video embedding vector sequence at the corresponding time step , corresponding to the hidden state of the video embedding vector sequence element mapping of the time step sequence element ;
[0135] The time-weighted cross entropy loss function is calculated by the following formula to obtain the total loss of the historical viewing behavior training result:
[0136] ;
[0137] The video label value of the element in the video embedding vector sequence at the corresponding time step is , a constant of 0 or 1 indicating the selected state of the label, The hidden state of the video embedding vector sequence element mapped to the corresponding time step sequence element, wherein the hidden state is used to represent the preference state of the label corresponding to the video label value.
[0138] S109: Obtain user behavior data of a target user, combine the historical viewing behavior and video tag data, calculate the target hidden state of the user behavior data of the target user according to an activation function, and obtain a recommendation result for the target user.
[0139] Acquiring the target hidden state indicates that the LSTM network has completed learning the historical viewing behavior of the current input, and based on the historical viewing behavior defined as sample data, has obtained a state that can be used to determine the next pushed video based on the current viewing video for the target user who is currently operating the video software, so that after the target user finishes watching the current video, the next video is played directly, and the next video to be played is the recommendation result for the target user.
[0140] This application obtains the hidden state of user preferences by inputting the user behavior data of the target user into the trained LSTM network model through the LSTM model training, so that the terminal can push the user's preferences according to the hidden state.
[0141] According to step S108, this application needs to train the LSTM network model to accurately obtain the user's target hidden state. Figure 2 , Figure 2 A flow chart of an embodiment of a LSTM network model training method in a method for personalized recommendation based on a deep neural network provided in the present application, the method comprising:
[0142] S201, initialize the initial hidden state and initial cell state of the LSTM network;
[0143] Specifically, the terminal sets the starting point for the LSTM network to ensure that the network can process sequence data from a unified state. Before processing the received data, the terminal sets the initial hidden state and initial cell state to a zero vector or initializes them with random numbers. The specific setting values are not limited here. The purpose of setting the initial state is to enable the first element in the time step to have a substitution parameter when calculating, so that the LSTM network can correctly obtain the hidden state of the next time step.
[0144] In an embodiment of the present application, the initial hidden state and initial cell state of the LSTM network model during initial training are set to a zero vector. When the target hidden state is subsequently calculated using the LSTM network model, the hidden state data and cell state data obtained when the hidden state calculation was last completed are obtained according to the records as the initial state.
[0145] S202, setting the time steps corresponding to the elements of the video embedding vector sequence to generate a time step sequence;
[0146] The terminal needs to assign a time step label to each element in the video embedding vector sequence in order to correctly process the sequence data. The application on the terminal device creates a time step sequence based on the time data of the video viewing, which will be synchronized with the video embedding vector sequence.
[0147] Specifically, a time step is a time series, and the user's actions are used as a reference to divide the time state, so as to obtain the corresponding parameters of each video watched by the user, thereby avoiding the situation of obtaining duplicate data.
[0148] S203, according to the preset parameters of the LSTM network, taking the initial hidden state and the initial cell state as initial data;
[0149] Ensure that the LSTM network starts data processing using the correct parameters obtained from S201. The inference engine on the terminal loads the preset network parameters and sends the initial hidden state and cell state to the network.
[0150] S204, calculating all elements in the video embedding vector sequence one by one according to the LSTM network standard process and the time step sequence to obtain a target hidden state.
[0151] The module on the terminal needs to process the user's historical viewing data to generate hidden states that reflect the user's preferences.
[0152] Specifically, the algorithm module on the terminal device processes each video embedding vector in chronological order. For each time step, the input gate, forget gate, and output gate are calculated according to the standard equation of LSTM, and the cell state is updated. The hidden state of each time step is calculated and output using the updated cell state and output gate activation value. After completing the processing of the entire sequence, the terminal obtains the final hidden state, which captures the user's historical viewing habits and can be used for the recommendation algorithm.
[0153] For the specific learning process of the LSTM network based on step S204, please refer to Figure 3 , Figure 3 A flowchart of an embodiment of the LSTM network model training calculation process in the method for personalized recommendation based on a deep neural network provided in this application, the method comprising:
[0154] S301, obtaining an input gate activation value, wherein the input gate activation value is a hidden state of a time step before a current time step, and an initial value of the input gate activation value is calculated by using the initial hidden state and the initial cell state;
[0155] Calculate the input gate activation value to determine what information should be updated to the cell state at the current time step. Use the hidden state of the previous time step and the input (video embedding vector) of the current time step as input, and calculate the input gate activation value through the weight matrix and bias vector. The initial value is calculated by the initial hidden state and the initial cell state through the input gate equation of LSTM.
[0156] S302, calculating the forget gate activation value, output gate activation value and candidate cell state of all elements in the video embedding vector sequence one by one according to the time step sequence and the input gate activation value;
[0157] Determine the degree of opening and closing of the forget gate and output gate, and calculate the candidate cell state to prepare for updating the cell state. Using the input of the current time step and the hidden state of the previous time step, the corresponding activation value is calculated through the equations of the forget gate, output gate and candidate cell state of the LSTM network.
[0158] S303, calculating and updating the cell state according to the forget gate activation value and the candidate cell state;
[0159] Update the cell state according to the forget gate activation value and the candidate cell state. The cell state update is the process of forgetting old information and adding new information. The forget gate controls the degree of forgetting of the old cell state, and the candidate cell state provides new information.
[0160] S304, updating the cell state corresponding to the element in the current video embedding vector sequence according to the updated cell state to obtain the current cell state;
[0161] The updated cell state is associated with the embedding vector of the current time step to prepare for calculating the hidden state. The cell state of the current time step is updated using the updated cell state calculated in S303.
[0162] S305, using the current cell state to calculate the hidden state of the element of the video embedding vector sequence corresponding to the current time step, the hidden state is calculated by the following formula:
[0163] ;
[0164] in, is the output gate activation value, the cell state of the element of the video embedding vector sequence corresponding to the current time step;
[0165] S306: When the hidden state calculations of all elements in the video embedding vector sequence are completed, the hidden state of the last time step is the target hidden state.
[0166] After the entire sequence is processed, the hidden state of the final time step is obtained as a representation of the user's preference. After the hidden state calculations of all time steps are completed, the hidden state of the last time step is selected as the target hidden state, which contains the information of the entire viewing sequence.
[0167] In practice, a model needs to be compensated for loss after training. Figure 4 , Figure 4 A flow chart of an embodiment of a method for training a model in a LSTM network model training method in a method for personalized recommendation based on a deep neural network provided in the present application, the method comprising:
[0168] S401, after the LSTM network generates the target hidden state, the current state of the LSTM network is used to calculate the loss function, and the current state of the LSTM network is a training model;
[0169] The target hidden state generated by the LSTM network is used to evaluate the current prediction performance of the model. The module on the terminal receives the final hidden state of the LSTM network and uses it as input for the calculation of the loss function. The loss function measures the difference between the predicted output and the true label. The specific calculation method is:
[0170] S402, performing back propagation on the training model according to the chain rule and the total loss to obtain a partial derivative of the total loss with respect to the training model;
[0171] The gradient of the loss function with respect to the model parameters is calculated through the back-propagation algorithm to prepare for parameter update. The module on the terminal applies the chain rule to calculate the gradient of each parameter step by step from the output layer to the input layer. This step involves the calculation of the partial derivatives of the loss function with respect to hidden states, weights, biases, etc.
[0172] S403. Perform gradient update on the parameters of the training model according to the partial derivatives to obtain a target training model.
[0173] Update the model parameters to minimize the loss function and improve the model's prediction accuracy. The module on the terminal adjusts the model's parameters based on the calculated gradient and the predetermined learning rate. Weights and biases are usually updated using gradient descent or other optimization algorithms such as Adam or RMSprop. The updated model will continue to learn in the next training cycle to gradually improve performance.
[0174] See also Figure 5 , Figure 5 A flowchart of another embodiment of the method for personalized recommendation based on deep neural network provided in this application:
[0175] S501, obtaining user behavior data and video tag data;
[0176] S502: pre-process the user behavior data to obtain historical viewing behavior, where the historical viewing behavior includes a video ID and viewing duration;
[0177] Steps S501 to S502 in this embodiment are similar to steps S101 to S102 in the aforementioned embodiment, and will not be described in detail here.
[0178] S503, parsing the video tag data to obtain a video tag class set;
[0179] Extract all possible label categories from the video label data to facilitate subsequent One-Hot encoding. Check the video label data, identify and list all different labels to form a class set of video labels.
[0180] S504, creating a label column for each element included in the video label class set;
[0181] Prepare the structure for One-Hot encoding, with one column for each label class. Create a column vector for each label in the video label class set, which will form the rows of the One-Hot encoding matrix.
[0182] S505, obtaining video data, and parsing out video tags contained in the video data;
[0183] Collect video data and extract label information for each video. Retrieve video data from a video database or data source, including video content and corresponding labels.
[0184] S506: Mark the label column with the video data according to the video label to obtain a video label value.
[0185] Associate the video data with the label column of the One-Hot encoding. For each video, mark the corresponding position of its label in the One-Hot encoding matrix with 1, and mark the remaining positions with 0 to generate the label value of the video.
[0186] S507, converting the video tag value into a high-dimensional vector space of a tag word embedding vector embedding learning model through an embedding layer, so that the video tag can be used as a feature of neural network learning;
[0187] S508, serializing the historical viewing behavior to obtain a viewing sequence;
[0188] S509, converting the video ID into a video embedding vector through an embedding layer;
[0189] S510, integrating the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence;
[0190] S511, initialize the LSTM network, and input the elements in the video embedding vector sequence into the LSTM network one by one, calculate each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function, and obtain the target hidden state;
[0191] Steps S507 to S511 in this embodiment are similar to steps S104 to S108 in the above-mentioned embodiment, and will not be described in detail here.
[0192] S512, inputting the user behavior data of the target user into an embedding layer to obtain a historical viewing behavior sequence of the target user;
[0193] Convert the user's historical viewing behavior into sequence data that the model can process. Use the embedding layer to convert user behavior data (such as the ID and duration of the video watched) into a numerical vector to form a historical viewing behavior sequence.
[0194] S513, inputting the historical viewing behavior sequence of the target user into the target training model to obtain the target hidden state of the target user;
[0195] The user's historical behavior data is used to generate hidden states that can reflect the user's preferences. The historical viewing behavior sequence is input into the trained LSTM model, and the target hidden state is obtained through model calculation.
[0196] S514, obtaining candidate video data, and calculating the target probability that the videos in the candidate video data are liked by the target user one by one according to the following formula:
[0197] ;
[0198] in, is the predicted preference probability of the user in the next time step, σ is the Sigmoid function, and are the weight parameters of the model, is the hidden state at time step t, is the video embedding vector of the user at time step t+1, and b is the partial derivative.
[0199] in,
[0200] This application provides personalized video recommendations based on the user's historical viewing behavior and uses LSTM to process time series data of user behavior. It can capture changes in user viewing habits over time and provide more accurate recommendations. Through One-Hot encoding of video tags and embedding layer conversion, the terminal can understand the video content more deeply and implement content-based recommendations. Using the embedding layer to convert video IDs and labels into high-dimensional vectors, the terminal can automatically learn complex features in the data. The terminal can update the user's hidden state in real time to reflect the latest user behavior and preference changes. The learning and generalization capabilities of the LSTM network enable the recommendation terminal to adapt to different user groups and diverse video content.
[0201] The above is a detailed description of the method for personalized recommendation based on a deep neural network in the embodiment of the present application. The following is a detailed description of the system and device for personalized recommendation based on a deep neural network.
[0202] See also Figure 6 The present application provides an embodiment of a system for personalized recommendation based on a deep neural network, which includes:
[0203] A first acquisition unit 601 is used to acquire user behavior data and video tag data;
[0204] A preprocessing unit 602 is used to preprocess the user behavior data to obtain historical viewing behavior, where the historical viewing behavior includes a video ID and viewing duration;
[0205] A conversion unit 603, configured to convert the video tag data into a video tag value using One-Hot encoding, wherein the video tag value is numerical data;
[0206] A first embedding unit 604, configured to convert the video tag value into a high-dimensional vector space of a tag word embedding vector embedding learning model through an embedding layer, so that the video tag can be used as a feature of a neural network learning;
[0207] A serialization unit 605, configured to serialize the historical viewing behavior to obtain a viewing sequence;
[0208] A second embedding unit 606, configured to convert the video ID into a video embedding vector through an embedding layer;
[0209] An integration unit 607, configured to integrate the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence;
[0210] A model training unit 608 is used to initialize the LSTM network, and input the elements in the video embedding vector sequence into the LSTM network one by one, and calculate each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function to obtain a target hidden state;
[0211] The calculation unit 609 is used to obtain the user behavior data of the target user, combine the historical viewing behavior and the video tag data, calculate the target hidden state of the user behavior data of the target user according to the activation function, and obtain the recommendation result of the target user.
[0212] Optionally, the model training unit 608 is further used for:
[0213] Initialize the initial hidden state and initial cell state of the LSTM network;
[0214] Setting the time steps corresponding to the elements of the video embedding vector sequence to generate a time step sequence;
[0215] According to the preset parameters of the LSTM network, the initial hidden state and the initial cell state are used as initial data;
[0216] All elements in the video embedding vector sequence are calculated one by one according to the LSTM network standard process and the time step sequence to obtain the target hidden state.
[0217] Optionally, the model training unit 608 is further used for:
[0218] Obtaining an input gate activation value, wherein the input gate activation value is a hidden state of a time step before a current time step, and an initial value of the input gate activation value is calculated by using the initial hidden state and the initial cell state;
[0219] Calculate forget gate activation values, output gate activation values and candidate cell states of all elements in the video embedding vector sequence one by one according to the time step sequence and the input gate activation value;
[0220] Calculate and update the cell state according to the forget gate activation value and the candidate cell state;
[0221] The cell state corresponding to the element in the current video embedding vector sequence is updated according to the updated cell state to obtain the current cell state;
[0222] The hidden state of the element of the video embedding vector sequence corresponding to the current time step is calculated using the current cell state, and the hidden state is calculated by the following formula:
[0223] ;
[0224] in, is the output gate activation value, the cell state of the element of the video embedding vector sequence corresponding to the current time step;
[0225] When the hidden states of all elements in the video embedding vector sequence are calculated, the hidden state of the last time step is the target hidden state.
[0226] Optionally, the model training unit 608 is further used for:
[0227] Get the time step weight coefficient , the video label value of the element in the video embedding vector sequence at the corresponding time step , corresponding to the hidden state of the video embedding vector sequence element mapping of the time step sequence element ;
[0228] The time-weighted cross entropy loss function is calculated by the following formula to obtain the total loss of the historical viewing behavior training result:
[0229] ;
[0230] The video label value of the element in the video embedding vector sequence at the corresponding time step is , a constant of 0 or 1 indicating the selected state of the label, The hidden state of the video embedding vector sequence element mapped to the corresponding time step sequence element, wherein the hidden state is used to represent the preference state of the label corresponding to the video label value.
[0231] Optionally, the model training unit 608 is further used for:
[0232] After the LSTM network generates the target hidden state, the loss function is calculated using the current state of the LSTM network, where the current state of the LSTM network is a training model;
[0233] Back-propagating the training model according to the chain rule and the total loss to obtain a partial derivative of the total loss with respect to the training model;
[0234] The parameters of the training model are gradient updated according to the partial derivatives to obtain a target training model.
[0235] Optionally, the calculation unit 609 is further used for:
[0236] Inputting the user behavior data of the target user into the embedding layer to obtain the historical viewing behavior sequence of the target user;
[0237] Inputting the historical viewing behavior sequence of the target user into the target training model to obtain the target hidden state of the target user;
[0238] Obtain candidate video data, and calculate the target probability that the videos in the candidate video data are liked by the target user one by one according to the following formula:
[0239] ;
[0240] in, is the predicted preference probability of the user in the next time step, σ is the Sigmoid function, and are the weight parameters of the model, is the hidden state at time step t, is the video embedding vector of the user at time step t+1, and b is the partial derivative.
[0241] Optionally, the conversion unit 603 is further used for:
[0242] Parsing the video tag data to obtain a video tag class set;
[0243] Create a label column for each element included in the video label class set;
[0244] Acquire video data, and parse out video tags contained in the video data;
[0245] The video data is labeled with the label column according to the video label to obtain a video label value.
[0246] In this embodiment, the functions of each unit are the same as those described above. Figures 1 to 5 The steps in the illustrated embodiments correspond to each other and will not be described again here.
[0247] See also Figure 7 The present application embodiment provides another embodiment of a device for personalized recommendation based on a deep neural network, including:
[0248] Processor 701, memory 702, input and output unit 703, bus 704;
[0249] The processor 701 is connected to the memory 702, the input and output unit 703 and the bus 704;
[0250] The processor 701 specifically performs Figures 1 to 5 The operations corresponding to the steps in the method are not described in detail here.
[0251] The present application also relates to a computer-readable storage medium on which a program is stored, wherein when the program is run on a computer, the computer is caused to execute any of the above methods.
[0252] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0253] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0254] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0255] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0256] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A method for personalized recommendation based on deep neural network, characterized in that: The method comprises: Obtain user behavior data and video tag data; Preprocessing the user behavior data to obtain historical viewing behavior, where the historical viewing behavior includes a video ID and viewing duration; The video tag data is converted into a video tag value using One-Hot encoding, wherein the video tag value is numerical data; The video tag value is converted into a high-dimensional vector space of a tag word embedding vector embedding learning model through an embedding layer, so that the video tag can be used as a feature of neural network learning; Serializing the historical viewing behavior to obtain a viewing sequence; Convert the video ID into a video embedding vector through the embedding layer; Integrating the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence; Initialize the LSTM network, input the elements in the video embedding vector sequence into the LSTM network one by one, calculate each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function, and obtain the target hidden state; The user behavior data of the target user is obtained, and the target hidden state of the user behavior data of the target user is calculated according to the activation function in combination with the historical viewing behavior and the video tag data, so as to obtain the recommendation result of the target user.
2. The method according to claim 1, characterized in that The LSTM network is initialized, and the elements in the video embedding vector sequence are input into the LSTM network one by one, and each element is calculated one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function to obtain the target hidden state, including: Initialize the initial hidden state and initial cell state of the LSTM network; Setting the time steps corresponding to the elements of the video embedding vector sequence to generate a time step sequence; According to the preset parameters of the LSTM network, the initial hidden state and the initial cell state are used as initial data; All elements in the video embedding vector sequence are calculated one by one according to the LSTM network standard process and the time step sequence to obtain the target hidden state.
3. The method according to claim 2, characterized in that The step of calculating all elements in the video embedding vector sequence one by one according to the LSTM network standard process and the time step sequence to obtain the target hidden state includes: Obtaining an input gate activation value, wherein the input gate activation value is a hidden state of a time step before a current time step, and an initial value of the input gate activation value is calculated by using the initial hidden state and the initial cell state; Calculate forget gate activation values, output gate activation values and candidate cell states of all elements in the video embedding vector sequence one by one according to the time step sequence and the input gate activation value; Calculate and update the cell state according to the forget gate activation value and the candidate cell state; The cell state corresponding to the element in the current video embedding vector sequence is updated according to the updated cell state to obtain the current cell state; The hidden state of the element of the video embedding vector sequence corresponding to the current time step is calculated using the current cell state, and the hidden state is calculated by the following formula: ; in, is the output gate activation value, the cell state of the element of the video embedding vector sequence corresponding to the current time step; When the hidden states of all elements in the video embedding vector sequence are calculated, the hidden state of the last time step is the target hidden state.
4. The method according to claim 1, characterized in that: The time-weighted cross entropy loss function includes: Get the time step weight coefficient , the video label value of the element in the video embedding vector sequence at the corresponding time step , corresponding to the hidden state of the video embedding vector sequence element mapping of the time step sequence element ; The time-weighted cross entropy loss function is calculated by the following formula to obtain the total loss of the historical viewing behavior training result: ; The video label value of the element in the video embedding vector sequence at the corresponding time step is , a constant of 0 or 1 indicating the selected state of the label, The hidden state of the video embedding vector sequence element mapped to the corresponding time step sequence element, wherein the hidden state is used to represent the preference state of the label corresponding to the video label value.
5. The method according to claim 4, characterized in that After obtaining the total loss amount of the historical viewing behavior training results, the method further includes: After the LSTM network generates the target hidden state, the loss function is calculated using the current state of the LSTM network, where the current state of the LSTM network is a training model; Back-propagating the training model according to the chain rule and the total loss to obtain a partial derivative of the total loss with respect to the training model; The parameters of the training model are gradient updated according to the partial derivatives to obtain a target training model.
6. The method according to claim 5, characterized in that The acquiring of user behavior data of the target user, combining the historical viewing behavior and video tag data, calculating the target hidden state of the user behavior data of the target user according to an activation function, and obtaining the recommendation result of the target user comprises: Inputting the user behavior data of the target user into the embedding layer to obtain the historical viewing behavior sequence of the target user; Inputting the historical viewing behavior sequence of the target user into the target training model to obtain the target hidden state of the target user; Obtain candidate video data, and calculate the target probability that the videos in the candidate video data are liked by the target user one by one according to the following formula: ; in, is the predicted preference probability of the user in the next time step, σ is the Sigmoid function, and are the weight parameters of the model, is the hidden state at time step t, is the video embedding vector of the user at time step t+1, and b is the partial derivative.
7. The method according to any one of claims 1 to 6, characterized in that The video tag data is converted into a video tag value using One-Hot encoding, and the video tag value is numerical data including: Parsing the video tag data to obtain a video tag class set; Create a label column for each element included in the video label class set; Acquire video data, and parse out video tags contained in the video data; The video data is labeled with the label column according to the video label to obtain a video label value.
8. A system for personalized recommendation based on deep neural network, characterized in that: The system comprises: A first acquisition unit, used to acquire user behavior data and video tag data; A preprocessing unit, configured to preprocess the user behavior data to obtain historical viewing behavior, wherein the historical viewing behavior includes a video ID and viewing duration; A conversion unit, used to convert the video tag data into a video tag value using One-Hot encoding, wherein the video tag value is numerical data; A first embedding unit, configured to convert the video tag value into a high-dimensional vector space of a tag word embedding vector embedding learning model through an embedding layer, so that the video tag can be used as a feature of neural network learning; A serialization unit, used for serializing the historical viewing behavior to obtain a viewing sequence; A second embedding unit, configured to convert the video ID into a video embedding vector through an embedding layer; an integration unit, configured to integrate the video embedding vectors according to the viewing sequence to obtain a video embedding vector sequence; A model training unit is used to initialize the LSTM network, and input the elements in the video embedding vector sequence into the LSTM network one by one, and calculate each element one by one according to the order of the elements in the video embedding vector sequence by calculating the time-weighted cross entropy loss function to obtain a target hidden state; A calculation unit is used to obtain user behavior data of a target user, combine the historical viewing behavior and video tag data, calculate the target hidden state of the user behavior data of the target user according to an activation function, and obtain a recommendation result for the target user.
9. A device for personalized recommendation based on deep neural network, characterized in that: The device comprises: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, performs the method according to any one of claims 1 to 7.
