Friend account recommendation method, device, equipment, medium and program product

By constructing distance feature vectors between nodes and anchor nodes in graph data, the problem of not being able to capture node distance information in existing technologies is solved, thereby improving the accuracy of friend account recommendations and user experience.

CN122220604APending Publication Date: 2026-06-16TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-12-16
Publication Date
2026-06-16

Smart Images

  • Figure CN122220604A_ABST
    Figure CN122220604A_ABST
Patent Text Reader

Abstract

The application discloses a friend account recommendation method and device, equipment, medium and program product, and is applied to the field of artificial intelligence. The method comprises the following steps: acquiring graph data, the graph data comprising N nodes and edges between the N nodes, the edges being used for representing the friend relationship between the N nodes, each node in the N nodes being used for representing a user account, and N being greater than 1; constructing a representation feature vector of each node based on the distance between each node and at least one anchor node, the representation feature vector being used for mapping the distance information between the current node and the at least one anchor node, and the at least one anchor node being determined based on the friend relationship between at least part of the N nodes; and determining at least one recommended friend account of a current user account based on the representation feature vector of each node. The method can improve the accuracy of friend account recommendation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular to a method, apparatus, device, medium, and program product for recommending friend accounts. Background Technology

[0002] In social networks or games, friend account recommendations are based on a user's social circle, interests, and other information. These recommendations suggest other user accounts that the user might be interested in and recommend them as friends. The goal is to help the user quickly expand their social circle and meet more like-minded friends.

[0003] In related technologies, a node in graph data represents a user account, and the edges between nodes represent the friend relationships between user accounts. This paper employs a Graph Convolutional Network (GCN) model to capture the edge information between nodes and their neighboring nodes in the graph data, enabling friend account recommendations for user accounts.

[0004] However, the relevant technologies only consider the edge information between nodes and cannot capture the distance information between nodes, resulting in insufficient accuracy in recommending friend accounts. Summary of the Invention

[0005] This application provides a method, apparatus, device, medium, and program product for recommending friend accounts. The technical solution is as follows:

[0006] On the one hand, a method for recommending friend accounts is provided, the method including:

[0007] Obtain graph data, which includes N nodes and edges between the N nodes. The edges are used to represent the friend relationships between the N nodes, and each of the N nodes is used to represent a user account. The N is greater than 1.

[0008] Based on the distance between each node and at least one anchor node, a representation feature vector is constructed for each node. The representation feature vector is used to map the distance information between the current node and the at least one anchor node. The at least one anchor node is determined based on the friend relationships between at least a portion of the N nodes.

[0009] Based on the representation feature vector of each node, at least one recommended friend account of the current user account is determined.

[0010] On the other hand, a friend account recommendation device is provided, the device comprising:

[0011] The acquisition module is used to acquire graph data, which includes N nodes and edges between the N nodes. The edges are used to represent the friend relationships between the N nodes, and each of the N nodes is used to represent a user account. The N is greater than 1.

[0012] The processing module is used to construct a representation feature vector for each node based on the distance between each node and at least one anchor node. The representation feature vector is used to map the distance information between the current node and the at least one anchor node. The at least one anchor node is determined based on the friend relationships between at least a portion of the N nodes.

[0013] The recommendation module is used to determine at least one recommended friend account for the current user account based on the representation feature vector of each node.

[0014] On the other hand, a computer device is provided, the computer device comprising: a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the friend account recommendation method as described above.

[0015] On the other hand, a computer-readable storage medium is provided that stores a computer program, which is loaded and executed by a processor to implement the friend account recommendation method as described above.

[0016] On the other hand, a computer program product is provided, the computer program product including computer instructions stored in a computer-readable storage medium, wherein a processor retrieves the computer instructions from the computer-readable storage medium, causing the processor to load and execute them to implement the friend account recommendation method as described above.

[0017] The beneficial effects of the technical solutions provided in this application include at least the following:

[0018] Compared to related technologies that only consider edge information between nodes and fail to capture distance information, this solution maps each node to a feature vector based on the distance between each node in the graph data and at least one anchor node. This feature vector preserves the distance information between nodes in the graph data as much as possible. Furthermore, the at least one anchor node is determined based on the friend relationships between at least a subset of nodes in the graph data, ensuring high coverage of the at least one anchor node in the graph data and maximizing the reachability of each node to at least one anchor node, thus improving the accuracy of distance calculation between each node and at least one anchor node. Therefore, when performing friend account recommendations for the current user account based on the feature vector of each node, the accuracy of friend account recommendations can be improved. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a schematic diagram of graph data provided in an exemplary embodiment of this application;

[0021] Figure 2 This is a structural block diagram of a computer system provided in an exemplary embodiment of this application;

[0022] Figure 3 This is a schematic diagram of a friend account recommendation method provided in an exemplary embodiment of this application;

[0023] Figure 4 This is a flowchart of a friend account recommendation method provided in an exemplary embodiment of this application;

[0024] Figure 5 This is a schematic diagram illustrating the calculation of the distance encoding vector provided in an exemplary embodiment of this application;

[0025] Figure 6 This is a schematic diagram illustrating the construction of an anchor node set provided in an exemplary embodiment of this application;

[0026] Figure 7 This is an interface diagram of a friend account recommendation method provided in an exemplary embodiment of this application;

[0027] Figure 8 This is a block diagram of a friend account recommendation device provided in an exemplary embodiment of this application;

[0028] Figure 9 This is a structural block diagram of a computer device provided in an exemplary embodiment of this application. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0030] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0031] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0032] It should be understood that although the terms first, second, etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, a first parameter may also be referred to as a second parameter, and similarly, a second parameter may also be referred to as a first parameter. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0033] It should be noted that this application may display prompt interfaces, pop-ups, or output voice prompts before and during the collection of user-related data (e.g., user accounts, friend accounts, friend relationships, game data, etc.). These prompt interfaces, pop-ups, or voice prompts are used to inform the user that their relevant data is being collected. This ensures that the application only begins the steps related to collecting user-related data after receiving confirmation from the user regarding the prompt interface or pop-up; otherwise (i.e., without receiving confirmation from the user), the steps to collect user-related data end, meaning no user-related data is collected. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of relevant user data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0034] First, a brief introduction to the terms used in the embodiments of this application:

[0035] Graph data consists of nodes and edges between them. Nodes represent entities or objects, such as people, places, and products, while edges represent relationships between entities, such as social relationships and cooperative relationships.

[0036] The graph data is represented as G = (V, E). V is the set of nodes, and E is the set of edges. The set of nodes includes N nodes, and the set of edges includes edges between the N nodes. Any edge connects two nodes in the N nodes, where N is greater than 1. When a node is connected to another node through an edge, that other node can be called a neighbor node. The N nodes also include at least one anchor node, which is at least one node pre-selected from the graph data. Specifically, the anchor node selection method provided in the embodiments of this application can be used to determine it.

[0037] In this embodiment, the graph data includes N nodes and edges between them, where edges represent friend relationships between the N nodes. Each of the N nodes represents a user account, and N is greater than 1. User accounts can be logged into applications that provide friend account recommendation features, such as at least one of the following: game applications, chat applications, lifestyle service applications, video applications, entertainment applications, travel applications, social applications, and health applications. A node's neighboring nodes can also be called friend nodes.

[0038] Figure 1This is a schematic diagram of graph data provided in an exemplary embodiment of this application. The graph data includes 9 nodes, each node representing a user account, and an edge connecting two nodes indicates that the user accounts corresponding to these two nodes are friends. The 9 nodes are represented as follows: node v1, node v2, node v3, node v4, node v5, node v6, node v7, node v8, and node v9, corresponding to user account 1, user account 2, user account 3, user account 4, user account 5, user account 6, user account 7, user account 8, and user account 9, respectively. Edge 12 between node v1 and node v2 indicates that user account 1 and user account 2 are friends; edge 13 between node v1 and node v3 indicates that user account 1 and user account 3 are friends; edge 14 between node v1 and node v4 indicates that user account 1 and user account 4 are friends; edge 45 between node v4 and node v5 indicates that user account 4 and user account 5 are friends; edge 47 between node v4 and node v7 indicates that user account 4 and user account 7 are friends; edge 56 between node v5 and node v6 indicates that user account 5 and user account 6 are friends; edge 58 between node v5 and node v8 indicates that user account 5 and user account 8 are friends; edge 67 between node v6 and node v7 indicates that user account 6 and user account 7 are friends; edge 89 between node v8 and node v9 indicates that user account 8 and user account 9 are friends. The nine nodes include four anchor nodes: anchor node v1, anchor node v6, anchor node v8, and anchor node v4.

[0039] Node degree: refers to the number of neighboring nodes of a node, or the number of neighbors of a node.

[0040] refer to Figure 1 If node v1's neighbors are nodes v2, v3, and v4, then node v1 has a degree of 3. If node v3's neighbors are node v1, then node v3 has a degree of 1.

[0041] Shortest reachable path: Also known as the shortest path, it refers to the shortest reachable path among all reachable paths between two nodes. The reachability path between nodes is determined based on edges, and the path length is the number of edges.

[0042] refer to Figure 1 There are two reachable paths from node v1 to node v5. Reachable path 1 is: node v1 to node v4 to node v5, with a path length of 2; reachable path 2 is: node v1 to node v4 to node v7 to node v6 to node v5, with a path length of 4. Reachable path 1 can be considered the shortest reachable path from node v1 to node v5. (Continue to refer to...) Figure 1There are two reachable paths from node v1 to node v6. Reachable path 1 is: node v1 to node v4 to node v5 to node v6, with a path length of 3. Reachable path 2 is: node v1 to node v4 to node v7 to node v6, with a path length of 3. Both of these reachable paths can be considered as the shortest reachable paths from node v1 to node v6.

[0043] Distance: Also known as node distance, it refers to the path length of the shortest reachable path between two nodes. The distance between node v and node u is expressed as: d v,u .

[0044] refer to Figure 1 The shortest reachable path length from node v1 to node v5 is 2, meaning the distance between node v1 and node v5 is 2. The shortest reachable path length from node v1 to node v6 is 3, meaning the distance between node v1 and node v6 is 3.

[0045] Friend order: This can be understood as the distance between two nodes in the graph data of this embodiment, denoted as t. A node's friend of order t refers to other nodes that are at a distance of friend order t from that node. For example, if node v is a friend of order t from node u, then the distance from node v to node u is t.

[0046] refer to Figure 1 When the friend order t is 1, the first-order friends of node v1 are: nodes v3, v2, and v4. The first-order friends of node v4 are: nodes v1, v5, and v7. When the friend order t is 2, the second-order friends of node v1 are: nodes v5 and v7. The second-order friends of node v4 are: nodes v3, v2, v6, and v8.

[0047] Graph Neural Network Model: This refers to the distance-encoding-based self-supervised graph neural network model provided in this application embodiment, or simply the graph neural network model. The graph neural network model can map each node of graph data to a fixed-length representation feature vector, which can preserve the distance information between nodes in the graph data as much as possible.

[0048] Figure 2 This is a structural block diagram of a computer system provided in an exemplary embodiment of this application. The computer system 100 can implement a system architecture for a friend account recommendation method. The computer system 100 includes a terminal 120 and a server 140.

[0049] Terminal 120 can be an electronic device such as a mobile phone, tablet computer, in-vehicle terminal (vehicle system), wearable device, PC (Personal Computer), or unmanned reservation terminal. A client application for the target application can be installed and run on terminal 120. Optionally, the target application can be an application that provides a friend account recommendation function for user accounts, such as at least one of the following: game application, chat application, lifestyle service application, video application, entertainment application, travel application, social application, and health application. The game can be any of the following: battle royale shooting game, virtual reality (VR) client, augmented reality (AR) program, 3D mapping program, virtual reality game, augmented reality game, first-person shooter (FPS) game, third-person shooter (TPS) game, multiplayer online battle arena (MOBA) game, strategy game (SLG), or party game. Alternatively, terminal 120 may store a graph neural network model. The target application may also be an application that provides training and / or usage functions for the graph neural network model; this application embodiment does not limit this. Furthermore, this application embodiment does not limit the form of the target application, including but not limited to Apps (Applications), mini-programs, etc., installed on terminal 120, and may also be in web page form.

[0050] Server 140 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud servers, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Server 140 can be a backend server for the aforementioned target application, providing backend services to the client of the target application. In an optional example, server 140 can also be implemented as a node in a blockchain system. Optionally, server 140 stores graph neural network models. Server 140 also provides training and / or usage functions for the graph neural network models.

