A Two-Tower Social Recommendation Method Based on Federated Comparative Learning
By introducing dual-tower learning and user attention comparison into federated social recommendation, and combining gradient perturbation and contrastive learning with differential privacy technology, the contradiction between social noise and privacy protection is resolved, thereby improving the accuracy and privacy of the recommendation model.
Patent Information
- Application Number
- CN202310023586.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-09
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-01-09
AI Technical Summary
Existing federated social recommendation methods, while protecting user privacy, have failed to effectively reduce the impact of noise and data perturbation in social relationships on the performance of recommendation models, resulting in a decrease in recommendation accuracy.
We adopt a dual-tower social recommendation method based on federated contrastive learning. By performing dual-tower learning and comparing user attention on the user client, we calculate the contrast loss between users and use differential privacy technology to protect the gradient perturbation. At the same time, we perform secondary updates and contrastive learning of the perturbed gradient on the central server to reduce the impact of noise.
It effectively reduces the impact of social noise on the recommendation model, improves the model's robustness and privacy protection, and achieves efficient recommendation results with a smaller privacy budget.
Smart Images

Figure CN116049570B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence interaction technology, and in particular to a dual-tower social recommendation method based on federated contrastive learning. Background Technology
[0002] With the advent of the big data era, recommender systems have emerged to help users filter items of interest from massive amounts of data, becoming an indispensable application in people's lives. Recommender systems collect users' personal information and historical interaction records (clicks, ratings, purchases, etc.) as data sources to train recommendation models, thereby generating a sequence of recommended items for users. However, in this process, users' personal data is often stored at recommendation service providers, posing a risk of privacy leaks, especially in social recommendation systems, where the impact on users is far greater than in general recommendation systems. Federated learning can mitigate this risk at its source.
[0003] For federated social recommendation systems, user data is always stored on the user's terminal. The recommendation model is trained locally using user personal data and social information. Data perturbation and secure multi-party computation are used to protect the training parameters before uploading, thus eliminating the risk of privacy leaks at the service provider. FedGNN, as the first federated social recommendation model, uses GNN to extract relationships between users and between users and items locally, and uses homomorphic encryption to protect the uploaded gradients. FeSoG calculates attention scores between users and between users and items using GAT, aggregating the user's own interests and preferences. It also uses differential privacy techniques to perturb the uploaded gradients. Compared to homomorphic encryption, this approach reduces the computational burden on the user's terminal device by sacrificing some model performance, while still providing high privacy protection. However, these methods do not consider the noise inherent in social relationships. Users' interests and preferences with their social friends are not necessarily similar, which can negatively impact model performance if social information is directly used. Furthermore, the noise introduced by data perturbation further affects the model's convergence speed and effectiveness.
[0004] In summary, although current social recommendation methods can make recommendations to users while protecting their personal and social information, these methods ignore the noise problem introduced during training, namely the implicit noise in users' social information and the noise introduced by data perturbation in gradient protection. This noise will ultimately affect the performance of the recommendation model and lead to a decrease in the accuracy of the recommendations. Summary of the Invention
[0005] The purpose of this invention is to provide a dual-tower social recommendation method based on federated contrastive learning. In a federated social recommendation environment, this invention can protect user privacy and security while reducing the impact of social noise between users and noise introduced by data perturbation on the performance of the recommendation model.
[0006] The technical solution of this invention: A dual-tower social recommendation method based on federated contrastive learning, comprising the following steps:
[0007] Step 1: The central server randomly selects a fixed number of user clients to participate in the local training of the current round, and distributes the model parameters, user embedding vectors and item embedding vectors to the user clients.
[0008] Step 2: Perform local training on the user client described in Step 1. Local training includes a dual-tower learning module and a user attention comparison module. The dual-tower learning module calculates the user's rating loss for items, and the attention comparison module calculates the comparison loss between users. The model loss function is calculated by combining the rating loss and the comparison loss.
[0009] After steps 3 and 2 are completed, the model gradient, user embedding vector gradient, and item embedding vector gradient are obtained. All gradients are perturbed by noise through the gradient protection module, and the perturbed gradients with added noise are uploaded to the central server.
[0010] Step 4: The central server aggregates the perturbation gradients obtained in Step 3 to obtain the final model gradients and generates the first updated user embedding vectors and item embedding vectors. The first updated user embedding vectors and item embedding vectors are then processed by the perturbation contrastive learning module to calculate the user and item contrastive losses respectively (equivalent to updating again based on the aggregated perturbation gradients) to achieve a second update, thus obtaining the final user embedding vectors and item embedding vectors. This completes one round of training.
[0011] Step 5: Repeat steps 1 to 4 until the set number of training rounds are completed, and obtain the converged model, user embedding vector and item embedding vector.
[0012] Step 6: For the model obtained in Step 5, use the converged user embedding vector and item embedding vector as model input to obtain the predicted rating of the input user for the input item, and obtain the final recommended item list for the user by sorting.
[0013] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, the user embedding vector in the dual-tower learning module is passed through three fully connected layers to obtain its final representation. The input for each layer is:
[0014] ,
[0015] in, This represents the input of user i's embedding vector at layer k. and These represent the weights and biases of the k-th fully connected layer, respectively. This represents the ReLU activation function.
[0016] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, similarly, in the dual-tower learning module, the item embedding vector is passed through three fully connected layers to obtain its final representation. The user embedding vector obtained after passing through three fully connected layers and item embedding vector Perform a dot product to obtain the predicted rating for user i on item j, and use this to calculate the rating loss, which is:
[0017] ,
[0018] in, This represents the actual rating of user i for item j; A collection of items.
[0019] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, the attention contrast module, based on current social science theory that users often share similar interests with their friends, uses users and their social friends as positive sample pairs for contrastive learning, and randomly selects irrelevant users with the same number of social friends as negative sample pairs. Simultaneously, considering the varying degrees of similarity in interests between users and their social friends, an attention mechanism is used to obtain the similarity between users and their social friends, which serves as a weight in the contrastive learning process, effectively reducing noise in social relationships. This is used to calculate the contrastive loss between users, and the formula for calculating the contrastive loss is as follows:
[0020]
[0021] in, This represents the set of social friends of user i. Let $\mathbf{i}$ be the set of non-social friends of user $i$, and the number of elements in the set is equal to $\mathbf{i}$. same, This represents the cosine similarity function, used to calculate the similarity between user embedding vectors. This is a temperature hyperparameter used to control the scaling of similarity between users. Let the social trust weight of user n to user i be calculated as follows:
[0022] ,
[0023] ,
[0024] in, Rate the attention of user n to user i. This represents the LeakReLU activation function, where a and W are the mapping parameters to be trained. This indicates a splicing operation.
[0025] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, the model loss function is:
[0026] ,
[0027] in, Hyperparameters for controlling user social contrast loss.
[0028] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, the gradient protection module adds adaptive Laplacian noise to the model parameters, user embedding vectors, and item embedding vectors using differential privacy technology. This effectively prevents malicious attackers from inferring the user's original data information from the gradient information. The adaptive Laplacian noise is calculated as follows:
[0029] ,
[0030] in, It is a mean function. For privacy budgeting, the final gradient after Laplace noise perturbation is:
[0031] ,
[0032] Here, clip() is the clipping function, and the gradient of the model parameters is obtained by perturbation using Laplacian noise. For both user embedding vectors and item embedding vectors, add Laplacian noise with the same mean and intensity, calculate the perturbation gradient twice, and obtain two different perturbation gradients. , , , .
[0033] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, step 4 involves using the FedAvg algorithm to process the perturbation gradient. , , , , Aggregation is performed, and the resulting model gradient is the final model gradient that needs to be updated.
[0034] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, in the perturbation contrastive learning model, the two perturbation user gradients and two perturbation item gradients obtained after aggregation are added to the original user embedding vector and the original item embedding vector, respectively, to obtain two perturbation user embedding vectors and two perturbation item embedding vectors.
[0035] The presence of perturbation gradients can protect user privacy, but it inevitably affects the convergence speed and performance of the model after convergence. To mitigate this negative impact and improve the robustness of the embedding vectors, a contrastive learning method is adopted. Two perturbation user embedding vectors are used, with the same user as a positive sample and different users as negative samples. Similarly, for perturbation item embedding vectors, the same item is used as a positive sample and different items as negative samples. The contrastive loss for users and items is calculated.
[0036] The user's comparative loss is:
[0037] ,
[0038] The item comparison loss is:
[0039] ,
[0040] The total comparison loss on the central server side is:
[0041] ,
[0042] in, , These are the sets of aggregated user embedding vectors and the sets of aggregated item embedding vectors, respectively, in this round. For temperature hyperparameters, and These are hyperparameters.
[0043] In the aforementioned dual-tower social recommendation method based on federated contrastive learning, for Using gradient descent, after the initial update of the user embedding vector and item embedding vector, a second update is performed based on the aggregated perturbation gradient to obtain the final user embedding vector and item embedding vector.
[0044] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention calculates social influence weights by utilizing the attention scores between users and their social users, and uses these weights to control user contrast loss. This achieves more granular control of contrast loss, reducing the impact of social noise on recommendation model performance while better capturing user interests and preferences using social information. Existing federated social recommendation methods struggle to simultaneously achieve good performance in balancing model privacy and effectiveness. This invention obtains two different perturbation gradients by adding noise to the perturbation gradient twice. Based on this, contrastive learning is used to shorten the distance between identical embedding vectors and widen the distance between different embedding vectors, effectively reducing the perturbation of embedding vectors by noise, thus improving the model's robustness and allowing it to achieve better recommendation results with a smaller privacy budget.
[0045] The model trained by this invention can effectively reduce the social noise contained in user social information in federated social recommendation scenarios, and further reduce the impact of privacy protection on model performance while protecting user privacy data, achieving high privacy and high effectiveness at the same time. Attached Figure Description
[0046] Figure 1 This is a flowchart of the recommended method of the present invention;
[0047] Figure 2 This is a schematic diagram of the dual-tower learning module structure of the method recommended in this invention;
[0048] Figure 3 This is a flowchart of the attention mechanism in the user attention comparison module of the recommended method of this invention. Detailed Implementation
[0049] The present invention will be further described below with reference to the accompanying drawings and embodiments, but this should not be construed as limiting the present invention.
[0050] Example: A dual-tower social recommendation method based on federated contrastive learning; the implementation process can be found in the following example. Figure 1 This includes the following steps:
[0051] Step 1: The central server randomly selects a fixed number of user clients to participate in the local training of the current round, and distributes the model parameters, user embedding vectors, and item embedding vectors to the user clients.
[0052] In each training round, the central server randomly selects s user clients and distributes the model parameters, user embedding vectors, and item embedding vectors stored in the central server to the corresponding s user clients for local training on the user clients.
[0053] Step 2: Perform local training on the user client in Step 1. Local training includes a dual-tower learning module and a user attention comparison module. The dual-tower learning module calculates the user's rating loss for items, and the attention comparison module calculates the comparison loss between users. The model loss function is calculated by combining the rating loss and the comparison loss.
[0054] For the dual-tower learning module, the module's structural framework can be found here. Figure 2 It contains two three-layer MLPs, which perform nonlinear transformations on user embedding vectors and item embedding vectors respectively to extract user interests and item features. Taking user embedding vectors as an example, for user i, its embedding vector... Where d is the dimension of the embedding vector, As input to the MLP, for the k-th layer:
[0055] ,
[0056] in, This represents the input of user i's embedding vector at layer k. and These represent the weights and biases of the k-th fully connected layer, respectively. This represents the ReLU activation function, used to implement nonlinear transformations. Similarly, in the dual-tower learning module, the item embedding vector is processed through a three-layer MLP to obtain its final representation. .
[0057] After passing through two three-layer MLPs, we obtain the embedding vector representations of users and items. and After taking the dot product, we obtain the predicted rating of user i for item j, and use it to calculate the rating loss, which is:
[0058] ,
[0059] in, This represents user i's actual rating for item j. The collection of items that user i has rated in the past.
[0060] For the user attention comparison module, please refer to the attention mechanism flowchart. Figure 3According to existing social network theory, users tend to have similar interests and preferences to those they trust. In a federated social recommendation scenario, a user's social friends can be considered trusted users. Therefore, the user's embedding vector is relatively close to the embedding vectors of their social friends on the hypersphere, while the distance to non-social friends is relatively large. Thus, a positive sample pair can be formed between the user's embedding vectors and those of their social friends, and a negative sample pair can be formed between the user's embedding vectors and those of non-social friends. Contrastive learning can then be used to calculate the contrastive loss. However, simply considering a user's social friends as trusted users introduces some error, as social relationships contain social noise. This invention treats the trust level of all social friends as the same value, meaning that the impact of higher-trust and lower-trust social friends on the user is consistent. Therefore, different social trust weights are added to different social friends to achieve more granular social influence and reduce the impact of social noise on the user. The contrastive loss is calculated using the following formula:
[0061]
[0062] in, This represents the set of social friends of user i. Let $\mathbf{i}$ be the set of non-social friends of user $i$, and the number of elements in the set is equal to $\mathbf{i}$. same, This represents the cosine similarity function, used to calculate the similarity between user embedding vectors. This is a temperature hyperparameter used to control the scaling of similarity between users. Let n be the social trust weight of user i, through The degree of social influence that social users with different levels of social trust can control over has on user i. It is calculated using the softmax function, and the calculation method is as follows:
[0063] ,
[0064] ,
[0065] in, Rate the attention of user n to user i. This represents the LeakReLU activation function, where a and W are the mapping parameters to be trained. This represents the concatenation operation. The embedding vectors of user i and user n are mapped to the embedding space using the mapping matrix W, then concatenated and multiplied with the parameter a to obtain the attention score of user n for user i. .
[0066] Compared to contrastive learning methods, the introduction of social trust weights can effectively address the drawback of overly average social contrast loss among users, making different social users have different influences on the target user. Furthermore, the social trust weights calculated based on attention scores integrate the embedding vectors of the target user and their social users, further uncovering deeper connections in social relationships.
[0067] Regarding the loss in user ratings Compared with user social interaction, the loss The model loss is calculated, and the model loss function is:
[0068] ,
[0069] in, Hyperparameters for controlling user social contrast loss.
[0070] After steps 3 and 2 are completed, the model gradient, user embedding vector gradient, and item embedding vector gradient are obtained. All gradients are perturbed by noise through the gradient protection module, and the perturbed gradients with added noise are uploaded to the central server.
[0071] After local training on the user's client, the gradients of the model, user embedding vectors, and item embedding vectors that need to be uploaded can be obtained. However, directly uploading the gradients to the central server may lead to privacy leaks. Existing research shows that malicious attackers can analyze the gradients during the upload phase and then infer the original data of the corresponding user. To avoid such situations, this invention uses differential privacy technology to noise-perturb the uploaded gradients in the gradient protection module.
[0072] To satisfy the differential privacy condition for gradient g, it is first pruned according to a pruning threshold c. However, a fixed pruning threshold often has different effects on gradients of different orders of magnitude. Therefore, the mean of gradient g is used as the pruning threshold to achieve an adaptive effect. Subsequently, the pruning threshold and privacy budget are considered. The intensity of the added Laplace noise is determined to obtain the final perturbation gradient. Specifically, the adaptive Laplace noise is calculated as follows:
[0073] ,
[0074] in, It is a mean function. For privacy budget, privacy budget It can be used to measure the strength of privacy protection. The smaller the value, the greater the added noise, and the stronger the privacy protection. The larger the value, the opposite is true; the final gradient after Laplace noise perturbation is:
[0075] ,
[0076] Here, clip() is the clipping function, and the gradient of the model parameters is obtained by perturbation using Laplacian noise. For both user embedding vectors and item embedding vectors, add Laplacian noise with the same mean and intensity, calculate the perturbation gradient twice, and obtain two different perturbation gradients. , , , .
[0077] Step 4: The central server aggregates the perturbation gradients obtained in Step 3 to obtain the final model gradients and generates the first updated user embedding vectors and item embedding vectors. The first updated user embedding vectors and item embedding vectors are then used by the perturbation contrastive learning module to calculate the user and item contrastive losses respectively (equivalent to updating again based on the aggregated perturbation gradients) to achieve a second update, thus obtaining the final user embedding vectors and item embedding vectors. This completes one round of training.
[0078] In this step, the perturbation gradient obtained in step 3 is... , , , , The FedAvg algorithm is used for aggregation, and the resulting model gradient is the final model gradient that needs to be updated.
[0079] However, existing technologies typically use the aggregated gradients of user embedding vectors and item embedding vectors as the final gradients to update the user embedding vectors and item embedding vectors. However, the Laplacian noise added to protect user privacy data can cause significant deviations in the representation of user interests and preferences as well as the capture of item features. Therefore, this invention needs to utilize contrastive learning methods again to reduce the impact of this deviation on the performance of the model after convergence.
[0080] Specifically, in the perturbation contrastive learning model, the two perturbation user gradients and two perturbation item gradients obtained after aggregation are added to the original user embedding vector and the original item embedding vector, respectively, to obtain two perturbation user embedding vectors and two perturbation item embedding vectors. In the two perturbation user embedding vectors, the same user is used as a positive sample and different users are used as negative samples. Similarly, for the perturbation item embedding vectors, the same item is used as a positive sample and different items are used as negative samples. The contrastive loss for users and items is calculated.
[0081] The user's comparative loss is:
[0082] ,
[0083] The item comparison loss is:
[0084] ,
[0085] The total comparison loss on the central server side is:
[0086] ,
[0087] in, , These are the sets of aggregated user embedding vectors and the sets of aggregated item embedding vectors, respectively, in this round. For temperature hyperparameters, and These are hyperparameters.
[0088] right Using gradient descent, after the initial update of the user and item embedding vectors, a second update is performed based on the aggregated perturbation gradient to obtain the final user and item embedding vectors. This completes a full training cycle between the central server and the user client.
[0089] Step 5: Repeat steps 1 to 4 until the set number of training rounds are completed, and obtain the converged model, user embedding vector, and item embedding vector.
[0090] Step 6: For the model obtained in Step 5, use the converged user embedding vector and item embedding vector as model input to obtain the predicted rating of the input user for the input item, and obtain the final recommended item list for the user by sorting.
[0091] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A dual tower social recommendation method based on federated contrastive learning, characterized in that: The method comprises the following steps: Step 1, the central server randomly selects a fixed number of user clients for participating in the local training of the current round, and distributes model parameters, user embedding vectors and item embedding vectors to the user clients; Step 2, local training is performed on the user clients in step 1, the local training includes a double tower learning module and a user attention contrast module, the user's rating loss for an item is calculated through the double tower learning module, the contrast loss between users is calculated through the attention contrast module, and the model loss function is calculated by combining the rating loss and the contrast loss; Step 3, after step 2, the model gradient, user embedding vector gradient and item embedding vector gradient are obtained, all the gradients are subjected to noise disturbance through a gradient protection module, and the disturbed gradient after adding noise is uploaded to the central server; Step 4, parameter aggregation of the perturbed gradient obtained in step 3 by the central server to obtain the final model gradient, and generate the first updated two perturbed user embedding vectors and two perturbed item embedding vectors The first updated two perturbed user embedding vectors and two perturbed item embedding vectors are calculated by the perturbed contrast learning module to realize secondary update to obtain the final user embedding vectors and item embedding vectors , thus completing a round of training; Step 5, repeat steps 1 to 4 until a set number of training rounds are completed, and obtain the converged model, user embedding vector and item embedding vector; Step 6, for the model obtained in step 5, the converged user embedding vector and item embedding vector are input into the model to obtain the predicted rating of the input user for the input item, and the final recommended item list for the user is obtained through sorting; In the dual tower learning module, the item embedding vector is passed through three fully connected layers to obtain its final representation The user embedding vector obtained after passing through three fully connected layers and the item embedding vector Dot product is performed to obtain the predicted score of user i for item j, and the score loss is calculated therefrom, and the score loss is: , wherein, represents the true rating of item j by user i; is the set of historical rated items for user i; In the attention contrast module, the user and his / her social friends are taken as positive sample pairs for contrast learning, and a number of irrelevant users consistent with the number of social friends are randomly selected as negative sample pairs, the similarity between the user and his / her social friends is obtained through the attention mechanism as the weight in the contrast learning, and the contrast loss between users is calculated, and the contrast loss calculation formula is: where, S i represents the set of social friends of user i, N i represents the set of non-social friends of user i, and the number of elements in the set is the same as S i, cosine similarity function used to compute the similarity between user embedding vectors, is a temperature hyper-parameter used to control the scaling of the similarity between users, is the social trust weight of user n to user i, which is computed as follows: , , wherein, is the attention score of user n to user i, denotes a LeakReLU activation function, a, W are mapping parameters to be trained, denotes a concatenation operation; The model loss function is: , wherein, is a hyperparameter to control the user social contrast loss.
2. The dual tower social recommendation method based on federated contrastive learning according to claim 1, characterized in that: In the dual tower learning module, the user embedding vector passes through three fully connected layers to obtain its final representation where the input to each layer is: , where, denotes the input of the embedding vector of user i at the kth layer, and denote the weight and bias of the kth fully connected layer, respectively, denotes the ReLU activation function.
3. The dual tower social recommendation method based on federated contrastive learning according to claim 1, characterized in that: In the gradient protection module, adaptive Laplace noise is added to the model gradient, user embedding vector gradient and item embedding vector gradient respectively by using differential privacy technology, and the adaptive Laplace noise calculation method is: , where, is the mean function, is the privacy budget, and the final gradient after Laplace noise perturbation is: , where clip(·) is a clipping function, and the perturbed gradient is obtained by perturbing the gradient of the model parameters with Laplacian noise ; for the user embedding vector and the item embedding vector, the same mean and intensity of Laplacian noise are added respectively, and two perturbed gradients are calculated to obtain two different perturbed user gradients 、 , two perturbed item gradients 、 .
4. The dual tower social recommendation method based on federated contrastive learning according to claim 3, characterized in that: In step 4, the disturbed gradient is aggregated by using the FedAvg algorithm , , , , The model gradient obtained after aggregation is the final model gradient that needs to be updated.
5. The dual tower social recommendation method based on federated contrastive learning according to claim 4, characterized in that: In the disturbance contrast learning module, for the two disturbed user gradients, the two disturbed item gradients obtained after disturbance, the original user embedding vectors and the original item embedding vectors are added respectively to obtain two disturbed user embedding vectors and two disturbed item embedding vectors ; the method of contrast learning is used to take the two disturbed user embedding vectors , the same user as the positive sample , and the different user as the negative sample , for the disturbed item embedding vectors , the same item as the positive sample , and the different item as the negative sample , and the user and item contrast loss is calculated; The user contrast loss is: , The item contrast loss is: , The total contrast loss of the central server is: , wherein, , are, respectively, a set of aggregated user embedding vectors and a set of aggregated item embedding vectors in the current round, is a temperature hyperparameter, and are hyperparameters.
6. The dual tower social recommendation method based on federated contrastive learning according to claim 5, characterized in that: To With the method of gradient descent, the final user embedding vector and item embedding vector are obtained by twice updating according to the aggregated perturbed gradient after the first update of the user embedding vector and item embedding vector and item embedding vector .
Citation Information
Patent Citations
Distributed learning privacy protection method based on differential privacy
CN111814189A
Social collaborative filtering recommendation method based on federal learning
CN114510652A