A friend recommendation method for online social platforms based on enhanced contrast representation
By building social networks and negative networks, using graph neural networks to extract user representations and calculate loss functions, the accuracy problem of friend recommendations in sparse social networks is solved, and more accurate and reliable friend recommendations are achieved.
Patent Information
- Application Number
- CN202510077131.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-01-17
AI Technical Summary
The friend recommendation system of the existing online social platform has poor recommendation systems due to sparse social network relationship information and noisy connections affect the accuracy, making it difficult to obtain comprehensive social network user statements efficiently, resulting in poor recommendation results.
Using an enhanced contrast representation method, by constructing a negative network of social networks and noise perturbation, user representations are extracted using graph neural networks, and hierarchical contrast learning, topology and structure losses are calculated, and personalized friend recommendations are finally obtained.
Optimizing social network representation through multi-angle information improves the accuracy and reliability of friend recommendations and enhances the robustness of user representation.
Smart Images

Figure CN120011655B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of recommendation, and in particular relates to a friend recommendation method for an online social platform based on enhanced contrast representation. Background Art
[0002] Online social platforms, such as Weibo and WeChat, provide users with online social services and play a crucial role in the current development of the internet. Social interaction is an inherent need of human spiritual life, contributing to individual growth, group harmony, and the spread of culture. Online social interaction transcends geographical constraints, providing real-time interaction and further satisfying people's social needs. The relationships between online users form vast social networks. Data analysis of social networks can help understand users' interpersonal and potential relationships, enabling targeted advertising and more effective dissemination of knowledge and information. This has a profound impact on people's thinking and communication methods, and therefore holds enormous market potential.
[0003] Online social friend recommendation aims to predict potential friendships based on known online social friend relationships. This method is widely used across major social platforms. On the one hand, users can use social friend recommendations to find suitable friends and expand their circle of friends. On the other hand, social platforms can use this to improve user stickiness and activity, thereby increasing the platform's commercial value. However, the number of a user's friends is far smaller than the vast number of social network users. As a result, social network relationship information is sparse, which greatly increases the destructiveness of noisy connections on social network relationships, thereby affecting the accuracy of online social friend recommendation systems. Therefore, how to capture robust and rich social network information representations has become a research hotspot in AI-based online social friend recommendation systems. Summary of the Invention
[0004] In order to overcome the problems that existing methods are difficult to efficiently obtain comprehensive social network user representations and the accuracy of friend recommendations is low, the present invention proposes an online social platform friend recommendation method based on enhanced contrastive representation with strong representation ability and excellent recommendation effect.
[0005] The technical specific steps adopted by the present invention to solve its technical problem are:
[0006] A friend recommendation method for online social platforms based on enhanced contrastive representation. First, a social network and a noise-perturbed negative social network are constructed for the online social platform. Then, a graph neural network is used to extract social user representations of the social network and the negative network. Then, hierarchical contrastive learning loss, topological loss, and structural loss are calculated on the social user representations. Finally, the total loss function is combined to obtain the final loss function, and personalized friend recommendation is achieved through the final social user representation.
[0007] Furthermore, the method comprises the following steps:
[0008] Step 1: Build a social network G between users of the online social platform. In the network G, the nodes in the network are defined as users. If two users follow each other in the online social platform, there is an edge between the users. Each user has attribute information; build a negative network The network is constructed by randomly modifying the order of some edges and attributes of the social network G;
[0009] Step 2: Build a graph neural network, which consists of a l-layer graph convolutional network. The graph neural network is used to mine the social network G and the negative network respectively. The information in the corresponding k≤l layer representation h is obtained k and
[0010] Step 3: Calculate the layer-wise contrastive learning loss of social user representation in the graph neural network. For the kth layer, calculate the global network representation g of the layer k , construct the discriminator β for similarity calculation, by maximizing β(g k , h k ), minimize To achieve the contrastive learning loss construction of the k-th layer;
[0011] Step 4: Calculate the topological loss of social user representation in the graph neural network. For the kth layer, construct the topological representation c k and topological negative representation Construct a discriminator γ for similarity calculation, by maximizing γ(g k , c k ), minimize To achieve the topological loss construction of the kth layer;
[0012] Step 5: Calculate the structural loss of social user representation in the graph neural network. For the kth layer, use matrix multiplication r k =h k (h k ) T Get the predicted k-th layer network structure by maximizing the distance between user i and user j in the real social network value to achieve the social network structure loss of the kth layer, and do similar operations on the negative network to achieve the negative network structure loss of the kth layer;
[0013] Step 6: Calculate the total loss function;
[0014] Step 7: Repeat steps 2 to 6 to obtain the final social user representation matrix;
[0015] Step 8: Calculate the representation similarity score to achieve personalized friend recommendations for the user.
[0016] Preferably, in step 1, user and user relationship information is obtained through an online social platform, and then a social network G = (V, E, X) is constructed based on this information, where V = {v1, v2, ..., v N} represents all users, E represents the relationship between users, N represents the number of users, X∈R N×dim Represents the attribute information of users, with a total of dim attributes. The adjacency matrix of the social network is represented by A=[a ii ]∈R N×N Indicates that when users are friends with each other, ij =1, otherwise a ij = 0, the degree matrix of the social network is D = diag (d1, d2, ... d N ) indicates that d i =∑ j a ij , the negative network use of social networks Indicates that To randomly modify some edges of G, To randomly disrupt the attributes of some users;
[0017] In the second step, a graph neural network is used to extract user representations of the social network G. The network consists of a graph convolutional network GCN with a layer of l. The social user representation of the k-th layer GCN is
[0018]
[0019] where k∈{1, .., l}, W k is the weight matrix of the kth layer, I is the unit matrix, h 0 =X, is the PRELU activation function; is the negative network Perform the same graph neural network operation to obtain the corresponding negative representations of social users at each layer
[0020] In step 3, the hierarchical contrast loss of social user representation in the graph neural network is calculated.
[0021]
[0022] The contrast loss of the k-th layer is,
[0023]
[0024] where k∈{1, .., l}, Q is the learnable weight matrix, is the matrix h k The i-th row vector of represents the characterization of the i-th user, is a matrix The i-th row vector of represents the negative representation of the i-th user; is the global network representation, σ is the sigmoid activation function;
[0025] In step 4, the topological loss of social user representation in the graph neural network is calculated.
[0026]
[0027] The topological loss of the kth layer is,
[0028]
[0029] where k∈{1, .., l}, is the topological representation of the kth layer, is the topological negative representation of the k-th layer, c k The i-th row vector of represents the topological representation of the i-th user, for The i-th row vector of represents the topological representation of the i-th user;
[0030] In step 5, the structural loss of social user representation in the graph neural network is calculated.
[0031]
[0032] The structural loss of the kth layer is,
[0033]
[0034] where k∈{1, .., l}, r k =h k (h k )T is the predicted k-th layer network structure, is the predicted k-th layer negative network structure, is an indicator function, which has a value of 1 when the subscript condition is met, otherwise it is 0;
[0035] In step six, the total loss function is calculated.
[0036] L = L1 + L2 + L3;
[0037] In step 7, steps 2 to 6 are repeated. When L decreases to a specified threshold, the calculation is terminated. The final social user representation matrix is h = h 1+h 2 +…+h l ;
[0038] In step 8, for any social user i, its user representation h i The vector represented by the i-th row of the social user representation matrix h is used to calculate the representation similarity scores between the social user and all other social users, and the K non-friends with the highest similarity scores are selected as the recommended friends of the user.
[0039] The technical concept of the present invention is: the present invention enhances the representation of social network users through a comparative learning method, thereby improving the accuracy and reliability of a friend recommendation algorithm.
[0040] The beneficial effects of the present invention are: considering the overall user information, the topological relationship of users and the structural relationship of the network respectively, optimizing the social network representation through multi-angle information, and improving the accuracy and reliability of recommendations. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 Schematic diagram of the process of friend recommendation method for online social platforms based on enhanced contrast representation. DETAILED DESCRIPTION
[0042] The present invention will be further described below with reference to the accompanying drawings.
[0043] Reference Figure 1 , a friend recommendation method for an online social platform based on enhanced contrast representation, comprising the following steps:
[0044] Step 1: Obtain user and user relationship information through online social platforms, and then use this information to build a social network G = (V, E, X), where V = {v1, v2, ..., v N} represents all users, E represents the relationship between users, N represents the number of users, X∈R N×dim Represents the user's attribute information, including age, education, gender and other attributes. The adjacency matrix of the social network is represented by A=[a ij ]∈R N×N Indicates that when users are friends with each other, ij =1, otherwise a ij = 0, the degree matrix of the social network is D = diag (d1, d2, ... d N ) indicates that d i =∑ j a ij , the negative network use of social networks Indicates that To randomly modify some edges of G, To randomly disrupt the attributes of some users;
[0045] Step 2: Use graph neural network to extract user representation of social network G. The network consists of a graph convolutional network GCN with a layer of l. The social user representation of the k-th layer GCN is:
[0046]
[0047] where k∈{1, .., l}, W k is the weight matrix of the kth layer, I is the unit matrix, h 0 =X, is the PRELU activation function; is the negative network Perform the same graph neural network operation to obtain the corresponding negative representations of social users at each layer
[0048] Step 3: Calculate the hierarchical contrast loss of social user representation in graph neural network.
[0049]
[0050] The contrast loss of the k-th layer is,
[0051]
[0052] where k∈{1, .., l}, W is the learnable weight matrix, is the matrix h k The i-th row vector of represents the characterization of the i-th user, is a matrix The i-th row vector of represents the negative representation of the i-th user; is the global network representation, σ is the sigmoid activation function;
[0053] Step 4: Calculate the topological loss of social user representation in the graph neural network.
[0054]
[0055] The topological loss of the kth layer is,
[0056]
[0057] where k∈{1, .., l}, is the topological representation of the kth layer, is the topological negative representation of the k-th layer, c k The i-th row vector of represents the topological representation of the i-th user, for The i-th row vector of represents the topological representation of the i-th user;
[0058] Step 5: Calculate the structural loss of social user representation in the graph neural network.
[0059]
[0060] The structural loss of the kth layer is,
[0061]
[0062] where k∈{1, .., l}, r k =h k (h k ) T is the predicted k-th layer network structure, is the predicted k-th layer negative network structure, is an indicator function, which has a value of 1 when the subscript condition is met, otherwise it is 0;
[0063] Step 6: Calculate the total loss function.
[0064] L = L1 + L2 + L3;
[0065] Step 7: Repeat steps 2 to 6. When L decreases to the specified threshold, the calculation ends. The final social user representation matrix is h = h 1 +h 2 +…+h l ;
[0066] Step 8: For any social user i, its user representation h i The vector represented by the i-th row of the social user representation matrix h is used to calculate the representation similarity scores between the social user and all other social users, and the K non-friends with the highest similarity scores are selected as the recommended friends of the user.
[0067] In this embodiment, for a certain social user, a representation of the social user is obtained. The representation comprehensively considers attribute information such as the user's age and gender, as well as multi-hop neighbor user information. By calculating the similarity between the representation and the representations of all other social users, the non-friend with the highest overall similarity is obtained as the final recommended friend.
[0068] The embodiments of this specification are merely examples of implementations of the invention and are provided for illustrative purposes only. The scope of protection of the present invention should not be considered limited to the specific embodiments described in these embodiments. The scope of protection of the present invention also extends to equivalent technical means that can be conceived by a person of ordinary skill in the art based on the invention.
Claims
1. A friend recommendation method for an online social platform based on enhanced contrast representation, characterized in that: First, a social network and a noise-perturbed negative social network are constructed for an online social platform. Next, a graph neural network is used to extract social user representations from the social network and the negative network. Hierarchical contrastive learning loss, topological loss, and structural loss are then calculated on the social user representations. Finally, the combined losses are combined to obtain the final total loss function, and personalized friend recommendations are implemented using the resulting social user representations. The method comprises the following steps: Step 1: Build a social network G between users of the online social platform. In the network G, the nodes in the network are defined as users. If two users follow each other in the online social platform, there is an edge between the users. Each user has attribute information; build a negative network The network is constructed by randomly modifying the order of some edges and attributes of the social network G; Step 2: Build a graph neural network, which consists of a l-layer graph convolutional network. The graph neural network is used to mine the social network G and the negative network respectively. The information in the corresponding k≤l layer representation h is obtained k and Step 3: Calculate the layer-wise contrastive learning loss of social user representation in the graph neural network. For the kth layer, calculate the global network representation g of the layer k , construct the discriminator β for similarity calculation, by maximizing β(g k ,h k ), minimize To achieve the contrastive learning loss construction of the k-th layer; Step 4: Calculate the topological loss of social user representation in the graph neural network. For the kth layer, construct the topological representation c k and topological negative representation Construct a discriminator γ for similarity calculation, by maximizing γ(g k ,c k ), minimize To achieve the topological loss construction of the kth layer; Step 5: Calculate the structural loss of social user representation in the graph neural network. For the kth layer, use matrix multiplication γ k =h k (h k ) T Get the predicted k-th layer network structure by maximizing the distance between user i and user j in the real social network value to achieve the social network structure loss of the kth layer, and do the same operation on the negative network to achieve the negative network structure loss of the kth layer; Step 6: Calculate the total loss function; Step 7: Repeat steps 2 to 6 to obtain the final social user representation matrix; Step 8: Calculate the representation similarity score to achieve personalized friend recommendations for the user.
2. The online social platform friend recommendation method based on enhanced contrast representation according to claim 1, characterized in that: In the step 1, the user and user relationship information is obtained through the online social platform, and then the social network G = (V, E, X) is constructed based on this information, where V = {v1, v2, ..., v N } represents all users, E represents the relationship between users, N represents the number of users, X∈R N×dim Represents the attribute information of users, with a total of dim attributes. The adjacency matrix of the social network is represented by A=[a ij ]∈R N ×N Indicates that when users are friends with each other, ij =1, otherwise a ij =0, the degree matrix of the social network is represented by D=diag(d1,d2,…d N ) indicates that d i =∑ j a ij , the negative network use of social networks Indicates that To randomly modify some edges of G, To randomly disrupt the attributes of some users; In the second step, a graph neural network is used to extract user representations of the social network G. The network consists of a graph convolutional network GCN with a layer of l. The social user representation of the k-th layer GCN is: where k∈{1,..,l}, W k is the weight matrix of the kth layer, I is the identity matrix, h 0 =X, is the PRELU activation function; is the negative network Perform the same graph neural network operation to obtain the corresponding negative representations of social users at each layer In step 3, the hierarchical contrast loss of social user representation in the graph neural network is calculated. The contrast loss of the k-th layer is, where k∈{1,..,l}, W is the learnable weight matrix, is the matrix h k The i-th row vector of represents the characterization of the i-th user, is a matrix The i-th row vector of represents the negative representation of the i-th user; is the global network representation, σ is the sigmoid activation function; In step 4, the topological loss of social user representation in the graph neural network is calculated. The topological loss of the kth layer is, where k∈{1,..,l}, is the topological representation of the kth layer, is the topological negative representation of the k-th layer, c k The i-th row vector of represents the topological representation of the i-th user, for The i-th row vector of represents the topological representation of the i-th user; In step 5, the structural loss of social user representation in the graph neural network is calculated. The structural loss of the kth layer is, where k∈{1,..,l}, r k =h k (h k ) T is the predicted k-th layer network structure, is the predicted k-th layer negative network structure, is an indicator function, which has a value of 1 when the subscript condition is met, otherwise it is 0; In step six, the total loss function is calculated. L = L1 + L2 + L3; In step 7, steps 2 to 6 are repeated. When L decreases to a specified threshold, the calculation is terminated. The final social user representation matrix is h = h 1 +h 2 +…+h l ; In step 8, for any social user i, its user representation h i The vector represented by the i-th row of the social user representation matrix h is used to calculate the representation similarity scores between the social user and all other social users, and the K non-friends with the highest similarity scores are selected as the recommended friends of the user.
Citation Information
Patent Citations
Social network service platform friend recommendation method based on global attention mechanism representation learning
CN112100514A
Recommendation method based on community perception and multi-scale graph comparative learning
CN119046541A