[0051] Terminal 120 and server 140 can communicate via a network, such as a wired or wireless network.

[0052] The friend account recommendation method provided in this application embodiment can be executed by a computer device, which refers to an electronic device with data computing, processing, and storage capabilities. Figure 2 Taking the implementation environment of the scheme shown as an example, the friend account recommendation method can be executed by the terminal 120. For example, the client of the target application installed and running in the terminal 120 can execute the friend account recommendation method, or the server 140 can execute the friend account recommendation method, or the terminal 120 and the server 140 can interact and cooperate to execute it. This application embodiment does not limit this.

[0053] Those skilled in the art will understand that the number of terminals 120 can be more or less. For example, there may be only one terminal 120, or there may be dozens or hundreds of terminals 120, or more. The embodiments of this application do not limit the number of terminals 120 or the type of device.

[0054] In social networks or games, friend account recommendations are based on a user's social circle, interests, and other information. These recommendations suggest other user accounts that the user might be interested in and recommend them as friends. The goal is to help the user quickly expand their social circle and meet more like-minded friends.

[0055] In related technologies, a node in graph data represents a user account, and the edges between nodes represent the friend relationships between user accounts. A Graph Convolutional Network (GCN) model is used to capture the edge information between nodes and their neighbors in the graph data to achieve friend account recommendations. Specifically, the GCN model uses aggregation and propagation operations on neighbor nodes to make the node's feature vector describe the edge information. The training samples of the GCN model are any two nodes in the graph data; if there is an edge between these two nodes, the training sample is a positive sample; otherwise, it is a negative sample. However, related technologies only consider the edge information between nodes and cannot capture the distance information between nodes, especially the distance information between distant nodes. The node feature vectors generated by the GCN model cannot describe the distance between nodes, resulting in insufficient accuracy in friend account recommendations.

[0056] Based on this, this application provides a method for recommending friend accounts, which can map nodes of graph data to fixed-length representation feature vectors. These representation feature vectors can preserve the distance information between nodes in the graph data as much as possible. When performing friend account recommendations based on these representation feature vectors, the accuracy of friend account recommendations can be improved.

[0057] Figure 3 This is a schematic diagram of a friend account recommendation method provided in an exemplary embodiment of this application. The method is executed by a computer device, which may be... Figure 2 The terminal 120 and / or server 140 are shown. The steps of this method are briefly described below:

[0058] Step 1: Obtain graph data. The graph data includes N nodes and the edges between the N nodes. The edges are used to represent the friend relationships between the N nodes. Each of the N nodes is used to represent a user account, and N is greater than 1.

[0059] refer to Figure 3 As shown in (1), the graph data includes 9 nodes, each representing a user account. An edge connecting two nodes indicates that the user accounts corresponding to these two nodes are friends. The 9 nodes are represented as follows: node v1, node v2, node v3, node v4, node v5, node v6, node v7, node v8, and node v9, corresponding to user account 1, user account 2, user account 3, user account 4, user account 5, user account 6, user account 7, user account 8, and user account 9, respectively. Edge 12 between node v1 and node v2 indicates that user account 1 and user account 2 are friends; edge 13 between node v1 and node v3 indicates that user account 1 and user account 3 are friends; edge 14 between node v1 and node v4 indicates that user account 1 and user account 4 are friends; edge 45 between node v4 and node v5 indicates that user account 4 and user account 5 are friends; edge 47 between node v4 and node v7 indicates that user account 4 and user account 7 are friends; edge 56 between node v5 and node v6 indicates that user account 5 and user account 6 are friends; edge 58 between node v5 and node v8 indicates that user account 5 and user account 8 are friends; edge 67 between node v6 and node v7 indicates that user account 6 and user account 7 are friends; edge 89 between node v8 and node v9 indicates that user account 8 and user account 9 are friends.

[0060] Step 2: Based on the distance between each node and at least one anchor node, construct a representation feature vector for each node. The representation feature vector is used to map the distance information between the current node and at least one anchor node. At least one anchor node is determined based on the friendship relationship between at least a portion of the N nodes.

[0061] refer to Figure 3 As shown in (1), the nine nodes include four anchor nodes: anchor node v1, anchor node v6, anchor node v8, and anchor node v4. (Continue to refer to...) Figure 3As shown in (2) in the figure, based on the distance between each node and each anchor node, the representation feature vector of each node can be obtained by mapping through the graph neural network model.

[0062] Step 3: Based on the representation feature vector of each node, determine at least one recommended friend account for the current user account.

[0063] refer to Figure 3 As shown in (3) above, the similarity or vector distance between the representation feature vectors of the node where the current user account is located and at least one other node can be determined based on the representation feature vector of each node, thereby determining at least one recommended friend account for the current user account. See the following examples for detailed examples.

[0064] Next, the friend account recommendation method provided in the embodiments of this application will be described:

[0065] Figure 4 This is a flowchart illustrating a friend account recommendation method provided in an exemplary embodiment of this application. The method is executed by a computer device, which may be... Figure 2 The terminal 120 and / or server 140 are shown. The method includes at least a portion of steps 220, 240, and 260:

[0066] Step 220: Obtain graph data. The graph data includes N nodes and edges between the N nodes. The edges are used to represent the friend relationships between the N nodes. Each of the N nodes is used to represent a user account, and N is greater than 1.

[0067] Graph data is determined based on user accounts and the friend relationships between them. When two user accounts are friends, it means that the two user accounts have added each other as friends. User accounts and their friend relationships can be pre-built, obtained from public databases or datasets, or obtained with the user accounts' consent.

[0068] The computer device acquires graph data, which includes N nodes and N edges connecting them. The edges represent the friend relationships between the N nodes. Each of the N nodes represents a user account, where N is greater than 1. Each node can be represented by a node identifier, which includes at least one of the following: numbers, letters, and symbols. Two user accounts connected by an edge are friends. For example, the graph data includes nodes v1 and v2, corresponding to user account 1 and user account 2, respectively. Node v1 and node v2 are connected by edge 12, therefore user account 1 and user account 2 are friends and have added each other as friends.

[0069] In some embodiments, graph data is represented as: G = (V, E). V is the set of nodes, and E is the set of edges. The set of nodes includes N nodes, and the set of edges includes edges between N nodes. Any edge connects two nodes in the N nodes, where N is greater than 1.

[0070] Step 240: Based on the distance between each node and at least one anchor node, construct a representation feature vector for each node. The representation feature vector is used to map the distance information between the current node and at least one anchor node. The at least one anchor node is determined based on the friend relationship between at least a portion of the N nodes.

[0071] At least one anchor node is selected from N nodes in the graph data. Optionally, at least one anchor node can be one or more anchor nodes from k anchor nodes, or it can be each of the k anchor nodes, where k is greater than 0 and less than or equal to N.

[0072] In some embodiments, the selection of at least one anchor node includes: Method 1, which is random selection, for example, randomly selecting at least one anchor node from N nodes; Method 2, which is selection based on node degree. For example, selecting nodes with a degree greater than a degree threshold from N nodes as anchor nodes. The degree threshold can be set according to actual technical needs, for example, the degree threshold is set to 10.

[0073] For methods 1 and 2, the following situations may exist: Some of the N nodes have no reachable path to any of the at least one anchor node. Alternatively, some of the N nodes have no reachable path to some of the at least one anchor node.

[0074] In this embodiment, at least one anchor node is determined based on the coverage of at least a subset of the N nodes in the graph data. The coverage of a node among the at least a subset of nodes is related to at least one of the following factors: whether there is a reachable path between the node and other nodes, the number of existing reachable paths, and the number of other nodes reachable through these reachable paths. Since reachable paths between nodes are determined based on edges, it can also be understood that at least one anchor node is determined based on the friendship relationships between at least a subset of the N nodes. Here, the at least a subset of nodes can be each of the N nodes or a subset of the N nodes. The selection method for at least one anchor node will be described in detail in the embodiments below.

[0075] Distance, also known as node distance, refers to the path length of the shortest reachable path between two nodes. Optionally, the computer device calculates the distance between each node and at least one anchor node. Based on the distance between each node and at least one anchor node, a representation feature vector is constructed for each node. The representation feature vector is used to map the distance information between the current node and at least one anchor node. The distance information may include at least one of the following: the specific numerical value of the distance, the edges involved in the distance, and the nodes connected by the edges. This representation feature vector can preserve the distance information between nodes in the graph data as much as possible, improving the accuracy of the feature representation of nodes.

[0076] In some embodiments, a graph neural network model, also known as a self-supervised graph neural network model, is pre-trained. A computer device stores the graph neural network model and, using this model, constructs a representation feature vector for each node based on the distance between each node and at least one anchor node. Types of graph neural network models include at least one of the following: Graph Convolutional Networks (GCN), Graph Auto-encoder (GAE), Graph Attention Networks (GAT), and Graph Generative Networks (GGN). The computational steps and training methods for graph neural network models will be described in detail in the embodiments below.

[0077] Step 260: Based on the representation feature vector of each node, determine at least one recommended friend account for the current user account.

[0078] At least one recommended friend account is at least one other user account recommended for the current user account, at least one other user account that is a candidate to become a friend of the current user account, and at least one other user account that the current user account may be interested in.

[0079] At least one recommended friend account can be calculated based on vector distance or cosine similarity. Optionally, the computer device determines at least one recommended friend account for the current user account based on the vector distance or similarity between the representation feature vectors of each node. Specifically, the similarity or vector distance between the representation feature vectors of the node containing the current user account and at least one other node is determined to identify at least one recommended friend account for the current user account.

[0080] In some embodiments, the computer device may also display a list of recommended friend accounts, showing at least one recommended friend account for the current user account. This allows the user corresponding to the current user account to visually see at least one recommended friend account, facilitating the addition of friends.

[0081] In summary, the friend account recommendation method provided in this application involves a computer device acquiring graph data, which includes N nodes and edges between them. The edges represent the friend relationships between the N nodes, and each of the N nodes represents a user account, where N is greater than 1. Based on the distance between each node and at least one anchor node, a representation feature vector is constructed for each node. This representation feature vector maps the distance information between the current node and at least one anchor node, where at least one anchor node is determined based on the friend relationships between at least a subset of the N nodes. Based on the representation feature vector of each node, at least one recommended friend account for the current user account is determined. Therefore, compared to related technologies that only consider edge information between nodes and fail to capture distance information, this solution, based on the distance between each node in the graph data and at least one anchor node, can map each node to a representation feature vector, which can retain as much of the distance information between nodes in the graph data as possible. Furthermore, at least one anchor node is determined based on the friend relationships between at least a subset of nodes in the graph data. This ensures that at least one anchor node has the highest possible coverage in the graph data and maximizes the reachability of each node to at least one anchor node, thereby improving the accuracy of distance calculation between each node and at least one anchor node. Consequently, when performing friend account recommendations based on the feature vector of each node for the current user account, the accuracy of friend account recommendations can be improved. This also enhances the user experience when the current user account uses the friend account recommendation function, thereby increasing user retention.

[0082] • Represents the calculation of eigenvectors:

[0083] In some embodiments, step 240 is specifically implemented as steps 300 and 400:

[0084] Step 300: Based on the distance between each node and at least one anchor node, determine the distance encoding vector for each node. The distance encoding vector is used to indicate the distance between the current node and at least one anchor node.

[0085] Step 400: Map the distance encoding vector of each node to the representation feature vector of each node.

[0086] When the location of each of the N nodes in a graph data, and at least one anchor node, is determined, the distance between each node and at least one anchor node is also determined. The distance between a node and an anchor node is the path length of the shortest reachable path from that node to that anchor node. Feature mapping is used to map the distance encoding vector to a feature vector. The distance encoding vector and the feature vector have the same length.

[0087] The computer device determines a distance encoding vector for each node based on the distance between each node and at least one anchor node. The specific values ​​of the elements in the distance encoding vector are the specific distance values, and the number of elements is the same as the number of anchor nodes in the at least one anchor node. For a node's distance encoding vector, one element in the distance encoding vector represents the distance between that node and one of the at least one anchor nodes. The distance encoding vector of each node is mapped to the representation feature vector of each node.

[0088] In this embodiment, the computer device first calculates the distance encoding vector of each node, and then maps the distance encoding vector to a feature vector, which can improve the accuracy of the feature vector and is beneficial to improving the accuracy of subsequent friend account recommendations for the current user account.

