Prediction model training method and apparatus, and storage medium and electronic device
By performing clustering and feature distance analysis on nodes in the graph structure, negative sample pairs in the intermediate region are determined and used to train the prediction model, the problem of missing information in the graph structure is solved, and the prediction accuracy is improved.
Patent Information
- Application Number
- PCT/CN2023/130951
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-21
- Filing Date
- 2023-11-10
- Publication Date
- 2025-02-27
AI Technical Summary
When using the graph structure to store and display information, the prior art often encounters missing information, which makes the graph structure unable to accurately express the link relationship between entities, making it difficult to predict the link possibility between nodes in the graph structure that have not yet been connected.
By clustering nodes in the sample graph, clustering clusters are determined, and intermediate distances are determined based on the characteristic distances between clustering clusters, thereby determining the intermediate region of the target node. Select nodes with no link relationship with the target node from the intermediate area as negative sample pairs, and combine them with the target nodes to train the prediction model.
Through the negative sample sampling method, the trained prediction model can accurately predict the possibility of link relationships between nodes, improving the accuracy of prediction results.
Smart Images

Figure CN2023130951_27022025_PF_FP_ABST
Abstract
Description
A prediction model training method, device, storage medium and electronic device Technical Field
[0001] The present disclosure relates to the field of graph neural networks, and in particular to a training method, device, storage medium, and electronic device for a prediction model. Background Art
[0002] At present, with the development of computer technology and the need for business integration, graph structures are widely used in various fields such as product recommendation, biological science, and finance due to their ability to model data from a wide range of scenarios.
[0003] However, when using graph structures to store and display information in existing technologies, it's common to encounter situations where certain types of information are missing from the acquired data, resulting in the constructed graph structure being unable to accurately represent the link relationships between entities. In such cases, predicting the likelihood of a link between two nodes in the graph structure that don't yet have an edge becomes increasingly critical based on the existing link relationships.
[0004] Based on this, the present disclosure provides a training method for a prediction model.
[0005] Summary of the Invention
[0006] The present disclosure provides a prediction model training method, device, storage medium, and electronic device to partially address the above-mentioned problems existing in the prior art. The present disclosure adopts the following technical solutions:
[0007] In a first aspect, the present disclosure provides a method for training a prediction model, comprising: determining a sample graph with entities as nodes and relationships between entities as edges; clustering the nodes in the sample graph to determine the clusters in the sample graph, and for each cluster, determining an intermediate distance used to characterize the distance between the cluster and other clusters based on the features of the nodes in the cluster and the features of the nodes in other clusters; determining a target node from the nodes in the sample graph, and determining the nodes included in the intermediate area of the target node based on the position of the target node, the intermediate distance corresponding to the cluster to which the target node belongs, and the position of the nodes in the sample graph; determining a designated node that has no link relationship with the target node from the nodes included in the intermediate area, and combining the designated node and the target node to obtain a first negative sample pair, and determining a positive sample pair based on the original link relationship of the target node in the sample graph; training the prediction model based on the negative sample pairs and the positive sample pairs, wherein the negative sample pairs at least include the first negative sample pair.
[0008] Optionally, determining the sample graph with entities as nodes and the relationships between entities as edges includes: determining multiple entities and the link relationships between the multiple entities based on the user's historical behavior data, the multiple entities including at least one of users, products, user attributes, and product attributes; and constructing the sample graph with the multiple entities as nodes and the link relationships between the multiple entities as edges based on the multiple entities and the link relationships between the multiple entities.
[0009] Optionally, determining the clusters in the sample graph includes: determining a specified number, where the specified number is the number of clusters included in the clustering result; clustering the nodes in the sample graph according to the specified number, and determining a clustering result including the specified number of clusters.
[0010] Optionally, the determination of the intermediate distance used to characterize the distance between the cluster and other clusters includes: taking each cluster in the other clusters as a designated cluster; for each designated cluster, for each node in the cluster, determining the distance between the node and each node in the designated cluster as the first distance; determining the designated distance between the cluster and the designated cluster based on the first distance corresponding to each node in the cluster; and determining the intermediate distance used to characterize the distance between the cluster and other clusters based on the determined designated distance.
[0011] Optionally, the determining of the nodes included in the middle area of the target node based on the position of the target node, the middle distance corresponding to the cluster to which the target node belongs, and the position of each node in the sample graph includes: determining a pending middle area with the position of the target node as the center and the middle distance corresponding to the cluster to which the target node belongs as the radius; and taking the other nodes in the pending middle area, except for the nodes belonging to the same cluster as the target node, as the nodes included in the middle area of the target node.
[0012] Optionally, the method further includes: taking nodes belonging to the same cluster as the target node as nodes in a neighboring area of the target node; and determining, from the nodes included in the neighboring area, a designated node that has no link relationship with the target node.
[0013] Optionally, determining the designated nodes that have no link relationship with the target node from the nodes included in the adjacent area includes: determining the nodes that have no link relationship with the target node from the nodes included in the adjacent area as first designated nodes; determining the designated nodes that have no link relationship with the target node from the nodes included in the middle area includes: determining the nodes that have no link relationship with the target node from the nodes included in the middle area as second designated nodes; the method also includes: sampling the first designated nodes and the second designated nodes according to a preset sampling ratio, and combining the sampled nodes with the target node to obtain the negative sample pairs.
[0014] Optionally, the sampling ratio of the first designated node is lower than the sampling ratio of the second designated node.
[0015] Optionally, the method further includes: taking the adjacent area and the area outside the middle area as a distant area, and determining, from the nodes contained in the distant area, the nodes that have no link relationship with the target node as the third designated nodes; sampling the first designated nodes and the second designated nodes according to a preset sampling ratio, and combining the sampled nodes with the target node respectively to obtain the negative sample pair includes: sampling the first designated nodes, the second designated nodes and the third designated nodes according to a preset sampling ratio, and combining the sampled nodes with the target node respectively to obtain the negative sample pair.
[0016] Optionally, the sampling ratio of the first designated node is lower than the sampling ratio of the second designated node, and the sampling ratio of the third designated node is lower than the sampling ratio of the second designated node.
[0017] In a second aspect, the present disclosure provides a training device for a prediction model, the device comprising: a graph determination module for determining a sample graph with entities as nodes and relationships between entities as edges; a clustering module for clustering the nodes in the sample graph, determining the clusters in the sample graph, and for each cluster, determining an intermediate distance for characterizing the distance between the cluster and other clusters based on the features of the nodes in the cluster and the features of the nodes in other clusters; an area determination module for determining a target node from the nodes in the sample graph, and determining an intermediate distance for characterizing the distance between the cluster and other clusters based on the features of the nodes in the cluster and the features of the nodes in other clusters; and an area determination module for determining a target node from the nodes in the sample graph, and determining an intermediate distance for characterizing the distance between the cluster and other clusters based on the location of the target node and the location of the target node. The method comprises the following steps: first, determining the nodes included in the middle area of the target node based on the middle distance corresponding to the cluster of the genus and the position of each node in the sample graph; second, determining the designated node that has no link relationship with the target node from the nodes included in the middle area, combining the designated node and the target node to obtain a first negative sample pair, and determining a positive sample pair based on the original link relationship of the target node in the sample graph; and third, determining the prediction model based on the negative sample pair and the positive sample pair, wherein the negative sample pair includes at least the first negative sample pair.
[0018] In a third aspect, the present disclosure provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the training method of the prediction model provided in the first aspect.
[0019] In a fourth aspect, the present disclosure provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the training method of the prediction model provided in the first aspect is implemented.
[0020] At least one of the above-mentioned technical solutions adopted in the present disclosure can achieve the following beneficial effects: by clustering the nodes in the sample graph, and then determining the designated node based on the nodes that are close to the target node but have no link relationship with the target node, and combining the designated node and the target node to obtain a negative sample pair, and training the prediction model based on the determined negative sample pair and the positive sample pair determined based on the original link relationship in the sample graph.
[0021] This method fully considers and utilizes the similarity information between nodes for negative sampling, so that the trained prediction model can accurately predict, for a certain node, whether other nodes that are close to the node and nodes that have a certain similarity to the node have a link relationship with the node, that is, the possibility of a link relationship between other nodes and the node, thereby improving the accuracy of the prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:
[0023] FIG1 is a flow chart of a method for training a prediction model according to an embodiment of the present disclosure;
[0024] FIG2 is a flow chart of a sample determination method according to an embodiment of the present disclosure;
[0025] FIG3 is a flow chart of a method for training a prediction model according to an embodiment of the present disclosure;
[0026] FIG4 is a schematic diagram of the structure of a training device for a prediction model provided by an embodiment of the present disclosure;
[0027] FIG5 is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] To make the objectives, technical solutions, and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.
[0029] The technical solutions provided by various embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0030] Currently, a common link prediction method is based on a prediction model. Specifically, a node pair whose likelihood of forming a connection needs to be predicted is identified as the node pair to be predicted. The graph structure containing this node pair is then input into a pre-trained prediction model, which outputs a prediction result for the node pair. This prediction result represents the probability of a connection between the two nodes in the node pair.
[0031] However, currently, a supervised approach can be used in the process of training the prediction model. The existing link relationships in the graph structure (also known as existing edges) can be used to determine positive sample pairs, and the two nodes without edges can be used as negative sample pairs. However, most networks are sparse, resulting in the number of non-existent edges being much greater than the number of existing edges, that is, the number of negative sample pairs is much greater than the number of positive sample pairs. Therefore, random sampling is used to determine the negative sample pairs. However, the negative sample pairs selected by random sampling may include more negative sample pairs with less reference significance, resulting in the prediction model obtained by training being inaccurate.
[0032] Based on this, the present disclosure provides a training method for a prediction model, which clusters the nodes in the sample graph, and then determines the designated node based on the nodes in the clustering results that belong to the same cluster cluster as the target node but have no link relationship with the target node, and the nodes that are close to the target node but have no link relationship with the target node, and combines the designated node and the target node to obtain a negative sample pair, and then trains the prediction model based on the determined negative sample pair.
[0033] Based on the prediction model obtained through training disclosed in the present invention, for each node, it is possible to accurately predict whether other nodes that are close to the node and nodes that have a certain similarity to the node have a link relationship with the node, that is, the possibility of a link relationship between other nodes and the node.
[0034] FIG1 is a flow chart of the training method of the prediction model provided by the present disclosure, which specifically includes the following steps:
[0035] S100: Determine a sample graph with entities as nodes and relationships between entities as edges.
[0036] This disclosure provides a method for training a prediction model. This method can be executed by an electronic device, such as a server, to determine the likelihood of a connection between two nodes in a graph structure. This disclosure uses the example of a server executing this method to illustrate the prediction model training method.
[0037] Based on the above brief description of the training method of the prediction model in the present disclosure, it can be seen that the training method of the prediction model in the present disclosure can first determine the sample graph.
[0038] Among them, the sample graph is a graph structure or knowledge graph with entities as nodes and relationships between entities as edges. Specifically, the server can receive a training request, and the training request can carry a sample graph. Then, the server can parse the received training request and determine the sample graph carried in the training sample. Of course, the above-mentioned training request can also be automatically initiated when the server detects that it meets the training start condition. The training start condition can be that a preset time is reached, or it can be that the sample graph used to train the prediction model has been determined. How and when the training request is generated can be set as needed, and this disclosure does not limit this.
[0039] A graph is a mathematical structure that uses vertices and edges to represent entities and their relationships. Vertices can also be called nodes, and edges can represent link relationships. In a graph, vertices represent entities, and edges represent relationships between entities. For example, in a social network, vertices can represent users, and edges can represent follow or friend relationships between users. The sample graph in the above steps can be a sample graph containing user node data. The server can determine the user's behavioral data and, based on the determined behavioral data, determine each entity and the link relationship between each entity. The entity includes at least one of a user and a user attribute.
[0040] Furthermore, the sample graph in the above steps may be a sample graph comprising user nodes and product nodes. Specifically, the server may determine the user's historical behavior data and, based on the determined historical behavior data, determine entities and the link relationships between entities. The entities include at least one of users, products, user attributes, and product attributes.
[0041] Based on the identified entities and the links between them, the server can construct a sample graph with each entity as a node and each link as an edge. In other words, the constructed sample graph can include user nodes, product nodes, user attribute nodes such as user age and user gender, and product attribute nodes such as product descriptions and user reviews. The specific content of these user attributes and product attributes can be customized as needed and is not limited by this disclosure.
[0042] It should be noted that the nodes in the above sample graph may include not only entity nodes but also modifying nodes. For example, nodes corresponding to adjectives modifying entities, such as "beautiful," "bustling," and "clean." The specific node types included in the sample graph can be set as needed and are not limited in this disclosure.
[0043] Of course, when the nodes contained in the above sample graph describe multiple types of data, such as user nodes, product nodes, nodes describing products, and nodes describing users, the sample graph can be called a heterogeneous graph.
[0044] When the nodes contained in the above sample graph are only nodes corresponding to a certain type of data, such as a sample graph containing only user nodes, or a sample graph containing only product nodes, the sample graph can be called an isomorphic graph.
[0045] When the nodes contained in the above sample graph only describe a type of data, such as there are user nodes and nodes describing users, or there are product nodes and nodes describing products, the sample graph can be called an attribute graph.
[0046] The server can directly execute subsequent steps based on the determined isomorphic graph, heterogeneous graph, or attribute graph, or it can split the heterogeneous graph to obtain split results, and then execute subsequent steps based on the split results. Each split result is a isomorphic subgraph or an attribute subgraph. In other words, the split result may contain only one type of node, or the split result may contain only nodes that describe one type of data.
[0047] It should be noted that the aforementioned isomorphic graphs containing product nodes, isomorphic graphs containing user nodes, and heterogeneous graphs containing both product and user nodes are merely examples of sample graphs. The specific types of sample graphs, the types of nodes contained in the sample graphs, and the specific link relationships represented by the edges between the nodes can be set as needed and are not limited by this disclosure.
[0048] S102: Clustering the nodes in the sample graph to obtain clusters, and for each cluster, determining an intermediate distance for representing the distance between the cluster and other clusters based on the characteristics of the nodes in the cluster and the characteristics of the nodes in other clusters.
[0049] In one or more embodiments provided by the present disclosure, generally, the more similar the node features corresponding to two nodes are, the closer the distance between the two nodes is, and the higher the possibility that the two nodes have a link relationship. Therefore, for each node, how to determine the nodes that are close to the node but do not have a link relationship with the node becomes increasingly important. Therefore, based on the method provided by the present disclosure, the server can determine the nodes that form a negative sample pair with the node from the nodes that are close to the node.
[0050] Vectors are typically used to represent nodes, and calculating vector similarity can measure the differences between node vectors. Methods for calculating vector similarity include, but are not limited to, Euclidean distance, cosine distance, and Hamming distance. An appropriate method for calculating vector similarity can be selected based on the type of node in the sample graph. For example, Euclidean distance can reflect the absolute differences in individual numerical features and is therefore more commonly used in analyses that require differences to be reflected in the numerical magnitude of a dimension. Cosine distance, on the other hand, distinguishes differences in direction and is often used to distinguish similarities and differences in interests using user content ratings. This also corrects for potential inconsistencies in metrics across users.
[0051] In this disclosure, how to measure this "close distance" becomes one of the technical issues that needs to be addressed. For a node, other nodes of the same type as the node are clearly closer to it. Nodes that are not of the same type but whose distance to the node is smaller than the distance between the node's cluster and other clusters are also considered closer. Therefore, the server can train the prediction model based on these two types of nodes.
[0052] In the present disclosure, each node in the sample graph can be clustered, and then for each node, the nodes belonging to the same cluster as the node are taken as nodes in the neighboring area of the node, and the nodes whose distance to the node is less than a preset threshold are combined with the node to determine the negative sample pair.
[0053] Specifically, the server can determine the node characteristics of each node in the sample graph. Then, the server can cluster each node according to the node characteristics corresponding to each node, and the server can determine the clusters contained in the clustering results. Finally, the server can determine, for each cluster, the intermediate distance that can be used to characterize the distance between the cluster and other clusters based on the distance between each node in the cluster and each node in other clusters. That is to say, for each cluster, with the node in the cluster as the center and the intermediate distance as the radius, in the determined intermediate area, there may be no nodes belonging to other clusters, or there may be only some nodes belonging to other clusters. It should be noted that in order to reduce the complexity of subsequent calculations, the cluster where the node is located is regarded as a compressed point.
[0054] In the above process, the server can perform feature extraction on the content corresponding to each node in the sample graph, and obtain the node feature of the node. Take the sample graph containing product nodes and nodes describing the products as an example. The server can determine the content corresponding to each node in the sample graph, and perform feature extraction on the content. The content corresponding to the node can be identifier (ID) type data such as "product name", text data such as "product description", and graphic data such as "product promotional picture". Different types of nodes have corresponding feature extraction methods. The above sample graph containing product nodes and nodes describing the products is only an example. The specific node types contained in the sample graph and how to determine the node features can be set as needed, and the present disclosure does not impose any restrictions on this.
[0055] Of course, the server can also determine, for each node, the neighbor nodes that have a link relationship with the node from the sample graph, and re-determine the node characteristics of the node based on the node characteristics corresponding to each neighbor node, the link relationship between each neighbor node and the node, and the node characteristics corresponding to the node itself.
[0056] In the above process of determining the intermediate distance, the server can determine the cluster center corresponding to each cluster cluster, and determine the intermediate distance of the cluster cluster based on the corresponding distances between the cluster center of the cluster cluster and the cluster centers of other cluster clusters, wherein the intermediate distance can be the average, median, etc. of the above distances. How to determine the intermediate distance can be set according to needs, and the present disclosure does not impose any restrictions on this.
[0057] When clustering each node, the server can use a variety of clustering algorithms such as K-means clustering algorithm, mean shift clustering algorithm, density-based clustering algorithm, etc. Since using clustering algorithms to cluster features is a relatively mature technology, this disclosure will not go into details.
[0058] S104: Determine a target node from each node, and determine each node included in the middle area of the target node according to the position of the target node, the middle distance corresponding to the cluster to which the target node belongs, and the position of each node.
[0059] In one or more embodiments provided herein, as previously described, the server may, for each target node, use the region of the cluster to which the target node belongs as the target node's neighboring region, and use the region whose distance from the target node is less than a distance threshold as the node's intermediate region. Subsequently, negative sample pairs may be determined based on the nodes in the neighboring region and / or intermediate region.
[0060] Specifically, the server may determine a target node from each node. The target node may be determined by the server through random sampling from each node, or may be determined by the server based on the number of neighboring nodes corresponding to each node. Of course, the server may also select each node in the sample graph as the target node. The specific method for determining the target node from each node may be configured as needed and is not limited by this disclosure.
[0061] The server may determine the cluster to which the target node belongs and use other nodes in the cluster to which the target node belongs as nodes included in the neighboring area of the target node. In other words, the server may use the area where the nodes belonging to the same cluster as the target node are located as the neighboring area of the target node.
[0062] Then, the server may determine a middle area of the target node based on the location of the target node and the middle distance of the clusters described by the target node, and determine each node located in the middle area based on the middle area and the locations of each node.
[0063] The server can use the middle distance of the cluster described by the target node as a radius, determine a regular graphic area centered on the position of the target node as a pending middle area, and determine other areas in the pending middle area except the adjacent areas as the middle area of the target node. The regular graphic area can be a circular area, a rectangular area, a parallelogram area, etc. The specific shape corresponding to the regular graphic can be set as needed, and the present disclosure does not limit this. Of course, the middle area can also correspond to an irregular shape, and the specific shape corresponding to the middle area can be set as needed, and the present disclosure does not limit this.
[0064] Finally, the server may determine each node included in the adjacent area and each node included in the middle area, so as to subsequently determine negative sample pairs based on the determined nodes included in the adjacent area and each node included in the middle area.
[0065] S106: Determine a designated node that has no link relationship with the target node from among the nodes included in the middle area, combine the designated node and the target node to obtain a first negative sample pair, and determine a positive sample pair based on the original link relationship of the target node in the sample graph.
[0066] In one or more embodiments provided by the present disclosure, for a target node, the server may determine a node in a sample graph that has a link relationship with the target node, and combine the node with the target node as a positive sample pair.
[0067] It is necessary to combine the target node with a node that is close to the target node but has no link relationship with the target node, and the target node to determine a negative sample pair. As mentioned above, nodes that belong to the same cluster as the node and whose distance to the node is less than the middle distance are all nodes that are closer to the target node. Therefore, the server can determine the first negative sample pair based on the nodes in the middle area. In some examples, the server can also determine the second negative sample pair based on the nodes in the adjacent area. Both the first negative sample pair and the second negative sample pair can be used to train the prediction model.
[0068] Specifically, the server may determine, based on the sample graph, the nodes in the sample graph that have a link relationship with the target node. Then, the server may determine, from the nodes contained in the adjacent area, other nodes except the nodes that have a link relationship with the target node, as nodes that do not have a link relationship with the target node. At the same time, the server may determine, from the nodes contained in the intermediate area, other nodes except the nodes that have a link relationship with the target node, as nodes that do not have a link relationship with the target node. The server may determine a designated node from the determined nodes that do not have a link relationship with the target node, and combine the designated node and the target node to obtain a first negative sample pair and a second negative sample pair.
[0069] S108: Training the prediction model based on the negative sample pairs and the positive sample pairs, wherein the negative sample pairs include at least a first negative sample pair.
[0070] In one or more embodiments provided in the present disclosure, after determining the training samples for training the prediction model, the server may train the prediction model.
[0071] Specifically, the server may input multiple positive sample pairs and multiple negative sample pairs into the prediction model, respectively, to obtain prediction results corresponding to the positive sample pairs and negative sample pairs. The prediction results are used to represent the probability that two nodes included in a positive sample pair have a link relationship, as well as the probability that two nodes included in a negative sample pair have a link relationship. A positive sample pair may be a combination of a node in the sample graph that has a link relationship with the target node and the target node.
[0072] In other words, the server can input a node pair into the prediction model and obtain a prediction result for the node pair output by the prediction model. The prediction result is used to represent the probability that the two nodes included in the node pair have a link relationship. The link relationship can be a subordinate relationship or a relationship corresponding to a specified operation.
[0073] For example, if a node pair contains two nodes, "Product A" and "User B," the link relationship between these two nodes can be that User B has performed a specified operation on Product A, which can be at least one of a purchase operation, a favorite operation, and a click operation. For example, if a node pair contains two nodes, "Product A" and "Component C," the link relationship between these two nodes can be that Product A has Component C.
[0074] After determining the prediction results of the positive sample pair and the prediction results of the negative sample pair, the server can determine the first gap based on the prediction results of the positive sample pair and their annotations, and determine the second gap based on the prediction results of the negative sample pair and their annotations. Finally, the server determines the loss based on the first gap and the second gap, and trains the prediction model with minimizing the loss as the optimization goal.
[0075] In the present disclosure, the trained prediction model can also be used to perform link prediction on a graph to be predicted, which includes multiple pairs of samples to be predicted. It is possible to predict whether there is a link relationship between two nodes to be predicted contained in the sample pair to be predicted. The two nodes to be predicted in the sample pair to be predicted may be a user node and a product node, and the server may predict whether the user corresponding to the user node can purchase the product corresponding to the product node. The above two nodes to be predicted may also be a user node and a user node, and the server may predict whether the users corresponding to the above two nodes know each other, whether they are friends, etc. The above two nodes to be predicted may also be a product node and a description node that describes the product, and the server may predict whether the above description node is used to describe the product corresponding to the product node.
[0076] The server may receive a prediction request, parse the request, and determine the sample pair to be predicted contained in the prediction request. The server may input the sample pair to be predicted into the prediction model, and obtain the link relationship between the two nodes to be predicted contained in the sample pair as a prediction result, as output by the prediction model. The node types corresponding to the two nodes to be predicted in the sample node pair, as well as the specific link relationship type corresponding to the prediction result, may be set as needed and are not limited in this disclosure. The server may return the prediction result based on the prediction request.
[0077] The training method of the prediction model shown in FIG1 is based on clustering each node in the sample graph, and then determining a designated node based on each node in the clustering result that belongs to the same cluster cluster as the target node but has no link relationship with the target node, and each node that is close to the target node but has no link relationship with the target node, and combining the designated node and the target node to obtain a negative sample pair, and training the prediction model based on the determined negative sample pair and the positive sample pair determined based on the original link relationship in the sample graph. This method can fully consider and utilize the similarity information between nodes for negative sampling, so that the trained prediction model can accurately predict, for a certain node, whether other nodes that are close to the node and nodes that have a certain similarity with the node have a link relationship with the node, that is, the possibility of a link relationship between other nodes and the node, thereby improving the accuracy of the prediction results.
[0078] Furthermore, the server may predetermine the number of cluster types that the nodes in the sample graph can be clustered into. When clustering each node, the server may also determine a specified number and, based on the specified number, employ a clustering algorithm to cluster each node in the sample graph, thereby determining a clustering result that includes the specified number of clusters. In other words, the number of clusters included in the clustering result may be a specified number, which may be pre-set.
[0079] Furthermore, the server may determine negative sample pairs in the following manner.
[0080] The server may determine, for each cluster, a designated distance corresponding to each cluster and each other cluster, wherein for each designated distance, the designated distance is used to represent the distance between the cluster and the other cluster corresponding to the designated distance (also referred to as the designated cluster).
[0081] Based on the specified distances corresponding to the cluster, a median distance is determined. The median distance can be used to represent the distance between the cluster and other clusters. The median distance can be a variety of indicators such as the mean or median of the specified data.
[0082] If a region is defined with the target node as the center and the intermediate distance as the radius, the region will contain many nodes that are not linked to the target node but are relatively close to it. Obviously, such nodes need to be accurately distinguished for the prediction model. In other words, based on the sample pairs consisting of nodes that are not specifically connected to the target node but are relatively close to it and the target node, the prediction model can be better trained.
[0083] The server can determine the middle area of the node based on the middle distance and the position of the target node, and determine one or more nodes that have no link relationship with the target node from the middle area according to a preset sampling ratio, and combine the determined one or more nodes with the target node to obtain one or more first negative sample pairs.
[0084] Among them, the above-mentioned specified distance can be determined by various algorithms such as the closest distance algorithm, the farthest distance algorithm, the center of gravity distance algorithm, the middle distance algorithm, etc. The specific method of determining the specified distance can be set as needed, and this disclosure does not impose any restrictions on this.
[0085] In Ω i and Ω j Taking the i-th cluster and the j-th cluster in the clustering result as an example, assuming Ω i Contains N i nodes,Ω j Contains N jnodes, then the specified distance between the two clusters can be:
[0086] Among them, X k To characterize Ω i The kth node in Y l To characterize Ω j The jth cluster can be the specified cluster of the i-th cluster.
[0087] According to the specified distances between the clusters, the middle distance can be determined, wherein the middle distance can be determined by averaging the specified distances or by taking the median of the specified distances. The specific method of determining the middle distance according to the specified distances can be set as needed, and the present disclosure does not impose any restrictions on this.
[0088] Furthermore, the prediction model obtained by training the present disclosure can be used to accurately determine the probability of a link between each node. Taking the example that node A and the target node belong to the same cluster, but there is no link relationship between the node A and the target node in the sample graph, assume that node B and the target node do not belong to the same cluster, and there is no link relationship between node B and the target node in the sample graph. In this case, if the model is used to predict the probability of a link relationship between node A and the target node, and the probability of a link relationship between node B and the target node, then one of the training objectives of the prediction model can be to output that the probability of a link relationship between node A and the target node is higher than the probability of a link relationship between node B and the target node. When constructing negative sample pairs, the number of negative sample pairs composed of other nodes similar to node B and the target node is greater than the number of negative sample pairs composed of other nodes similar to node A and the target node, and the above training objectives can be achieved when training the prediction model. Therefore, the server can also sample the nodes in the adjacent area and the nodes in the middle area based on a preset sampling ratio.
[0089] Specifically, the server may determine, from among the nodes contained in the adjacent area, each node that has no link relationship with the target node as each first designated node. At the same time, the server may determine, from among the nodes contained in the intermediate area, each node that has no link relationship with the target node as each second designated node. The server may sample each first designated node and each second designated node according to a preset sampling ratio to obtain a sampling result. In some examples, the sampling ratio of the first designated node is lower than the sampling ratio of the second designated node; in some examples, the number of the first designated nodes after sampling is less than the number of the second designated nodes after sampling. The server may combine each sampled node with the target node to obtain each first negative sample pair and second negative sample pair.
[0090] In addition, for a target node, if only the nodes in the target node's neighboring and intermediate regions that do not have a link relationship with the target node are considered, the accuracy of the prediction results obtained by the trained prediction model when predicting whether each node in regions other than the neighboring and intermediate regions has a link relationship with the target node may be limited. Therefore, in the present disclosure, sample pairs can also be determined based on nodes in regions other than the neighboring and intermediate regions.
[0091] Specifically, the server may regard other areas outside the adjacent area and the middle area as remote areas, and determine, from among the nodes included in the remote areas, nodes that have no link relationship with the target node as third designated nodes.
[0092] The server may sample each first designated node, each second designated node, and each third designated node according to a preset sampling ratio to obtain a sampling result. The sampling ratio of the first designated node is lower than the sampling ratio of the second designated node; the sampling ratio of the third designated node is also lower than the sampling ratio of the second designated node. In some examples, the number of first designated nodes after sampling is less than the number of second designated nodes after sampling; the number of third designated nodes after sampling is also less than the number of second designated nodes after sampling. Finally, the server may combine each sampled node with the target node to obtain each negative sample pair. The negative sample pair consisting of the third designated node and the target node may be referred to as a third negative sample pair. The third negative sample pair may also be used to train the prediction model.
[0093] Furthermore, in the present disclosure, the server may also determine, for each cluster, an intra-cluster distance representing the distance between nodes in the cluster according to the distance between nodes in the cluster, so as to determine a neighboring area based on the intra-cluster distance.
[0094] Specifically, for each node in the cluster, the distance between the node and other nodes in the cluster is determined as the second distance. According to the second distance corresponding to each node in the cluster, the intra-cluster distance of the cluster is determined. Among them, the distance between other nodes and the node can be the similarity between nodes. Such as Pearson correlation coefficient, Spearman's rank correlation coefficient, Euclidean distance, Chebyshev distance, Minkowski distance, Mahalanobis distance, cosine similarity, Manhattan distance, Hamming distance, edit distance, information entropy, shortest distance, etc. The specific method used to measure the similarity between two vectors or two features can be set as needed, and the present disclosure does not limit this.
[0095] Take X and Y as an example, the node vectors corresponding to two nodes, assuming that the dimension of the node vector is n, x i , y are the i-th components in nodes X and Y respectively. Taking the Euclidean distance to determine the similarity between node vectors as an example, the distance between these two node vectors can be:
[0096] For each node in each cluster, the server may determine the second distance of the node as:
[0097] Among them, X k Used to represent the kth node in the cluster, X l Used to represent the lth node in the cluster, d(X k ,X l ) is used to represent the distance between the two nodes, and N is the number of nodes contained in the cluster.
[0098] Then, according to the second distance corresponding to each node in the cluster, the server can determine the intra-cluster distance of the cluster as:
[0099] Among them, Ω is used to characterize the cluster.
[0100] In addition, to more accurately determine positive and negative sample pairs, after determining each cluster, the server can also determine the corresponding number for each cluster and, for each cluster, label each node within the cluster with the cluster number. Thus, when determining positive and negative sample pairs, the server can determine the nodes within each region corresponding to the target node based solely on the target node number and the numbers of the other nodes. Identical numbers indicate the same cluster, while different numbers indicate different clusters. That is, for each node, if the node number is the same as the target node number, the node can be considered a node within the target node's neighboring region. If the node number is different from the target node number, the node can be considered a node within the target node's intermediate or distant region. Therefore, based on the determined nodes within the target node's neighboring region, intermediate region, and distant region, the server can determine nodes that do not have a link relationship with the target node and combine them with the target node as designated nodes to form negative sample pairs.
[0101] It should be noted that for each node, if the node is in the middle area of the target node, then other nodes belonging to the same cluster as the node are also in the middle area of the target node. In other words, to simplify the processing, for each cluster, the distance between the nodes contained in the cluster can be considered to be 0.
[0102] Based on the same idea, the present disclosure also provides a flow chart of a sample determination method for a prediction model, as shown in FIG2 .
[0103] FIG2 is a flow chart of the sample determination method provided by the present disclosure. The figure includes four stages: stage a, stage b, stage c, and stage d. In stage a, the server can determine a sample graph, which includes two different types of nodes. For the sake of simplicity, the existing links are not drawn in the sample graph. The server can cluster the nodes in the sample graph to obtain clusters as shown in stage b. Nodes filled with different content are used to represent nodes belonging to different clusters, and nodes filled with the same content are used to represent nodes belonging to the same cluster. It can be seen that the number of clusters included in the clustering result in stage B is two. In particular, i1, i3, and e2 are the same cluster; i2 and e1 are the same cluster.
[0104] For example, if the target node is i3 and the middle area is a square, the server can identify nodes i1 and e2, which belong to the same cluster as the target node, as nodes in the adjacent area, and node i2 in the middle area. Because i2 and e1 belong to different nodes within the same cluster, the server can determine that the nodes in the middle area of the target node are nodes i2 and e1, respectively.
[0105] Assuming that only node i1 and target node i3 are connected in the sample graph, the server can combine node i and the target node as a positive sample pair. It can also randomly select any node, such as node i2, from the nodes in the adjacent area that do not have a link relationship with the target node and the nodes in the intermediate area that do not have a link relationship with the target node as a designated node, and combine this designated node with the target node as a negative sample pair.
[0106] The server can display the determined positive and negative sample pairs, as shown in the diagram of stage d. In the diagram, solid lines indicate the presence of a link relationship, and dashed lines indicate the absence of a link relationship. The diagram of stage d is merely an example of positive and negative sample pairs.
[0107] It should be noted that the above description only takes the example of determining the combination of nodes in the middle area and the distant area with the target node to form a sample pair. The specific method of determining the sample pairs based on the nodes in the adjacent area, the nodes in the middle area and the nodes in the distant area can be set as needed, and the present disclosure does not impose any restrictions on this.
[0108] Based on the same idea, the present disclosure provides a flow chart of a model training method, as shown in FIG3 .
[0109] FIG3 is a flow chart of the training method of the prediction model provided by the present disclosure. After determining the positive sample pairs and the negative sample pairs, the server can use multiple positive sample pairs and multiple negative sample pairs as inputs and input them into the feature extraction layer of the prediction model to obtain the sample pair features output by the feature extraction layer. The sample pair features are then input into the prediction layer to obtain the prediction results of the positive samples and the prediction results of the negative samples output by the prediction layer, respectively. The first gap is determined based on the prediction results of the positive samples and the annotations of the positive samples, and the second gap is determined based on the prediction results of the negative samples and the annotations of the negative samples. Finally, the server can determine the loss based on the first gap and the second gap, and train the prediction model with minimizing the loss as the optimization goal.
[0110] The server can also determine, for each node, an enhanced feature of the node based on the node features of its neighboring nodes in the sample graph and the node features of the node itself. Then, for each determined sample pair, the server can determine a prediction result for the sample pair based on the enhanced features corresponding to the two nodes in the sample pair. Based on the prediction results and annotations for each sample pair, the server can determine the loss, with minimizing the loss as the optimization goal.
[0111] The training objective of the prediction model can be to minimize the difference between the prediction result and the annotation of each sample pair for each sample pair. Alternatively, for any two nodes that have a link relationship in the sample graph, the prediction result of the sample pair formed by these two nodes is higher than the prediction result of the sample pair formed by the two nodes that do not have a link relationship in the sample graph.
[0112] Taking the output of the link prediction period as s as an example, assume that E is the set of link pairs in the sample graph, E - is the set of unlinked pairs in the sample graph. Then the optimization objective of the prediction model can be:
[0113] Among them, s uj and s kl is the output of the link predictor. i ,v j are two nodes with link relationship in the sample graph, v k ,v l are two nodes that have no link relationship in the sample graph.
[0114] Based on the same idea, the present disclosure also provides a prediction model training device, as shown in Figure 4. Figure 4 is a schematic diagram of the structure of the prediction model training device provided by the present disclosure, which includes the following modules.
[0115] The graph determination module 200 is used to determine a sample graph with entities as nodes and relationships between entities as edges.
[0116] The clustering module 202 is used to cluster the nodes in the sample graph, determine the clusters in the sample graph, and for each cluster, determine the intermediate distance used to characterize the distance between the cluster and other clusters based on the characteristics of the nodes in the cluster and the characteristics of the nodes in other clusters.
[0117] The region determination module 204 is used to determine the target node from the nodes in the sample graph, and determine the nodes included in the middle region of the target node based on the position of the target node, the middle distance corresponding to the cluster to which the target node belongs, and the position of each node in the sample graph.
[0118] The sample determination module 206 is used to determine, from the nodes contained in the middle area, a designated node that has no link relationship with the target node, and combine the designated node and the target node to obtain a first negative sample pair, and determine a positive sample pair based on the original link relationship of the target node in the sample graph.
[0119] The training module 208 is configured to train the prediction model based on the negative sample pairs and the positive sample pairs, wherein the negative sample pairs include at least the first negative sample pair.
[0120] Optionally, the graph determination module 200 is used to determine multiple entities and the link relationships between the multiple entities based on the user's historical behavior data, where the multiple entities include at least one of users, products, user attributes, and product attributes; and based on the multiple entities and the link relationships between the multiple entities, construct the sample graph with the multiple entities as nodes and the link relationships between the multiple entities as edges.
[0121] Optionally, the clustering module 202 is configured to determine a specified number, where the specified number is the number of clusters included in the clustering result; cluster each node in the sample graph according to the specified number to determine a clustering result including the specified number of clusters.
[0122] Optionally, the clustering module 202 is used to use each cluster in other clusters as a designated cluster; for each designated cluster, for each node in the cluster, the distance between the node and each node in the designated cluster is determined as the first distance; based on the first distances corresponding to each node in the cluster, the designated distance between the cluster and the designated cluster is determined; based on the determined designated distance, the intermediate distance used to characterize the distance between the cluster and other clusters is determined.
[0123] Optionally, the area determination module 204 is used to determine the pending middle area with the position of the target node as the center and the middle distance corresponding to the cluster to which the target node belongs as the radius; and to take the other nodes in the pending middle area except the nodes belonging to the same cluster as the target node as the nodes included in the middle area of the target node.
[0124] Optionally, the device further includes a determination module for taking nodes belonging to the same cluster as the target node as nodes in the neighboring area of the target node; and determining, from the nodes included in the neighboring area, a designated node that has no link relationship with the target node.
[0125] Optionally, the determination module is further configured to determine, from among the nodes included in the adjacent region, nodes that do not have a link relationship with the target node, as first designated nodes. The sample determination module 206 determines, from among the nodes included in the intermediate region, nodes that do not have a link relationship with the target node, as second designated nodes; samples the first designated nodes and the second designated nodes according to a preset sampling ratio, and combines the sampled nodes with the target node to obtain the negative sample pairs.
[0126] Optionally, the sampling ratio of the first designated node is lower than the sampling ratio of the second designated node.
[0127] Optionally, the determination module is further configured to define the area outside the adjacent area and the middle area as a distant area, and to determine, from the nodes included in the distant area, nodes that do not have a link relationship with the target node as third designated nodes. The sample determination module 206 is configured to sample the first designated nodes, the second designated nodes, and the third designated nodes, respectively, according to a preset sampling ratio, and to combine the sampled nodes with the target node to obtain the negative sample pairs.
[0128] Optionally, the sampling ratio of the first designated node is lower than the sampling ratio of the second designated node, and the sampling ratio of the third designated node is lower than the sampling ratio of the second designated node.
[0129] The present disclosure also provides a computer-readable storage medium storing a computer program, which can be used to execute the training method of the prediction model provided in Figure 1. The computer-readable storage medium may include a non-volatile computer-readable storage medium.
[0130] The present disclosure also provides a schematic structural diagram of an electronic device as shown in Figure 5. As shown in Figure 5, at the hardware level, the electronic device includes a processor and a memory. Among them, the memory may include internal memory and non-volatile memory, and of course may also include hardware required for other services, such as internal bus, network interface, etc. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the training method of the prediction model described in Figure 1 above. Of course, in addition to software implementation, the present disclosure does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0131] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly performed using "logic compiler" software. This is similar to the software compiler used during program development. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0132] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
[0133] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0134] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing the present disclosure, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0135] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0136] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable lesion detection device to produce a machine, so that the instructions executed by the processor of the computer or other programmable lesion detection device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0137] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable lesion detection device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0138] These computer program instructions may also be loaded onto a computer or other programmable lesion detection device so that a series of operating steps are performed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0139] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0140] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0141] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0142] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0143] Those skilled in the art will appreciate that embodiments of the present disclosure may be provided as methods, systems, or computer program products. Thus, the present disclosure may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0144] The present disclosure may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present disclosure may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0145] The various embodiments of this disclosure are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, refer to the description of the method embodiments.
[0146] The foregoing is merely an embodiment of the present disclosure and is not intended to limit the present disclosure. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure are intended to be included within the scope of the claims of the present disclosure.
Claims
1. A prediction model training method, characterized in that: The method comprises: Determine a sample graph with entities as nodes and relationships between entities as edges; Clustering each node in the sample graph to determine each cluster in the sample graph, and for each cluster, determining an intermediate distance for characterizing the distance between the cluster and other clusters according to the characteristics of each node in the cluster and the characteristics of each node in other clusters; Determine a target node from each node in the sample graph, and determine each node included in the middle area of the target node according to the position of the target node, the middle distance corresponding to the cluster to which the target node belongs, and the position of each node in the sample graph; Determine, from each node included in the middle area, a designated node that has no link relationship with the target node, and combine the designated node and the target node to obtain a first negative sample pair, and determine a positive sample pair according to the original link relationship of the target node in the sample graph; The prediction model is trained according to the negative sample pairs and the positive sample pairs, wherein the negative sample pairs include at least a first negative sample pair.
2. The method according to claim 1, characterized in that Determining a sample graph with entities as nodes and relationships between entities as edges includes: Determine, based on the historical behavior data of the user, a plurality of entities and link relationships between the plurality of entities, wherein the plurality of entities include at least one of a user, a product, a user attribute, and a product attribute; According to the multiple entities and the link relationships between the multiple entities, the sample graph is constructed with the multiple entities as nodes and the link relationships between the multiple entities as edges.
3. The method according to claim 1, characterized in that The determining of each cluster in the sample graph comprises: Determine a specified number, where the specified number is the number of clusters included in the clustering result; According to the specified number, each node in the sample graph is clustered to determine a clustering result containing the specified number of clusters.
4. The method according to claim 1, characterized in that The determining of the intermediate distance used to characterize the distance between the cluster and other clusters includes: Each cluster in the other clusters is used as a designated cluster; For each specified cluster, For each node in the cluster, determine the distance between the node and each node in the specified cluster as a first distance; Determine a specified distance between the cluster and the specified cluster according to the first distances respectively corresponding to the nodes in the cluster; According to the determined designated distance, an intermediate distance for characterizing the distance between the cluster and other clusters is determined.
5. The method according to claim 1, characterized in that The determining of the nodes included in the middle area of the target node according to the position of the target node, the middle distance corresponding to the cluster to which the target node belongs, and the position of each node in the sample graph comprises: Taking the position of the target node as the center and the middle distance corresponding to the cluster to which the target node belongs as the radius, determine the middle area to be determined; The other nodes in the to-be-determined middle region except the nodes belonging to the same cluster as the target node are regarded as the nodes included in the middle region of the target node.
6. The method according to claim 1, characterized in that The method further comprises: Taking nodes belonging to the same cluster as the target node as nodes in the neighboring area of the target node; A designated node having no link relationship with the target node is determined from among the nodes included in the neighboring area.
7. The method according to claim 6, characterized in that Determining the designated nodes that have no link relationship with the target node from the nodes included in the adjacent area includes: determining the nodes that have no link relationship with the target node from the nodes included in the adjacent area as the first designated nodes; Determining the designated nodes that have no link relationship with the target node from the nodes included in the middle area includes: determining the nodes that have no link relationship with the target node from the nodes included in the middle area as the second designated nodes; The method further includes: sampling the first designated nodes and the second designated nodes according to a preset sampling ratio, and combining the sampled nodes with the target node to obtain the negative sample pair.
8. The method according to claim 7, characterized in that The sampling ratio of the first designated node is lower than the sampling ratio of the second designated node.
9. The method according to claim 7, characterized in that The method further comprises: The adjacent area and the area outside the middle area are regarded as remote areas, and nodes that have no link relationship with the target node are determined from the nodes included in the remote areas as third designated nodes; The step of sampling the first designated nodes and the second designated nodes according to a preset sampling ratio, and combining the sampled nodes with the target node to obtain the negative sample pair includes: According to a preset sampling ratio, the first designated nodes, the second designated nodes and the third designated nodes are sampled respectively, and the sampled nodes are combined with the target node respectively to obtain the Negative sample pairs.
10. The method according to claim 9, characterized in that The sampling ratio of the first designated node is lower than the sampling ratio of the second designated node, and the sampling ratio of the third designated node is lower than the sampling ratio of the second designated node.
11. A training device for a prediction model, characterized in that: The device comprises: A graph determination module, used to determine a sample graph with entities as nodes and relationships between entities as edges; A clustering module, used to cluster the nodes in the sample graph, determine the clusters in the sample graph, and for each cluster, determine an intermediate distance for representing the distance between the cluster and other clusters according to the characteristics of each node in the cluster and the characteristics of each node in other clusters; A region determination module, used to determine a target node from each node in the sample graph, and determine each node included in the middle region of the target node according to the position of the target node, the middle distance corresponding to the cluster to which the target node belongs, and the position of each node in the sample graph; A sample determination module, configured to determine, from the nodes included in the middle area, a designated node that has no link relationship with the target node, and combine the designated node with the target node to obtain a first negative sample pair, and determine a positive sample pair according to the original link relationship of the target node in the sample graph; A training module is used to train the prediction model according to the negative sample pairs and the positive sample pairs, wherein the negative sample pairs include at least the first negative sample pair.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Data processing method, device and equipment
CN115859110A
Multi-modal negative sample construction method and device, model pre-training method and device, equipment and medium
CN116127319A
Task execution method and device, storage medium and electronic equipment
CN116402113A
Prediction model training method and device, storage medium and electronic equipment
CN116757278A
Clustering device, method, and program
JP2013156697A