[0089] In some embodiments, the computer device stores the trained graph neural network model and can perform mapping based on the trained graph neural network model. Optionally, step 400 is specifically implemented as step 420:

[0090] Step 420: Using the trained graph neural network model, the distance encoding vector of each node is mapped to the representation feature vector of each node; wherein, the graph neural network model is used to capture the distance information represented by the distance encoding vector of each node.

[0091] For example, a computer device uses a trained graph neural network model to map the distance encoding vector of each node to the representation feature vector of each node. The input data of the graph neural network model is the distance encoding vector of each node, and the output data is the representation feature vector of each node. This graph neural network model is also called a distance-encoding-based self-supervised graph neural network model. The graph neural network model is used to capture the distance information represented by the distance encoding vector of each node, so that the representation feature vector of each node retains as much distance information between nodes in the graph data as possible.

[0092] This embodiment provides a graph neural network model. Through this graph neural network model, the computer device can map the distance encoding vector of each node into a feature vector, thereby improving the accuracy of the feature vector representation and thus improving the accuracy of subsequent friend account recommendations for the current user account.

[0093] In some embodiments, the graph neural network model includes learning parameters, bias parameters, and an activation function. The activation function type includes one of the following: a sigmoid function, a hyperbolic tangent function, and a ReLU function. Optionally, step 420 is specifically implemented as step 422:

[0094] Step 422: Multiply the distance encoding vector of each node by the learning parameters to obtain the product result; add the product result to the bias parameters to obtain the addition result; based on the activation function mapping addition result, obtain the representation feature vector of each node.

[0095] The computer device uses the trained graph neural network model to multiply the distance encoding vector of each node by the learned parameters to obtain a product; it then adds the product to the bias parameters to obtain an addition result; based on the activation function mapping the addition result, it obtains the representation feature vector of each node. In this embodiment, the activation function can be the Sigmoid function.

[0096] In some embodiments, the aforementioned calculation steps may be performed on each element in the distance encoding vector of each node, where each element has corresponding learning parameters and a bias function. For each element in the distance encoding vector of each node, the element is multiplied by the learning parameter corresponding to the element to obtain the product result; the product result is added to the bias parameter corresponding to the element to obtain the addition result; the addition result is mapped based on the activation function to obtain the mapped addition result; the mapped addition results corresponding to each element are combined to obtain the representation feature vector of each node.

[0097] In one example, the graph neural network model encodes the distance vector E for each node v. v The mapping is represented by the feature vector F. v Distance encoding vector E v The length of is k, representing the feature vector F. v The length of is also k. This represents the eigenvector F. v The i-th element F v,i Through the distance encoding vector E v The linear transformation yields, expressed as:

[0098] F v,i =σ(W i ·E v +b i )

[0099] Among them, W i b is a learning parameter of length k. i This is the bias parameter. σ is the sigmoid function, expressed as:

[0100]

[0101] In this embodiment, a graph neural network model is provided to transform distance encoding vectors into feature vectors. The model parameters in the graph neural network model are all obtained through training. This graph neural network model can effectively capture the distance information represented by the distance encoding vectors of different nodes, thereby improving the accuracy of the feature vector representation.

[0102] • Calculation of distance encoding vector:

[0103] In some embodiments, at least one anchor node refers to each of the k anchor nodes in the set of anchor nodes. Where k is greater than 0 and less than or equal to N. That is, k is greater than or equal to 1 and less than or equal to N. Step 300 is specifically implemented as step 320:

[0104] Step 320: Determine the distance encoding vector for each node based on the distance between each node and each of the k anchor nodes in the set of anchor nodes; wherein the distance encoding vector includes k elements, one of the k elements is used to indicate the distance between the current node and one of the k anchor nodes; k is greater than 0 and less than or equal to N.

[0105] The set of anchor nodes consists of k anchor nodes. Optionally, an anchor node set M of size k is constructed, where k ≤ |V|. That is, the size of the anchor node set M is |M| = k, and the anchor node set M is a subset of the node set V of the graph data G, represented as: The node set V of the graph data G includes N nodes, where k is greater than 0 and less than or equal to N.

[0106] The computer device determines a distance encoding vector for each node based on the distance between each node and each of the k anchor nodes in the set of anchor nodes; wherein the distance encoding vector includes k elements, one of which indicates the distance between the current node and one of the k anchor nodes.

[0107] In this embodiment, the computer device determines the distance encoding vector of each node based on the distance between each node and each of the k anchor nodes in the anchor node set, which can improve the calculation accuracy of the distance encoding vector of each node. It should also be noted that when k is 1, the distance encoding vector of each node contains 1 element, and the distance encoding vector of each node is regarded as a one-dimensional vector.

[0108] Figure 5 This is a schematic diagram illustrating the calculation of the distance encoding vector provided in an exemplary embodiment of this application.

[0109] refer to Figure 5 As shown in (1), the graph data includes 9 nodes, each representing a user account. An edge connecting two nodes indicates that the user accounts corresponding to these two nodes are friends. The 9 nodes are represented as follows: node v1, node v2, node v3, node v4, node v5, node v6, node v7, node v8, and node v9, corresponding to user accounts 1, 2, 3, 4, 5, 6, 7, 8, and 9, respectively. Among the 9 nodes, there are 4 anchor nodes: anchor node v1, anchor node v6, anchor node v8, and anchor node v4. (Reference) Figure 5 As shown in (2) of the table, each row represents the distance encoding vector of a node. The graph data has four anchor nodes, and the distance encoding vector of each node includes four elements, one of which indicates the distance between that node and an anchor node. These distances and the shortest reachable path are represented as follows:

[0110] The distance from node v1 to anchor node v1 is 0; the distance from node v1 to anchor node v6 is 3, and the shortest reachable path is from node v1 to node v4 to node v7 to node v6, or from node v1 to node v4 to node v5 to node v6; the distance from node v1 to anchor node v8 is 3, and the shortest reachable path is from node v1 to node v4 to node v5 to node v8; the distance from node v1 to anchor node v4 is 1.

[0111] The distance from node v2 to anchor node v1 is 1; the distance from node v2 to anchor node v6 is 4, and the shortest reachable path is from node v2 to node v1 to node v4 to node v7 to node v6, or from node v2 to node v1 to node v4 to node v5 to node v6; the distance from node v2 to anchor node v8 is 4, and the shortest reachable path is from node v2 to node v1 to node v4 to node v5 to node v8; the distance from node v2 to anchor node v4 is 2, and the shortest reachable path is from node v2 to node v1 to node v4.

[0112] The distance from node v3 to anchor node v1 is 1; the distance from node v3 to anchor node v6 is 4, and the shortest reachable path is from node v3 to node v1 to node v4 to node v7 to node v6, or from node v3 to node v1 to node v4 to node v5 to node v6; the distance from node v3 to anchor node v8 is 4, and the shortest reachable path is from node v3 to node v1 to node v4 to node v5 to node v8; the distance from node v3 to anchor node v4 is 2, and the shortest reachable path is from node v3 to node v1 to node v4.

[0113] The distance from node v4 to anchor node v1 is 1; the distance from node v4 to anchor node v6 is 2, and the shortest reachable path is from node v4 to node v5 to node v6, or from node v4 to node v7 to node v6; the distance from node v4 to anchor node v8 is 2, and the shortest reachable path is from node v4 to node v5 to node v8; the distance from node v4 to anchor node v4 is 0.

[0114] The distance from node v5 to anchor node v1 is 2, and the shortest reachable path is from node v5 to node v4 to node v1; the distance from node v5 to anchor node v6 is 1; the distance from node v5 to anchor node v8 is 1; the distance from node v5 to anchor node v4 is 1.

[0115] The distance from node v6 to anchor node v1 is 3, and the shortest reachable path is from node v6 to node v7 to node v4 to node v1, or from node v6 to node v5 to node v4 to node v1; the distance from node v6 to anchor node v6 is 0; the distance from node v6 to anchor node v8 is 2, and the shortest reachable path is from node v6 to node v5 to node v8; the distance from node v6 to anchor node v4 is 2, and the shortest reachable path is from node v6 to node v5 to node v4, or from node v6 to node v7 to node v4.

[0116] The distance from node v7 to anchor node v1 is 2, and the shortest reachable path is from node v7 to node v4 to node v1; the distance from node v7 to anchor node v6 is 1; the distance from node v7 to anchor node v8 is 3, and the shortest reachable path is from node v7 to node v6 to node v5 to node v8, or from node v7 to node v4 to node v5 to node v8; the distance from node v7 to anchor node v4 is 1.

[0117] The distance from node v8 to anchor node v1 is 3, and the shortest reachable path is from node v8 to node v5 to node v4 to node v1; the distance from node v8 to anchor node v6 is 2, and the shortest reachable path is from node v8 to node v5 to node v6; the distance from node v8 to anchor node v8 is 0; the distance from node v8 to anchor node v4 is 2, and the shortest reachable path is from node v8 to node v5 to node v4.

[0118] The distance from node v9 to anchor node v1 is 4, and the shortest reachable path is from node v9 to node v8 to node v5 to node v4 to node v1; the distance from node v9 to anchor node v6 is 3, and the shortest reachable path is from node v9 to node v8 to node v5 to node v6; the distance from node v9 to anchor node v8 is 1; the distance from node v9 to anchor node v4 is 3, and the shortest reachable path is from node v9 to node v8 to node v5 to node v4.

[0119] This embodiment also provides the following traversal method to construct the distance encoding vector: Specifically, step 320 includes the following steps 321, 322, 323, 324, 325, 326, 327, and 328. Step 321 is an initialization operation, which includes steps 3211, 3212, 3213, 3214, and 3215 in sequence:

[0120] Step 321, perform the following initialization operations in sequence:

[0121] Step 3211: Initialize the elements in the distance encoding vector of each node to initial values;

[0122] Optionally, the initial value is set to 0. For each node u in the graph data G, a distance encoding vector E of length k is initialized, with all initial values ​​being 0. u For any 1 ≤ i ≤ k, there exists E u,i =0.

[0123] Step 3212: Initialize the anchor node traversal identifier i when traversing k anchor nodes;

[0124] Optionally, i = 1 is initialized, indicating that the traversal starts from the first anchor node among the k anchor nodes.

[0125] Step 3213, initialize the distance variable d;

[0126] Optionally, d = 1 during initialization, indicating that each node is traversed layer by layer starting from a distance of 1.

[0127] Step 3214: Initialize the first set of nodes that have been visited;

[0128] Optionally, the first node set is represented as: V visited ={v i The first set of nodes that has been visited initially is the i-th anchor node.

[0129] Step 3215: Initialize the second node set of the currently visited node;

[0130] Alternatively, the second node set is represented as: V current ={v i The initial currently visited node in the second node set is the i-th anchor node.

[0131] Step 322: Calculate the first friend set corresponding to the second node set when the friend order is d;

[0132] Optionally, the friend nodes in the first friend set are composed of other nodes in the second node set that are at a distance of d from each node. Specifically, for each node in the second node set, other nodes at a distance of d from that node are considered its friend nodes, and the friend nodes of each node in the second node set form the first friend set. When d = 1, the first friend set is represented as:

[0133]

[0134] Step 323: Take the unvisited nodes in the first friend set as the second friend set;

[0135] Optionally, the second friend set consists of unvisited nodes from the first friend set. Specifically, visited nodes are removed from the first friend set to obtain the second friend set. The second friend set is represented as: V tmp2 =V tmp1 / V visited .

[0136] Step 324: Set the distance from each node in the second friend set to the i-th anchor node as d;

[0137] Set a second friend set V tmp2 The distance from each node u to the i-th anchor node is d, denoted as: E u,i =d. If a return step 322 occurs subsequently, in step 324 executed upon return, the distance from each node in the second friend set to the i-th anchor node is set to the sum of d and the number of returns, where the number of returns is the number of executions minus 1. For example, in the second execution of step 324, i.e., the number of returns is 1, the distance from each node in the second friend set to the i-th anchor node is set to d+1.

[0138] Step 325: Merge the second friend set with the first node set to update the first node set;

[0139] Optionally, the second friend set is merged with the first node set; that is, each node in the second friend set is added to the first node set corresponding to the visited nodes to update the first node set, represented as: V visited =V visited ∪V tmp2 .

[0140] Step 326: Use the second set of friends as the second set of nodes to update the second set of nodes;

[0141] Optionally, update the second friend set corresponding to the currently visited node, that is, update the second node set V. currentFor the second friend set V tmp2 , represented as: V current =V tmp2 .

[0142] Step 327: If the updated second node set is not empty, return to the step of calculating the first friend set corresponding to the second node set when the friend order is d, and set the distance from each node in the second friend set to the i-th anchor node to the sum of d and the number of returns; otherwise, if the updated second node set is empty, update i to i+1.

[0143] Optionally, when the updated set of second nodes V current If the value is not empty, proceed to step 322 and set the distance to the sum of d and the number of returns when returning to step 324. Otherwise, update the anchor node traversal flag to i = i + 1 and continue to step 328.

[0144] Step 328: If the updated i is less than or equal to k, return to the step of initializing the distance variable d and update d to d+1; otherwise, if the updated i is greater than k, determine that all k anchor nodes have been traversed and obtain the distance encoding vector of each node.

[0145] Optionally, if i ≤ k, proceed to step 3213 and update d to d+1 to continue execution; if i > k, it means that all anchor nodes have been traversed, and the distance encoding vector E of each node u is output. u .

[0146] In this embodiment, a step of constructing the distance encoding vector by traversal is provided, which can ensure that each node and each of the k anchor nodes in the anchor node set are traversed, thereby improving the accuracy of the distance encoding vector of each node.

[0147] As an example, see reference Figure 5 As shown in (1), the graph data includes 9 nodes, each representing a user account. An edge connecting two nodes indicates that the user accounts corresponding to these two nodes are friends. The 9 nodes are represented as follows: node v1, node v2, node v3, node v4, node v5, node v6, node v7, node v8, and node v9, corresponding to user account 1, user account 2, user account 3, user account 4, user account 5, user account 6, user account 7, user account 8, and user account 9, respectively. Among the 9 nodes, there are 4 anchor nodes, namely: anchor node v1, anchor node v6, anchor node v8, and anchor node v4. The steps for constructing the distance encoding vector are briefly described as follows:

[0148] (1) Initialize the elements in the distance encoding vector of each of the 9 nodes of the graph data to 0;

[0149] (2) Initialize the anchor node traversal flag i = 1, and start traversing from the first anchor node v1;

[0150] (3) Initialize the distance variable d = 1;

[0151] (4) Initialize the first set of visited nodes V. visited ={v1};

[0152] (5) Initialize the second node set V of the currently visited node. current ={v1};

[0153] (6) Calculate the second node set V current ={v1} is the first set of friends when the friend order is d=1.

[0154] (7) Take the unvisited nodes in the first friend set as the second friend set V. tmp2 =V tmp1 / V visited ={v2,v3,v4};

[0155] (8) Set a second friend set V tmp2 For each node: node v2, node v3, and node v4, the distance from the first anchor node v1 is d = 1. (Refer to...) Figure 5 In (2), the distance from node v2, node v3, and node v4 to the first anchor node v1 is 1;

[0156] (9) Set the second friend group V tmp2 Each node: node v2, node v3, node v4 is added to the first node set V. visited ={v1,v2,v3,v4};

[0157] (10) Update the set of the second node currently visited V current For the second friend set V tmp2 The second node set V current =V tmp2 ={v2,v3,v4};

[0158] (11) At this time, the second node set V current ={v2,v3,v4} is not empty, return (6) on the first attempt;

[0159] (6-1) Calculate the second node set V current ={v2,v3,v4} is the first set of friends corresponding to the friend order d=1.

[0160] (7-1) Take the unvisited nodes in the first friend set as the second friend set V. tmp2 =V tmp1 / V visited ={v5,v7};

[0161] (8-1) Set the second friend set V tmp2 For each node: node v5 and node v7, the distance to the first anchor node v1 is d+1 = 2. (Refer to...) Figure 5 The distance from node v5 and node v7 to the first anchor node v1 shown in (2) is 2;

[0162] (9-1) Set the second friend group V tmp2 Each node: node v5, node v7 are added to the first node set V. visited ={v1,v2,v3,v4,v5,v7};

[0163] (10-1) Update the set of the second node currently visited, V. current For the second friend set V tmp2 The second node set V current =V tmp2 ={v5,v7};

[0164] (11-1) At this time, the second node set V current ={v5,v7} is not empty, return (6) for the second time;

[0165] (6-2) Calculate the second node set V curr5nt ={v5,v7} is the first set of friends when the friend order is d=1.

[0166] (7-2) Take the unvisited nodes in the first friend set as the second friend set V. tmp2 =V tmp1 / V visited ={v6,v8};

[0167] (8-2) Set the second friend set V tmp2 For each node: node v6 and node v8, the distance to the first anchor node v1 is d+2=3, refer to... Figure 5 The distance from node v6 and node v8 to the first anchor node v1 shown in (2) is 3;

[0168] (9-2) Set the second friend group V tmp2 Each node: node v6, node v8 are added to the first node set V. visited={v1,v2,v3,v4,v5,v6,v7,v8};

[0169] (10-2) Update the set of the second node currently visited, V. current For the second friend set V tmp2 The second node set V current =V tmp2 ={v6,v8};

[0170] (11-2) At this time, the second node set V current =={v6,v8} is not empty, return (6) on the 3rd time;

[0171] (6-3) Calculate the second node set V current ={v6,v8} is the first set of friends when the friend order is d=1.

[0172] (7-3) Take the unvisited nodes in the first friend set as the second friend set V. tmp2 =V tmp1 / V visited ={v9};

[0173] (8-3) Set the second friend set V tmp2 For each node: the distance from node v9 to the first anchor node v1 is d+3=4, refer to... Figure 5 The distance from node v9 to the first anchor node v1 shown in (2) is 4;

[0174] (9-3) Set the second friend group V tmp2 Each node: Node v9 is added to the first node set V visited ={v1,v2,v3,v4,v5,v6,v7,v8,v9};

[0175] (10-3) Update the set of the second node currently visited, V. current For the second friend set V tmp2 The second node set V current =V tmp2 ={v9};

[0176] (11-3) At this time, the second node set V current If not empty, return 4 times (6);

[0177] (6-4) Calculate the second node set V current ={v9} is the first set of friends when the friend order is d=1.

[0178] (7-4) Take the unvisited nodes in the first friend set as the second friend set. At this time, the second friend set is empty, so the updated second node set is empty; then continue to execute (12);

[0179] (12) Update i to i+1=2. At this time, i=2 is less than or equal to k=4, indicating that the 4 anchor nodes have not been traversed. Continue traversing from the 2nd anchor node v6. Then, start from the step of initializing the distance variable d=1 in (3) and continue to execute downwards until the distance between each node and the 2nd anchor node v6 is obtained. Iterate in this way until all 4 anchor nodes have been traversed and the distance is obtained. Figure 5 Each row in (2) indicates the distance encoding vector for each node.

[0180] In some embodiments, before the computer device determines the distance encoding vector of each node based on the distance between each node and each of the k anchor nodes in the anchor node set, it needs to ensure the arrangement order of the k anchor nodes in the anchor node set, so that the elements at the same position in the distance encoding vector of each node represent the distance between each node and the same anchor node, thus ensuring the comparability of the distance encoding vectors of different nodes. For example, before step 3211, step 3210 is also included:

[0181] Step 3210: Sort the k anchor nodes in the anchor node set; wherein the sorting method includes sorting by node identifier, random sorting, or sorting by the order in which they were added to the anchor node set.

[0182] Optionally, the computer device sorts the k anchor nodes in the anchor node set; wherein the sorting method includes sorting by node identifier, random sorting, or sorting according to the order in which they were added to the anchor node set. For example, refer to Figure 5 As shown in (2), the four anchor nodes are ordered according to the order in which they were added to the anchor node set. In this embodiment, it is ensured that the order of the k anchor nodes in the traversed anchor node set remains unchanged when calculating the distance encoding vector of each node, thereby ensuring the comparability of the distance encoding vectors of each anchor node.

[0183] In this embodiment, the computer device pre-sorts the k anchor nodes in the anchor node set, which ensures that the anchor node set has a definite order, making the distance encoding vector of each node comparable, improving the accuracy of the representation feature vector of each node, and also facilitating the use of distance encoding vectors for training of graph neural network models.

[0184] • Selection of anchor nodes:

[0185] In some embodiments, at least one anchor node is determined based on the coverage of at least a subset of nodes among N nodes in the graph data. This is an algorithm that maximizes node coverage when selecting at least one anchor node, prioritizing anchor nodes that can cover most of the N nodes in the graph data, and then considering other types of anchor nodes. Specifically, at least one anchor node consists of k anchor nodes, where k is greater than 0 and less than or equal to N. The coverage of at least a subset of nodes is determined based on their friend relationships, and the k anchor nodes in the set are determined based on this coverage.

[0186] For the method of determining k anchor nodes in the anchor node set based on coverage, the method further includes steps 341, 342, 343, 344, 345, and 346:

[0187] Step 341: Determine the set of friends of order t for each node in the graph data when the friend order is t;

[0188] The friend order t can be understood as distance, where t is greater than 0 and less than or equal to the longest shortest reachable path between the N nodes in the original graph data. Optionally, for each of the N nodes in the graph data, nodes with a friend order t are designated as friend nodes of order t, and these friend nodes of order t constitute a friend set of order t. The friend set of order t for each node v in the graph data can be represented as:

[0189] In some embodiments, the set of friends of order t for each node in the graph data is determined based on the breadth-first search (BFS) algorithm. BFS is an algorithm used to traverse or search graph data. Starting from the root node, it sequentially traverses all nodes at the same level, and then sequentially traverses the nodes at the next lower level until the entire graph data has been traversed.

[0190] Step 342: Determine the largest node in the friend set of order t;

[0191] Optionally, the maximum t-order friend set refers to a node whose t-order friend set contains the largest number of t-order friend nodes. Based on the number of nodes in each node's t-order friend set, the node with the largest t-order friend set is determined.

[0192] In some embodiments, if there are at least two largest nodes in the t-order friend set, a largest node is randomly selected from the at least two largest nodes. Alternatively, the node with the smallest node identifier is selected from the at least two largest nodes as the largest node according to its node identifier.

[0193] Step 343: Add the largest node as the anchor node to the anchor node set;

[0194] Step 344: Remove the largest node and the nodes in the t-order friend set of the largest node from the graph data to obtain the graph data after deletion.

[0195] Optionally, by deleting the largest node and the nodes in its t-order friend set from the graph data, the edges between these nodes will also be deleted, resulting in the graph data after deletion. In some embodiments, if there are nodes in the deleted graph data that are not connected by any edges, these edgeless nodes can be ignored.

[0196] Step 345: If the number of current anchor nodes in the anchor node set is less than k and the deleted graph data is not empty, use the deleted graph data as the graph data for the next iteration, and return the steps to determine the friend set of each node in the graph data when the friend order is t.

[0197] Optionally, if the number of current anchor nodes in the anchor node set is less than k and the deleted graph data is not empty, jump to step 341 and use the deleted graph data as the graph data for the next iteration to continue executing the steps.

[0198] Step 346: If the number of current anchor nodes in the anchor node set is less than k, and the graph data after deletion is empty, add the nodes in the original graph data that meet the filtering conditions as anchor nodes to the anchor node set; where t is greater than 0 and less than or equal to the longest shortest reachable path between N nodes in the original graph data; the filtering conditions include the first preset number of nodes that have not been added to the anchor node set and have the largest node degree, and the preset number is the difference between k and the number of current anchor nodes in the anchor node set.

[0199] Optionally, if the number of current anchor nodes in the anchor node set is less than k, and the graph data after deletion is empty, nodes that meet the filtering criteria in the original graph data are selected as anchor nodes and added to the anchor node set. Optionally, the filtering criteria include a preset number of nodes that are not added to the anchor node set and have the largest node degree. In other embodiments, the filtering criteria also include a preset number of nodes that are not added to the anchor node set and have the largest friend set of order t. The preset number is the difference between k and the number of current anchor nodes in the anchor node set.

[0200] In some embodiments, given a fixed value for the friend order t and the number of anchor nodes k, a method is provided for selecting anchor nodes and constructing an anchor node set. This method considers the coverage of anchor nodes on the graph data, improving the rationality of anchor node selection and thus enhancing the accuracy of the distance encoding vector for each node. The values ​​of the friend order t and the number of anchor nodes k can also be adjusted according to actual technical needs. Theoretically, the larger the friend order t and the larger the number of anchor nodes k, the higher the accuracy of friend account recommendations. In one possible example, the number of anchor nodes k can be set to 1% of the N nodes in the graph data.

[0201] Figure 6 This is a schematic diagram illustrating the construction of an anchor node set provided in an exemplary embodiment of this application.

[0202] refer to Figure 6 As shown in (1), the graph data includes 9 nodes, each representing a user account. An edge connecting two nodes indicates that the user accounts corresponding to these two nodes are friends. The 9 nodes are represented as follows: node v1, node v2, node v3, node v4, node v5, node v6, node v7, node v8, and node v9, corresponding to user accounts 1, 2, 3, 4, 5, 6, 7, 8, and 9, respectively. Taking a friend order t of 1 and a friend k of 4 as an example, the anchor node set includes 4 anchor nodes. The construction method of the anchor node set is briefly described as follows:

[0203] refer to Figure 6 As shown in (1), in the original graph data, when the friend order t is 1, the nodes with the most first-order friend nodes are nodes v1, v4, and v5. Among them, the first-order friend nodes of node v1 are: nodes v2, v3, and v4; the first-order friend nodes of node v4 are: nodes v1, v5, and v7; and the first-order friend nodes of node v5 are: nodes v4, v6, and v8. Node v1 is randomly selected as the first anchor node from the nodes v1, v4, and v5 with the most first-order friend nodes. Node v1 and its first-order friend nodes v2, v3, and v4 are then deleted from the graph data. The graph data after deletion is referenced. Figure 6 As shown in (2) of the text.

[0204] refer to Figure 6As shown in (2), in the deleted graph data, when the friend order t is 1, the nodes with the most first-order friend nodes are nodes v5, v6, and v8. Among them, the first-order friend nodes of node v5 are: nodes v6 and v8; the first-order friend nodes of node v6 are: nodes v5 and v7; and the first-order friend nodes of node v8 are: nodes v5 and v9. Node v6 is randomly selected as the second anchor node from the nodes v5, v6, and v8 with the most first-order friend nodes. Node v6 and its first-order friend nodes v5 and v7 are deleted from the graph data. The deleted graph data is referenced. Figure 6 As shown in (3) of the text.

[0205] refer to Figure 6 As shown in (3) of the diagram, in the deleted graph data, when the friend order t is 1, the nodes with the most first-order friend nodes are nodes v8 and v9. Among them, the first-order friend node of node v8 is node v9, and the first-order friend node of node v9 is node v8. Node v8 is randomly selected as the third anchor node from the nodes v8 and v9 with the most first-order friend nodes. Node v8 and its first-order friend node v9 are deleted from the graph data, and the deleted graph data is empty. At this time, there are already 3 anchor nodes. It is also necessary to select one node with the most first-order friend nodes other than these 3 anchor nodes from the original graph data: node v4, as the fourth anchor node. The set of anchor nodes in this embodiment is represented as: M = {v1, v6, v8, v4}.

[0206] • Recommendation of friend's account:

[0207] In some embodiments, after determining the representation feature vector of each of the N nodes in the graph data, friend account recommendations for the current user account can be implemented based on these representation feature vectors. For example, step 260 is specifically implemented as steps 262 and 264:

[0208] Step 262: Calculate the vector distance between the representation feature vector of the node where the current user account is located and the representation feature vector of at least one other node, where at least one other node is at least one node among N nodes other than the node where the current user account is located.

[0209] Vector distance is used to characterize the similarity between representation feature vectors. Specifically, vector distance can be Euclidean distance. In graph data, each of the N nodes represents a user account. For example, a computer device determines the node containing the current account, calculates the vector distance between the representation feature vector of the current user account node and the representation feature vector of at least one other node, which is at least one node among the N nodes other than the node containing the current user account.

[0210] Step 264: Determine the user account corresponding to at least one other node whose vector distance satisfies the recommendation criteria as at least one recommended friend account of the current user account; wherein, the recommendation criteria include vector distance less than or equal to a distance threshold.

[0211] For example, the computer device identifies user accounts corresponding to at least one other node whose vector distance meets the recommendation criteria as at least one recommended friend account for the current user account. Optionally, the recommendation criteria include a vector distance less than or equal to a distance threshold, which can be set according to actual technical needs.

[0212] This embodiment provides a method for recommending friend accounts to the current user account. The recommendation is based on the representation feature vector of each node, which can improve the accuracy of recommending friend accounts to the current user account and, to some extent, also improve the user experience of the current user account.

[0213] Training of graph neural network models:

[0214] In some embodiments, the training of the graph neural network model is performed by a computer device, which may be... Figure 2 The terminal 120 and / or server 140 are shown. This computer device can connect with... Figure 4 The computer equipment used in the embodiments may be the same or different, and no limitation is made here. The method further includes at least some of steps 520, 540, and 560, with step 560 specifically implemented as steps 562, 564, 566, and 568:

[0215] Step 520: Obtain sample graph data. The sample graph data includes N sample nodes and sample edges between the N sample nodes. The sample edges are used to represent the sample friend relationships between the N sample nodes. Each of the N sample nodes is used to represent a sample user account, and N is greater than 1.

[0216] The sample graph data is determined based on sample user accounts and the friend relationships between them, and is used during the training phase of the graph neural network model. When two sample user accounts are friends, it means that the two sample user accounts have added each other as friends. The sample user accounts and their friend relationships can be pre-built, obtained from public databases or datasets, or obtained with the consent of the sample user accounts.

[0217] The computer device acquires sample graph data, which includes N sample nodes and N sample edges between them. The sample edges represent the friend relationships between the N sample nodes. Each of the N sample nodes represents a sample user account, where N is greater than 1. Each sample node can be represented by a sample node identifier, which includes at least one of the following: numbers, letters, and symbols. Two sample user accounts connected by a sample edge are friends. For example, the sample graph data includes sample nodes v1 and v2, corresponding to sample user account 1 and sample user account 2, respectively. Sample nodes v1 and v2 are connected by sample edge 12, indicating that sample user account 1 and sample user account 2 are friends and have added each other as friends.

[0218] In some embodiments, the sample graph data is represented as: G = (V, E). V is the set of sample nodes, and E is the set of sample edges. The set of sample nodes includes N sample nodes, and the set of sample edges includes sample edges between N sample nodes. Any sample edge connects two sample nodes in the N sample nodes, where N is greater than 1.

[0219] Step 540: Determine the sample distance encoding vector for each sample node based on the sample distance between each sample node and at least one sample anchor node.

[0220] At least one sample anchor node is selected from N sample nodes in the sample graph data. Optionally, at least one sample anchor node can be one or more sample anchor nodes from k sample anchor nodes, or it can be each of the k sample anchor nodes, where k is greater than 0 and less than or equal to N.

[0221] In this embodiment, at least one sample anchor node is determined based on the coverage of sample nodes. The coverage of a sample node is related to at least one of the following factors: whether there is a reachable path between the sample node and other sample nodes, the number of existing reachable paths, and the number of other nodes reachable through these reachable paths. Since the reachable paths between sample nodes are determined based on sample edges, it can also be understood that at least one sample anchor node is determined based on the friend relationships between at least a portion of the N sample nodes. The selection method for at least one sample anchor node is consistent with the aforementioned selection method for at least one anchor node.

[0222] Sample distance, also known as sample node distance, refers to the path length of the shortest reachable path between two sample nodes. When the positions of each of the N sample nodes in the sample graph data, and at least one sample anchor node, are determined, then the sample distance between each sample node and at least one sample anchor node is also determined. The sample distance between a sample node and a sample anchor node is the path length of the shortest reachable path from that sample node to that sample anchor node.

[0223] Optionally, the computer device determines a sample distance encoding vector for each sample node based on the sample distance between each sample node and at least one sample anchor node. Specifically, the sample distance encoding vector for each sample node is determined based on the sample distance between each sample node and each of the k sample anchor nodes in the set of sample anchor nodes; wherein the sample distance encoding vector includes k elements, and one element of the k elements is used to indicate the sample distance between the current sample node and one of the k sample anchor nodes; k is greater than 0 and less than or equal to N.

[0224] The calculation method for the sample distance encoding vector of each sample node is consistent with the calculation method for the distance encoding vector of each node mentioned above. Next, based on the sample distance encoding vector of each sample node, a self-supervised graph neural network model based on distance encoding is trained, or simply a graph neural network model.

[0225] Step 560: Perform the following processing on the graph neural network model to be trained:

[0226] Step 562: Based on the sample distance encoding vector of each sample node, determine the sample label value of each sample. Each sample includes any two sample node pairs, and each sample node pair in any two sample node pairs includes any two sample nodes.

[0227] Optionally, the graph neural network model does not use manually labeled training labels, but instead generates training labels based on sample graph data. Using the graph neural network model to be trained, the sample label value for each sample is determined based on the sample distance encoding vector of each sample node. Each sample includes any two sample node pairs, and each of these pairs includes any two sample nodes. That is, each sample includes any four sample nodes from the N sample nodes in the sample graph data.

[0228] In some embodiments, sample label values ​​are defined based on a characteristic function. Given an event, the characteristic function determines whether the value is a first or a second value based on whether the event is true or false. The first value includes 1, and the second value includes 0. Let A be an event, then:

[0229]

[0230] Step 564: Map the sample distance encoding vector of each sample node to the predicted representation feature vector.

[0231] The predicted representation feature vector is obtained by mapping the sample distance encoding vector of each sample node to the graph neural network model to be trained. For example, the graph neural network model to be trained maps the sample distance encoding vector of each sample node to the predicted representation feature vector.

[0232] Step 566: Calculate the predicted label value for each sample based on the predicted representation feature vector of each sample node.

[0233] The predicted label value is obtained by performing predictions on each sample using the graph neural network model to be trained. Optionally, the predicted label value for each sample is calculated based on the predicted representation feature vector of each sample node using the graph neural network model to be trained. In some embodiments, the predicted label value is calculated in the same way as the aforementioned sample label value, and is also determined based on the aforementioned indicator function.

[0234] Step 568: Optimize the model parameters of the graph neural network model based on the predicted label value and the sample label value for each sample.

[0235] For example, the model parameters of the graph neural network model are optimized based on the predicted label value and the sample label value for each sample. Here, the model parameters include: learning parameters, bias parameters, and activation functions.

[0236] In this embodiment, a method is provided to acquire sample graph data and train a graph neural network model based on the sample distance encoding vector of each sample node in the sample graph data. This allows the graph neural network model to learn the representation feature vector of each node, enabling the distance information of different nodes in the graph data to be better restored based on at least one anchor node.

[0237] In some embodiments, the calculation method for the sample label value of each sample is specifically implemented as steps 5621, 5622, and 5623:

[0238] Step 5621: Determine the sample query distance for each sample node pair based on the sample distance encoding vector of each sample node.

[0239] For each pair of sample nodes in the sample graph data, each pair consists of two sample nodes. The sample query distance of this pair is the sum of the sample distances between the nearest anchor node and each of the two sample nodes. When the nearest anchor node is located on the shortest reachable path between the two sample nodes, the sample query distance between these two sample nodes is the path length of that shortest reachable path.

[0240] Specifically, for each sample node pair, the sample distance encoding vectors of the two sample nodes in each sample node pair are added together to obtain a summed distance encoding vector; the minimum distance in the summed distance encoding vector is determined as the sample query distance. Here, each element in the summed distance encoding vector represents the sum of the sample distances between each of the two sample nodes in the sample node pair and a sample anchor node.

[0241] In one example, for a pair of sample nodes on sample graph data G, which includes sample node u and sample node v, the sample query distance of the pair is defined as:

[0242]

[0243] Among them, h u,v It is the sample query distance, E u,i E is the distance from the i-th sample anchor node in the sample distance encoding vector of sample node u. v,i is the distance between sample node v and the i-th sample anchor node in the sample distance encoding vector, and k is the number of sample anchor nodes in the sample anchor node set.

[0244] In this embodiment, the sample query distance h between sample node u and sample node v is... u,v , is the sample anchor node v in the set of sample anchor nodes that is closest to these two sample nodes. i The sum of the distances to sample node u and sample node v, respectively. When the sample is anchored to node v. i On the shortest reachable path between sample node u and sample node v, the sample query distance is the distance on the sample graph data, which is the path length of the shortest reachable path.

[0245] Step 5622: Calculate the sample difference between the two sample nodes contained in each sample and their respective sample query distances.

[0246] Step 5623: For each sample, if the sample difference is greater than the sample threshold, determine the sample label value as the first value; if the sample difference is not greater than the sample threshold, determine the sample label value as the second value.

[0247] Each sample consists of two sample node pairs. The sample label value of each sample is used to characterize whether the two sample node pairs contained in the sample are relatively closer to any one of the sample anchor nodes in the sample anchor node set. Alternatively, the sample label value of each sample is used to characterize which of the two sample node pairs contained in the sample is relatively closer to any one of the sample anchor nodes in the sample anchor node set.

[0248] In some embodiments, based on the indicator function, the sample difference between the query distances of two samples contained in each sample is defined. For each sample, if the sample difference is greater than a sample threshold, the sample label value is determined to be a first value; if the sample difference is not greater than the sample threshold, the sample label value is determined to be a second value. The sample threshold, the first value, and the second value can be set according to actual technical needs. For example, the sample threshold can be set to 0, the first value can include 1, and the second value can include 0.

[0249] In one example, for a sample in the sample graph data G, the sample consists of any two pairs of sample nodes, one pair consisting of sample node u and sample node v, and the other pair consisting of sample node u′ and sample node v′. Using indicator functions, the two pairs of sample nodes (u,v) and (u′,v′) for any sample are defined as follows:

[0250]

[0251] Where y is the sample label value of the sample, h u,v h is the sample query distance between sample node pairs (u,v). u′,v′ This is the sample query distance between sample node pairs (u′, v′). In this embodiment, based on the sample distance encoding vector, the sample label value of a sample corresponding to any two sample node pairs (u, v) and sample node pairs (u′, v′) can be calculated. The sample label value is used to characterize whether the two sample node pairs contained in the sample are relatively closer to any anchor node in the sample anchor node set.

[0252] This embodiment provides a method for generating sample label values ​​for each sample using a graph neural network model. The graph neural network model is a self-supervised model that does not use manually labeled training labels but generates training labels based on sample graph data. This reduces data labeling costs, improves data utilization, enhances generalization ability, and thus improves the accuracy of the graph neural network model.

[0253] In some embodiments, the calculation method for the predicted label value of each sample, step 566 is specifically implemented as steps 5661, 5662, and 5663:

[0254] Step 5661: Determine the predicted query distance for each sample node pair based on the predicted representation feature vector of each sample node.

[0255] For each pair of sample nodes in the sample graph data, each pair consists of two sample nodes. The predicted query distance of this pair is the vector distance between the predicted feature vectors of the two sample nodes. Specifically, the vector distance can be Euclidean distance. For example, based on the predicted feature vector of each sample node, the vector distance between the predicted feature vectors of each pair of sample nodes is calculated to obtain the predicted query distance for each pair of sample nodes.

[0256] In one example, for a sample node pair on sample graph data G, the sample node pair includes sample node u and sample node v, the predicted query distance of the sample node pair is defined as:

[0257]

[0258] Where, h′ u,v It predicts the query distance, F u F is the predicted feature vector of sample node u. v F is the predicted feature vector of sample node v. u,i F is the mapping distance between the predicted feature vector of sample node u and the anchor node of the i-th sample. v,i The predicted representation of sample node v is the mapping distance between the feature vector and the i-th sample anchor node, where k is the number of sample anchor nodes in the sample anchor node set.

[0259] Step 5662: Calculate the prediction difference between the predicted query distances of the two sample nodes contained in each sample;

[0260] Step 5663: Based on the activation function of the graph neural network model, map the prediction difference of each sample to obtain the predicted label value of each sample.

[0261] Each sample comprises two pairs of sample nodes. The predicted label value for each sample is used to predict whether the two sample node pairs contained in that sample are relatively closer to any one of the sample anchor nodes in the sample anchor node set. Alternatively, the predicted label value for each sample is used to predict which of the two sample node pairs contained in that sample is relatively closer to any one of the sample anchor nodes in the sample anchor node set. Optionally, the predicted difference for each sample is mapped using the activation function of the graph neural network model to obtain the predicted label value for each sample. In some embodiments, the activation function is the sigmoid function.

[0262] In one example, for a sample in the sample graph data G, the sample consists of any two pairs of sample nodes, one pair consisting of sample node u and sample node v, and the other pair consisting of sample node u′ and sample node v′. Using the indicator function, the predicted label value of any two sample node pairs (u,v) and (u′,v′) is defined as follows:

[0263] y′=σ(h′ u,v -h′ u′,v′ )

[0264] Where y′ is the sample label value of the sample, h′ u,v h′ is the predicted query distance for the sample node pair (u,v). u′,v′ σ is the predicted query distance of the sample node pair (u′,v′), and σ is the activation function, specifically the sigmoid function.

[0265] This embodiment provides a method for the graph neural network model to generate the predicted label value for each sample, which is beneficial for the self-supervised learning of the graph neural network model and improves the accuracy of the graph neural network model.

[0266] In some embodiments, the sample label value and predicted label value of each sample are a first value or a second value, where the first value includes 1 and the second value includes 0. In this case, the loss function is the Binary CrossEntropy Loss (BCE Loss). Step 568 is specifically implemented as step 5680:

[0267] Step 5680: Based on the predicted label value and sample label value of each sample, determine the binary cross-entropy loss function, and optimize the model parameters of the graph neural network model with minimizing the binary cross-entropy loss function as the training objective.

[0268] Optionally, based on the predicted label value and the sample label value for each sample, a binary cross-entropy loss function is determined. The model parameters of the graph neural network are optimized by minimizing this binary cross-entropy loss function as the training objective. The binary cross-entropy loss function is expressed as:

[0269]

[0270] Where L is the binary cross-entropy loss function, N is the number of samples, and y j y′ is the sample label value of the j-th sample. j It is the predicted label value of the j-th sample.

[0271] In this embodiment, the loss function is the binary cross-entropy loss function, and a method for calculating the binary cross-entropy loss function of the graph neural network model is provided. Reducing the binary cross-entropy loss function as the training objective can improve the accuracy of the graph neural network model.

[0272] Next, we will provide an overall explanation of the friend account recommendation method with specific illustrations.

[0273] • Application scenarios:

[0274] The friend account recommendation method provided in this application can be applied to social networks or game programs. Figure 7 This is an interface diagram of a friend account recommendation method provided in an exemplary embodiment of this application. In the game program, after the player of the current user account clicks "Search Players," the interface diagram of the computer device displays a list of recommended friend accounts. The list of recommended friend accounts includes the avatars, nicknames, and prompt text of multiple user accounts. For example, the avatar and nickname of user account 1 are displayed, with the prompt text "You all love competitive gameplay"; the avatar and nickname of user account 2 are displayed, with the prompt text "We've played Brawl together"; the avatar and nickname of user account 3 are displayed, with the prompt text "You all like playing on the slide in the square"; and the avatar and nickname of user account 4 are displayed, with the prompt text "You all like playing on the slide in the square." Players can click on these user accounts to send friend requests.

[0275] • Technical Implementation:

[0276] The friend account recommendation method provided in this application mainly involves three aspects: 1. Constructing a set of anchor nodes for graph data; 2. Calculating the distance encoding vector of each node in the graph data; 3. Training a graph neural network model based on the distance encoding vector; 4. Recommending friend accounts based on the graph neural network model.

[0277] Specifically, given graph data, represented as G = (V, E), where V is the set of nodes and E is the set of edges, construct an anchor node set M of size k, where k ≤ |V|. That is, the size of the anchor node set M is |M| = k, and the anchor node set M is a subset of the node set V of the graph data G, represented as: The distance between each node in the graph data G and each anchor node in the set of anchor nodes is calculated, resulting in a distance encoding vector of length k for each node. This distance encoding vector is then used as input data to a graph neural network (GNN) model. A loss function and optimization objective are designed for the GNN model to train it. The trained GNN model can then be used to generate the feature vector representing each node in the graph data.

[0278] 1. Construct the set of anchor nodes for the graph data:

[0279] Selecting k anchor nodes from graph data G = (V, E) can be done in several ways, such as randomly selecting or selecting based on node degree from highest to lowest. However, these methods do not consider the coverage of anchor nodes in the graph data, which may result in some nodes in the graph data not having a reachable path from any of the anchor nodes.

[0280] This application proposes a method for selecting anchor nodes by maximizing node coverage. It prioritizes anchor nodes that can cover most of the N nodes in the graph data, and then considers other types of anchor nodes. Given an integer k less than |V| and a friend order t, the steps for determining k anchor nodes and constructing the anchor node set M of the graph data include:

[0281] (1) Initialize an empty set of anchor nodes M;

[0282] (2) Using the breadth-first traversal algorithm, calculate the set of friends of order t for each node v in the graph data G, represented as: Optionally, the breadth-first traversal algorithm starts from a node v and traverses its neighbors level by level until all of v's neighbors of order t are calculated.

[0283] (3) Calculate the node u with the largest friend set of order t in the graph data G; Optionally, when there are at least two nodes with the largest friend set of order t, randomly select a node u from at least two nodes;

[0284] (4) Add node u to the anchor node set M;

[0285] (5) Node u and its t-order friend set The nodes in the graph are deleted from the graph data G;

[0286] (6) If the number of current anchor nodes in the anchor node set M is less than k and the graph data G is not empty, then jump to step (2) and continue to execute.

[0287] (7) When the number of anchor nodes in the anchor node set M is less than k and the graph data G is empty, select the first k-|M| nodes with the largest node degree that have not been added to the anchor node set M from the original graph data G and add them to the anchor node set M.

[0288] (8) Output the anchor node set M as the final result.

[0289] For example, refer to Figure 6 When k=4 and t=1, calculate a set M of anchor nodes with 4 anchor nodes based on the first-order friends of each node. (Reference) Figure 6As shown in (1), based on the first-order friend set of each node, node v1 is selected and added to the anchor node set M. Node v1 and its friend nodes v2, v3, v4 are then removed from the graph data G. (See reference...) Figure 6 As shown in (2), in the new graph data G, the first-order friend set of each node is recalculated, and node v6 is selected to be added to the anchor node set M. Node v6 and its friend nodes v5 and v7 are then removed from the graph data G. (See reference...) Figure 6 As shown in (3), in the new graph data G, node v8 was selected and added to the anchor node set M. Node v8 and its friend node v9 were then removed from the graph data G. Since the remaining graph data G is empty and the anchor node set M contains only 3 anchor nodes, refer to... Figure 6 As shown in (4), select the node v4 with the most first-order friends from the original graph data G, excluding the 3 anchor nodes in the anchor node set M. Then the anchor node set M = {v1, v6, v8, v4}.

[0290] 2. Calculate the distance encoding vector for each node in the graph data:

[0291] Given a set of anchor nodes M, containing k anchor nodes, the distance encoding vector E for each node v in the graph data G is... v It is based on the distance d between node v and each anchor node u in the set of anchor nodes M. v,u The process is as follows: To determine the positions of k anchor nodes in the anchor node set M within the distance encoding vector, the k anchor nodes in the anchor node set M are sorted. Given that the anchor node set M and the graph data G are determined, the distance encoding vector for each node in the graph data G is also determined.

[0292] Based on the order of the k anchor nodes in the anchor node set M, traverse each anchor node v, and calculate the distance d from each node v in the graph data G to each anchor node u in the anchor node set M by traversing the friend set. v,u To determine the distance encoding vector, the steps include:

[0293] (1) For the k anchor nodes in the anchor node set M, sort them according to their node identifiers or according to the order in which they were added to the anchor node set M, to obtain the anchor node sequence v1, v2, ..., v k ;

[0294] (2) For each node u in the graph data G, initialize a vector E of length k with all values ​​of 0. u For any 1≤i≤k, there exists E u,i =0;

[0295] (3) Initialize an anchor node traversal identifier i = 1;

[0296] (4) Initialize a distance variable d = 1;

[0297] (5) Initialize the first set of visited nodes, denoted as: V visited ={v i The initial content of the first node set is the i-th anchor node v. i ;

[0298] (6) Initialize a second node set of the currently visited node, denoted as: V current ={v i The initial content of the second node set is the i-th anchor node v. i ;

[0299] (7) Calculate the set V of the first node currently visited. current The first set of friends of order d is denoted as:

[0300]

[0301] (8) Calculate the first friend set V tmp1 The set of the second unvisited nodes in the first friend set V, i.e.: the set of the first friend set V. tmp1 After deleting visited nodes, we obtain the second friend set, denoted as V. tmp2 =V tmp1 / V visited ;

[0302] (9) Set a second friend set V tmp2 From all nodes u to the i-th anchor node v i The distance is d, denoted as: E u,i =d; When returning to the calculation, set the second friend set V. tmp2 From all nodes u to the i-th anchor node v i The distance is the sum of d and the number of returns;

[0303] (10) Set the second friend group V tmp2 All nodes are added to the first set of visited nodes to update the first set of nodes, denoted as: V visited =V visited ∪V tmp2 ;

[0304] (11) Update the second node set of the currently visited node to the second friend set, in order to update the second node set, represented as: V current =V tmp2 ;

[0305] (12) When the second node set V current If not empty, proceed to step (7); otherwise, continue execution.

[0306] (13) Update the anchor node traversal flag, which is represented as: i = i + 1;

[0307] (14) If i≤k, then jump to step (4) and update d to d+1; otherwise, continue execution.

[0308] (15) When i>k, it means that all anchor nodes have been traversed, and the vector E of each node u is output. u It is its distance encoding vector.

[0309] For example, refer to Figure 5 When k=4 and t=1, the set of anchor nodes M={v1,v6,v8,v4}. (Reference) Figure 5 As shown in (2), the distance encoding vector of each node v is obtained based on the distance between each node v in the graph data G and each anchor node in the anchor node set M.

[0310] 3. Training a graph neural network model based on distance encoding vectors:

[0311] Given a graph dataset G, use a graph neural network model to generate the feature vector F representing each node v. v , such that the eigenvector F v It can capture distance information between nodes in graph data G. Graph neural network models do not use manually labeled training labels, but instead generate trainable labels from the graph data. For any two nodes u and v in graph data G, the query distance h between them is... u,v Defined as:

[0312]

[0313] That is: the query distance h between node u and node v u,v It is the i-th anchor node v in the set of anchor nodes M that is closest to these two nodes. i The sum of distances to node u and node v. When the i-th anchor node v... i The query distance between nodes u and v on the shortest reachable path is the same as the distance on the graph.

[0314] Using indicator functions, any pair of nodes (u,v) and (u′,v′) can be defined as follows:

[0315]

[0316] Based on this formula, the sample label value y of any two node pairs (u,v) and (u′,v′) contained in a sample can be calculated according to the distance encoding vector of each node. The sample label value y is used to determine whether the two node pairs contained in a sample are relatively closer to any anchor node in the set of anchor nodes.

[0317] In this embodiment, it is necessary to train and learn the representation feature vector F of each node v in the graph data G. v This allows for a better reconstruction of the distance information between nodes on the graph based on the set of anchor nodes.

[0318] The graph neural network model encodes the distance vector E for each node v. v The transformation mapping is represented by the eigenvector F. v . represents the eigenvector F v The length of is also k. This represents the eigenvector F. v Each element F v,i It can be obtained through the distance encoding vector E v The linear transformation yields, expressed as:

[0319] F v,i =σ(W i ·E v +b i )

[0320] Among them, W i b is a learning parameter variable of length k. i It is a bias variable. σ is the sigmoid function:

[0321]

[0322] The vector distance between any two nodes u and v in a node pair is expressed as:

[0323]

[0324] For any two node pairs (u,v) and (u′,v′) contained in each sample, the predicted label value is:

[0325] y′=σ(h′ u,v -h′ u′,v′ )

[0326] The model parameters of the graph neural network model are optimized using the binary cross-entropy loss function, as follows:

[0327]

[0328] Where L is the binary cross-entropy loss function, N is the number of samples, and y jy′ is the sample label value of the j-th sample. j It is the predicted label value of the j-th sample.

[0329] 4. Friend account recommendation based on graph neural network model:

[0330] In some embodiments, the computer device stores the trained graph neural network model. Specifically, graph data of the friend network is acquired, and the distance encoding vector of each node is calculated, where each user account is a node in the graph data, and the friend relationships between user accounts are edges between nodes. The distance encoding vector of each node is input into the graph neural network model, which generates a representation feature vector for each node. Next, based on the representation feature vector of each node, the vector distance or similarity between the node containing the current user account and at least one other node is determined, and at least one other user account that is most similar to the representation feature vector of the current user account, or at least one other user account whose vector distance is less than a distance threshold, is recommended to the current user account, forming a list of recommended friend accounts, which is then displayed.

[0331] Beneficial effects:

[0332] Table 1 shows a comparison of the effects of different anchor node selection methods. The recommendation accuracy is the proportion of users who accept the recommendation, expressed as: Accuracy = Users who accept the recommendation / Users who receive the recommendation. The comparison methods include three: (1) Random, which is a method of randomly selecting anchor nodes; (2) Node degree, which is a method of selecting anchor nodes based on the node degree from large to small; (3) PageRank algorithm, which is a method of evaluating the importance of nodes in the graph based on random walks and iterative calculations to select anchor nodes. As can be seen from Table 1, the anchor node selection method of this application embodiment is higher in accuracy than other comparison methods, with a relative improvement of 14.4% compared to the node degree method and a relative improvement of 16.6% compared to the random method. Table 2 shows a comparison of the effects of different models. Compared to the GCN model, the graph neural network model of this application embodiment improves the recommendation accuracy by 0.0056, a relative improvement of 0.63%, which is better.

[0333] Table 1: Comparison of the effects of anchor node selection methods

[0334] Model random Node degree PageRank Examples of this application accuracy 0.7659 0.7801 0.7707 0.8928

[0335] Table 2: Comparison of the effects of different models

[0336] Model GCN Examples of this application accuracy 0.8872 0.8928

[0337] Figure 8This is a block diagram of a friend account recommendation device provided in an exemplary embodiment of this application. Exemplarily, the friend account recommendation device 800 includes at least some of the following modules: an acquisition module 820, a processing module 840, and a recommendation module 860.

[0338] The acquisition module 820 is used to acquire graph data, which includes N nodes and edges between the N nodes. The edges are used to represent the friend relationships between the N nodes, and each of the N nodes is used to represent a user account. The N is greater than 1.

[0339] The processing module 840 is used to construct a representation feature vector for each node based on the distance between each node and at least one anchor node. The representation feature vector is used to map the distance information between the current node and the at least one anchor node. The at least one anchor node is determined based on the friend relationships between at least a portion of the N nodes.

[0340] The recommendation module 860 is used to determine at least one recommended friend account of the current user account based on the representation feature vector of each node.

[0341] In some embodiments, the processing module 840 is configured to:

[0342] Based on the distance between each node and the at least one anchor node, a distance encoding vector is determined for each node, the distance encoding vector being used to indicate the distance between the current node and the at least one anchor node;

[0343] The distance encoding vector of each node is mapped to the representation feature vector of each node.

[0344] In some embodiments, the processing module 840 is configured to:

[0345] The distance encoding vector of each node is mapped to the representation feature vector of each node using the trained graph neural network model.

[0346] The graph neural network model is used to capture the distance information represented by the distance encoding vector of each node.

[0347] In some embodiments, the graph neural network model includes learning parameters, bias parameters, and activation functions; the processing module 840 is configured to:

[0348] The distance encoding vector of each node is multiplied by the learning parameters to obtain a product result; the product result is added to the bias parameters to obtain an addition result; the addition result is mapped based on the activation function to obtain the representation feature vector of each node.

[0349] In some embodiments, the processing module 840 is configured to:

[0350] Based on the distance between each node and each of the k anchor nodes in the set of anchor nodes, the distance encoding vector of each node is determined;

[0351] The distance encoding vector includes k elements, one of which indicates the distance between the current node and one of the k anchor nodes; k is greater than 0 and less than or equal to N.

[0352] In some embodiments, the processing module 840 is configured to:

[0353] The following initialization operations are performed sequentially: the elements in the distance encoding vector of each node are initialized to initial values, the anchor node traversal identifier i is initialized when traversing the k anchor nodes, the distance variable d is initialized, the first node set of the visited nodes is initialized, and the second node set of the currently visited node is initialized.

[0354] Calculate the first friend set corresponding to the second node set when the friend order is d;

[0355] The unvisited nodes in the first friend set are used as the second friend set;

[0356] The distance from each node in the second friend set to the i-th anchor node is set to d;

[0357] Merge the second friend set with the first node set to update the first node set;

[0358] Use the second set of friends as the second set of nodes to update the second set of nodes;

[0359] If the updated second node set is not empty, return to the step of calculating the first friend set corresponding to the second node set when the friend order is d, and set the distance from each node in the second friend set to the i-th anchor node to the sum of d and the number of returns; otherwise, if the updated second node set is empty, update i to i+1.

[0360] If the updated i is less than or equal to k, return to the step of initializing the distance variable d; otherwise, if the updated i is greater than k, determine that all k anchor nodes have been traversed and obtain the distance encoding vector of each node.

[0361] In some embodiments, the processing module 840 is configured to:

[0362] Based on the friend relationships between at least a portion of the N nodes, the coverage of the at least a portion of the nodes is determined, and based on the coverage, the k anchor nodes in the anchor node set are determined;

[0363] The coverage of one of the at least some nodes is related to at least one of the following factors: whether there is a reachable path between the node and other nodes, the number of the existing reachable paths, and the number of other nodes reached through the reachable paths.

[0364] In some embodiments, the processing module 840 is configured to:

[0365] Determine the set of friends of order t for each node in the graph data when the friend order is t.

[0366] Determine the largest node in the friend set of order t;

[0367] The largest node is added to the set of anchor nodes as the anchor node;

[0368] The maximum node and the nodes in the t-order friend set of the maximum node are deleted from the graph data to obtain the deleted graph data.

[0369] If the number of current anchor nodes in the anchor node set is less than k, and the deleted graph data is not empty, the deleted graph data is used as the graph data for the next iteration, and the step of determining the friend set of each node in the graph data when the friend order is t is returned.

[0370] If the number of current anchor nodes in the anchor node set is less than k, and the deleted graph data is empty, the nodes in the original graph data that meet the filtering conditions are added to the anchor node set as anchor nodes.

[0371] Wherein, t is greater than 0 and less than or equal to the longest shortest reachable path among N nodes in the original graph data; the filtering conditions include the first preset number of nodes that have not been added to the anchor node set and have the largest node degree, and the preset number is the difference between k and the current number of anchor nodes in the anchor node set.

[0372] In some embodiments, the processing module 840 is configured to:

[0373] If there are at least two largest nodes in the t-order friend set, randomly select one of the at least two largest nodes.

[0374] In some embodiments, the processing module 840 is configured to:

[0375] Sort the k anchor nodes in the set of anchor nodes;

[0376] The sorting method includes one of the following: sorting by node identifier, random sorting, or sorting according to the order in which the nodes were added to the anchor node set.

[0377] In some embodiments, the recommended module 860 is used for:

[0378] Calculate the vector distance between the representation feature vector of the node where the current user account is located and the representation feature vector of at least one other node, wherein the at least one other node is at least one node among the N nodes other than the node where the current user account is located;

[0379] The user account corresponding to at least one other node whose vector distance satisfies the recommendation condition is determined as the at least one recommended friend account of the current user account;

[0380] The recommendation criteria include the vector distance being less than or equal to a distance threshold.

[0381] In some embodiments, the acquisition module 820 is further configured to:

[0382] Obtain sample graph data, which includes N sample nodes and sample edges between the N sample nodes. The sample edges are used to represent sample friend relationships between the N sample nodes. Each of the N sample nodes is used to represent a sample user account, and N is greater than 1.

[0383] Processing module 840 is also used for:

[0384] Based on the sample distance between each sample node and at least one sample anchor node, determine the sample distance encoding vector for each sample node;

[0385] The following processing is performed on the graph neural network model to be trained:

[0386] Based on the sample distance encoding vector of each sample node, the sample label value of each sample is determined, wherein each sample includes any two sample node pairs, and each sample node pair includes any two sample nodes.

[0387] The sample distance encoding vector of each sample node is mapped to a predicted representation feature vector;

[0388] Based on the predicted representation feature vector of each sample node, the predicted label value of each sample is calculated;

[0389] Based on the predicted label value and the sample label value for each sample, the model parameters of the graph neural network model are optimized.

[0390] In some embodiments, the processing module 840 is configured to:

[0391] Based on the predicted representation feature vector of each sample node, the predicted query distance of each sample node pair is determined;

[0392] Calculate the prediction difference between the predicted query distances of the two sample nodes contained in each sample;

[0393] Based on the activation function of the graph neural network model, the predicted difference of each sample is mapped to obtain the predicted label value of each sample.

[0394] In some embodiments, the processing module 840 is configured to:

[0395] Based on the sample distance encoding vector of each sample node, determine the sample query distance of each sample node pair;

[0396] Calculate the sample difference between the query distances of the two sample nodes contained in each sample to their respective samples;

[0397] For each sample, if the sample difference is greater than the sample threshold, the sample label value is determined to be a first value; if the sample difference is not greater than the sample threshold, the sample label value is determined to be a second value.

[0398] In some embodiments, the processing module 840 is configured to:

[0399] For each sample node pair, the sample distance encoding vectors of the two sample nodes in each sample node pair are added together to obtain a summed distance encoding vector; the minimum distance in the summed distance encoding vector is determined as the sample query distance.

[0400] In some embodiments, the processing module 840 is configured to:

[0401] Based on the predicted label value and the sample label value for each sample, a binary cross-entropy loss function is determined, and the model parameters of the graph neural network model are optimized by minimizing the binary cross-entropy loss function as the training objective.

[0402] It should be noted that the specific limitations of the one or more friend account recommendation devices 800 provided in the above embodiments can be found in the limitations of the friend account recommendation method described above, and will not be repeated here. Each module of the above device can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in the processor of the computer device in hardware form or independent of it, or it can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0403] This application also provides a computer device, which includes: a processor and a memory, wherein the memory stores a computer program; the processor is used to execute the computer program in the memory to implement the friend account recommendation method provided in the above method embodiments.

[0404] For example, Figure 9 This is a structural block diagram of a computer device provided in an exemplary embodiment of this application. Optionally, the computer device is a server 1000.

[0405] Typically, server 1000 includes a processor 1001 and memory 1002.

[0406] Processor 1001 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1001 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). Processor 1001 may also include a main processor and a coprocessor. The main processor, also known as a central processing unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1001 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1001 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.

[0407] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1002 is used to store at least one instruction, which is executed by the processor 1001 to implement the friend account recommendation method provided in the above-described method embodiments.

[0408] In some embodiments, the server 1000 may optionally include an input interface 1003 and an output interface 1004. The processor 1001, memory 1002, and input interfaces 1003 and 1004 can be connected via a bus or signal lines. Various peripheral devices can be connected to the input interfaces 1003 and 1004 via a bus, signal lines, or a circuit board. The input interfaces 1003 and 1004 can be used to connect at least one input / output (I / O) related peripheral device to the processor 1001 and memory 1002. In some embodiments, the processor 1001, memory 1002, and input interfaces 1003 and 1004 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, memory 1002, and input interfaces 1003 and 1004 can be implemented on separate chips or circuit boards, and this application does not limit this.

[0409] Those skilled in the art will understand that Figure 9 The structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0410] In an exemplary embodiment, this application also provides a chip, which includes programmable logic circuits and / or program instructions. When the chip is run on a computer device, it is used to implement the friend account recommendation method provided in the above-described method embodiments.

[0411] This application also provides a computer-readable storage medium storing a computer program, which is loaded and executed by a processor to implement the friend account recommendation method provided in the above-described method embodiments.

[0412] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the processor of the computer device to load and execute the friend account recommendation method provided in the above-described method embodiments.

[0413] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0414] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0415] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0416] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for recommending friend accounts, characterized in that, The method includes: Obtain graph data, which includes N nodes and edges between the N nodes. The edges are used to represent the friend relationships between the N nodes, and each of the N nodes is used to represent a user account. The N is greater than 1. Based on the distance between each node and at least one anchor node, a representation feature vector is constructed for each node. The representation feature vector is used to map the distance information between the current node and the at least one anchor node. The at least one anchor node is determined based on the friend relationships between at least a portion of the N nodes. Based on the representation feature vector of each node, at least one recommended friend account of the current user account is determined.

2. The method according to claim 1, characterized in that, The construction of the representation feature vector for each node based on the distance between each node and at least one anchor node includes: Based on the distance between each node and the at least one anchor node, a distance encoding vector is determined for each node, the distance encoding vector being used to indicate the distance between the current node and the at least one anchor node; The distance encoding vector of each node is mapped to the representation feature vector of each node.

3. The method according to claim 2, characterized in that, The step of mapping the distance encoding vector of each node to the representation feature vector of each node includes: The distance encoding vector of each node is mapped to the representation feature vector of each node using the trained graph neural network model. The graph neural network model is used to capture the distance information represented by the distance encoding vector of each node.

4. The method according to claim 3, characterized in that, The graph neural network model includes learning parameters, bias parameters, and activation functions; the process of mapping the distance encoding vector of each node to the representation feature vector of each node using the trained graph neural network model includes: The distance encoding vector of each node is multiplied by the learning parameters to obtain a product result; the product result is added to the bias parameters to obtain an addition result; the addition result is mapped based on the activation function to obtain the representation feature vector of each node.

5. The method according to any one of claims 2 to 4, characterized in that, Determining the distance encoding vector for each node based on the distance between each node and the at least one anchored node includes: Based on the distance between each node and each of the k anchor nodes in the set of anchor nodes, the distance encoding vector of each node is determined; The distance encoding vector includes k elements, one of which indicates the distance between the current node and one of the k anchor nodes; k is greater than 0 and less than or equal to N.

6. The method according to claim 5, characterized in that, The step of determining the distance encoding vector for each node based on the distance between each node and each of the k anchor nodes in the set of anchor nodes includes: The following initialization operations are performed sequentially: the elements in the distance encoding vector of each node are initialized to initial values, the anchor node traversal identifier i is initialized when traversing the k anchor nodes, the distance variable d is initialized, the first node set of the visited nodes is initialized, and the second node set of the currently visited node is initialized. Calculate the first friend set corresponding to the second node set when the friend order is d; The unvisited nodes in the first friend set are used as the second friend set; The distance from each node in the second friend set to the i-th anchor node is set to d; Merge the second friend set with the first node set to update the first node set; Use the second set of friends as the second set of nodes to update the second set of nodes; If the updated second node set is not empty, return to the step of calculating the first friend set corresponding to the second node set when the friend order is d, and set the distance from each node in the second friend set to the i-th anchor node to the sum of d and the number of returns; otherwise, if the updated second node set is empty, update i to i+1. If the updated i is less than or equal to k, return to the step of initializing the distance variable d; otherwise, if the updated i is greater than k, determine that all k anchor nodes have been traversed and obtain the distance encoding vector of each node.

7. The method according to claim 5 or 6, characterized in that, The method further includes: Based on the friend relationships between at least a portion of the N nodes, the coverage of the at least a portion of the nodes is determined, and based on the coverage, the k anchor nodes in the anchor node set are determined; The coverage of one of the at least some nodes is related to at least one of the following factors: whether there is a reachable path between the node and other nodes, the number of the existing reachable paths, and the number of other nodes reached through the reachable paths.

8. The method according to claim 7, characterized in that, Determining the k anchor nodes in the anchor node set based on the coverage includes: Determine the set of friends of order t for each node in the graph data when the friend order is t. Determine the largest node in the friend set of order t; The largest node is added to the set of anchor nodes as the anchor node; The maximum node and the nodes in the t-order friend set of the maximum node are deleted from the graph data to obtain the deleted graph data. If the number of current anchor nodes in the anchor node set is less than k, and the deleted graph data is not empty, the deleted graph data is used as the graph data for the next iteration, and the step of determining the friend set of each node in the graph data when the friend order is t is returned. If the number of current anchor nodes in the anchor node set is less than k, and the deleted graph data is empty, the nodes in the original graph data that meet the filtering conditions are added to the anchor node set as anchor nodes. Wherein, t is greater than 0 and less than or equal to the longest shortest reachable path among N nodes in the original graph data; the filtering conditions include the first preset number of nodes that have not been added to the anchor node set and have the largest node degree, and the preset number is the difference between k and the current number of anchor nodes in the anchor node set.

9. The method according to claim 8, characterized in that, The method further includes: If there are at least two largest nodes in the t-order friend set, randomly select one of the at least two largest nodes.

10. The method according to any one of claims 5 to 8, characterized in that, The method further includes: Sort the k anchor nodes in the set of anchor nodes; The sorting method includes one of the following: sorting by node identifier, random sorting, or sorting according to the order in which the nodes were added to the anchor node set.

11. The method according to any one of claims 1 to 10, characterized in that, The step of determining at least one recommended friend account for the current user account based on the representation feature vector of each node includes: Calculate the vector distance between the representation feature vector of the node where the current user account is located and the representation feature vector of at least one other node, wherein the at least one other node is at least one node among the N nodes other than the node where the current user account is located; The user account corresponding to at least one other node whose vector distance satisfies the recommendation condition is determined as the at least one recommended friend account of the current user account; The recommendation criteria include the vector distance being less than or equal to a distance threshold.

12. The method according to claim 3 or 4, characterized in that, The method further includes: Obtain sample graph data, which includes N sample nodes and sample edges between the N sample nodes. The sample edges are used to represent sample friend relationships between the N sample nodes. Each of the N sample nodes is used to represent a sample user account, and N is greater than 1. Based on the sample distance between each sample node and at least one sample anchor node, determine the sample distance encoding vector for each sample node; The following processing is performed on the graph neural network model to be trained: Based on the sample distance encoding vector of each sample node, the sample label value of each sample is determined, wherein each sample includes any two sample node pairs, and each sample node pair includes any two sample nodes. The sample distance encoding vector of each sample node is mapped to a predicted representation feature vector; Based on the predicted representation feature vector of each sample node, the predicted label value of each sample is calculated; Based on the predicted label value and the sample label value for each sample, the model parameters of the graph neural network model are optimized.

13. The method according to claim 12, characterized in that, The step of calculating the predicted label value for each sample based on the predicted representation feature vector of each sample node includes: Based on the predicted representation feature vector of each sample node, the predicted query distance of each sample node pair is determined; Calculate the prediction difference between the predicted query distances of the two sample nodes contained in each sample; Based on the activation function of the graph neural network model, the predicted difference of each sample is mapped to obtain the predicted label value of each sample.

14. The method according to claim 12, characterized in that, The process of determining the sample label value for each sample based on the sample distance encoding vector of each sample node includes: Based on the sample distance encoding vector of each sample node, determine the sample query distance of each sample node pair; Calculate the sample difference between the query distances of the two sample nodes contained in each sample to their respective samples; For each sample, if the sample difference is greater than the sample threshold, the sample label value is determined to be a first value; if the sample difference is not greater than the sample threshold, the sample label value is determined to be a second value.

15. The method according to claim 14, characterized in that, Determining the sample query distance for each pair of sample nodes based on the sample distance encoding vector of each sample node includes: For each sample node pair, the sample distance encoding vectors of the two sample nodes in each sample node pair are added together to obtain a summed distance encoding vector; the minimum distance in the summed distance encoding vector is determined as the sample query distance.

16. The method according to any one of claims 12 to 15, characterized in that, The optimization of the model parameters of the graph neural network model based on the predicted label value and the sample label value for each sample includes: Based on the predicted label value and the sample label value for each sample, a binary cross-entropy loss function is determined, and the model parameters of the graph neural network model are optimized by minimizing the binary cross-entropy loss function as the training objective.

17. A friend account recommendation device, characterized in that, The device includes: The acquisition module is used to acquire graph data, which includes N nodes and edges between the N nodes. The edges are used to represent the friend relationships between the N nodes, and each of the N nodes is used to represent a user account. The N is greater than 1. The processing module is used to construct a representation feature vector for each node based on the distance between each node and at least one anchor node. The representation feature vector is used to map the distance information between the current node and the at least one anchor node. The at least one anchor node is determined based on the friend relationships between at least a portion of the N nodes. The recommendation module is used to determine at least one recommended friend account for the current user account based on the representation feature vector of each node.

18. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the friend account recommendation method as described in any one of claims 1 to 16.

19. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is loaded and executed by a processor to implement the friend account recommendation method as described in any one of claims 1 to 16.

20. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, wherein a processor retrieves the computer instructions from the computer-readable storage medium, causing the processor to load and execute them to implement the friend account recommendation method as described in any one of claims 1 to 16.