Model training method, device and equipment for heterogeneous network graphs
By constructing data augmentation and edge deletion processing of heterogeneous network matrix, positive and negative samples are generated for comparison learning, the problem of heterogeneous network graph training depends on label data, and efficient and accurate model training effect is achieved.
Patent Information
- Application Number
- CN202210653525.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-06-09
AI Technical Summary
In the prior art, model training of heterogeneous network graphs relies on label data, resulting in low training efficiency and inability to effectively utilize the potential of network representation learning.
By constructing a heterogeneous network matrix, data augmentation and edge deletion are performed, positive and negative samples are generated, and model training is performed using the comparison learning between positive and negative samples to avoid relying on label data.
It improves the model training efficiency and accuracy of heterogeneous network graphs, and can perform effective model training in the absence of label data, taking into account both global and local features, improving the overall performance of the model.
Smart Images

Figure CN117271833B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer and Internet technology, and in particular to a model training method, apparatus, device and storage medium for heterogeneous network graphs. Background Art
[0002] Heterogeneous network graphs are widely used to describe complex relationships between things.
[0003] At present, in the field of graph analysis, in order to facilitate the further processing of heterogeneous network graphs by downstream tasks, the heterogeneous network graphs are mapped from high-dimensional space to low-dimensional space through network representation learning, and low-dimensional vectors are used to represent the structural features of the heterogeneous network graphs, so that downstream tasks can continue to further mine and process the information in the heterogeneous network graphs based on low-dimensional vectors.
[0004] However, in the above-mentioned related technologies, it is necessary to construct sample data and label data corresponding to heterogeneous network graphs in network representation learning. Network representation learning depends on label data, and the construction of label data leads to low overall training efficiency for heterogeneous network graphs. Summary of the Invention
[0005] The embodiments of the present application provide a method, apparatus, device, and storage medium for model training of heterogeneous network graphs, which improve the overall efficiency and accuracy of model training of heterogeneous network graphs. The technical solution is as follows.
[0006] According to one aspect of an embodiment of the present application, a model training method for a heterogeneous network graph is provided, the method comprising the following steps:
[0007] Constructing a heterogeneous network matrix based on the heterogeneous network graph, wherein the heterogeneous network matrix is used to characterize the structural characteristics of the heterogeneous network graph; wherein the data of the first target row in the heterogeneous network matrix is used to characterize the adjacency relationship between the first target node and other nodes in the heterogeneous network graph;
[0008] Performing data augmentation processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix; wherein the positive sample node representation matrix is used to represent node features in the heterogeneous network graph after the data augmentation processing, and the positive sample graph representation vector is used to represent graph features in the heterogeneous network graph after the data augmentation processing;
[0009] Performing edge deletion processing on the heterogeneous network matrix to obtain a negative sample node representation matrix and a negative sample graph representation vector corresponding to the heterogeneous network matrix; wherein the negative sample node representation matrix is used to represent node features in the heterogeneous network graph after the edge deletion processing, and the negative sample graph representation vector is used to represent graph features in the heterogeneous network graph after the edge deletion processing;
[0010] Determining a first loss of a target model based on the positive sample node representation matrix and the negative sample node representation matrix, where the first loss is used to measure the accuracy of the target model from a node dimension;
[0011] Determining a second loss of the target model based on the positive sample graph representation vector and the negative sample graph representation vector, where the second loss is used to measure the accuracy of the target model from a graph dimension;
[0012] The target model is trained according to the first loss and the second loss, and the target model is used to determine the low-dimensional node representation matrix and low-dimensional graph vector representation of the heterogeneous network graph after dimensionality reduction.
[0013] According to one aspect of an embodiment of the present application, a model training device for a heterogeneous network graph is provided, the device comprising the following modules:
[0014] A matrix construction module is used to construct a heterogeneous network matrix based on a heterogeneous network graph, wherein the heterogeneous network matrix is used to characterize the structural characteristics of the heterogeneous network graph; wherein the data of the first target row in the heterogeneous network matrix is used to characterize the adjacency relationship between the first target node and other nodes in the heterogeneous network graph;
[0015] A data enhancement module is used to perform data enhancement processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix; wherein the positive sample node representation matrix is used to represent the node features in the heterogeneous network graph after the data enhancement processing, and the positive sample graph representation vector is used to represent the graph features in the heterogeneous network graph after the data enhancement processing;
[0016] A data deletion module is used to perform edge deletion processing on the heterogeneous network matrix to obtain a negative sample node representation matrix and a negative sample graph representation vector corresponding to the heterogeneous network matrix; wherein the negative sample node representation matrix is used to represent the node features in the heterogeneous network graph after the edge deletion processing, and the negative sample graph representation vector is used to represent the graph features in the heterogeneous network graph after the edge deletion processing;
[0017] a loss determination module, configured to determine a first loss of a target model based on the positive sample node representation matrix and the negative sample node representation matrix, wherein the first loss is used to measure the accuracy of the target model from a node dimension;
[0018] The loss determination module is further configured to determine a second loss of the target model based on the positive sample graph representation vector and the negative sample graph representation vector, wherein the second loss is used to measure the accuracy of the target model from a graph dimension;
[0019] A model training module is used to train the target model according to the first loss and the second loss, and the target model is used to determine the low-dimensional node representation matrix and low-dimensional graph vector representation of the heterogeneous network graph after dimensionality reduction.
[0020] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one program, and the at least one program is loaded and executed by the processor to implement the above-mentioned model training method for heterogeneous network graphs.
[0021] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer-readable storage medium, in which at least one program is stored, and the at least one program is loaded and executed by a processor to implement the above-mentioned model training method for heterogeneous network graphs.
[0022] According to one aspect of an embodiment of the present application, a computer program product or computer program is provided, comprising 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 computer device to perform the aforementioned model training method for a heterogeneous network graph.
[0023] The technical solutions provided in the embodiments of the present application can bring the following beneficial effects:
[0024] By performing data enhancement processing on the heterogeneous network matrix, positive samples corresponding to the heterogeneous network matrix are constructed. By performing edge deletion processing on the heterogeneous network matrix, negative samples corresponding to the heterogeneous network matrix are constructed. Then, the model is trained based on the positive samples and negative samples. That is, the model is trained through comparative learning between the positive samples and the negative samples, and there is no need to obtain label data corresponding to the sample data, thereby improving the overall efficiency of model training for the heterogeneous network graph. Moreover, the positive samples include a positive sample node representation matrix and a positive sample graph representation vector, and the negative samples include a negative sample node representation matrix and a negative sample graph representation vector. The node representation matrix is used to represent the local features at the node level in the heterogeneous network graph, and the graph representation vector is used to represent the global features at the graph level in the heterogeneous network graph. During the model training process, both global features and fine-grained local features are considered, thereby improving the accuracy of model training. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is a schematic diagram of a model training system for heterogeneous network graphs provided by one embodiment of the present application;
[0026] Figure 2 A schematic diagram of a model training system for heterogeneous network graphs is exemplarily shown;
[0027] Figure 3 This is a flowchart of a model training method for a heterogeneous network graph provided by one embodiment of the present application;
[0028] Figure 4 A schematic diagram of a heterogeneous network graph is exemplarily shown;
[0029] Figure 5 A schematic diagram of a heterogeneous network subgraph is exemplarily shown;
[0030] Figure 6 A schematic diagram of a heterogeneous network graph after edge deletion is exemplarily shown;
[0031] Figure 7 A schematic diagram illustrating a process of a model training method for a heterogeneous network graph is shown;
[0032] Figure 8 This is a flowchart of a model training method for a heterogeneous network graph provided by another embodiment of the present application;
[0033] Figure 9 This is a block diagram of a model training device for a heterogeneous network graph provided by one embodiment of the present application;
[0034] Figure 10 is a block diagram of a model training device for a heterogeneous network graph provided by another embodiment of the present application;
[0035] Figure 11 This is a structural block diagram of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0037] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also involves studying the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0038] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0039] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.
[0040] The solutions provided in the embodiments of this application involve technologies such as machine learning of artificial intelligence, which are specifically illustrated by the following embodiments.
[0041] Please refer to Figure 1 , which shows a schematic diagram of a model training system for heterogeneous network graphs provided by an embodiment of the present application. The model training system for heterogeneous network graphs may include a terminal device 10 and a server 20.
[0042] The terminal device 10 can be an electronic device such as a mobile phone, a tablet computer, a PC (Personal Computer), an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc., and the embodiments of the present application are not limited to this.
[0043] Server 20 is a model training device for heterogeneous network graphs. Server 20 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0044] The terminal device 10 and the server 20 may be connected directly or indirectly via wired or wireless communication, which is not limited in this application.
[0045] In some embodiments, during the model training process for heterogeneous network graphs, the terminal device 10 is used to collect heterogeneous network graphs, and the server 20 is used to process and train the model for the heterogeneous network graphs. Figure 2 As shown, the terminal device 10 collects and obtains a heterogeneous network graph. Furthermore, the server 20 performs data processing on the heterogeneous network graph to construct a heterogeneous network matrix corresponding to the heterogeneous network graph. The server 20 then performs data augmentation on the heterogeneous network graph, constructing multiple heterogeneous network sub-matrices corresponding to the heterogeneous network sub-graphs based on the heterogeneous network matrix. The server 20 then linearly fuses the multiple heterogeneous network sub-matrices to obtain a positive sample matrix corresponding to the heterogeneous network matrix. Based on the positive sample matrix, the server 20 then determines a positive sample node representation matrix and a positive sample graph representation vector. Furthermore, the server 20 performs edge deletion on the heterogeneous network graph, deleting a target number of target-type edges from the heterogeneous network matrix to obtain a negative sample matrix corresponding to the heterogeneous network matrix. Based on the negative sample matrix, the server 20 then determines a first loss for the target model based on the positive sample node representation matrix and the negative sample node representation matrix, and determines a second loss for the target model based on the positive sample graph representation vector and the negative sample graph representation vector. The target model is then trained in both the node and graph dimensions using the first and second losses as benchmarks.
[0046] It should be noted that the above introduction to the terminal device 10 and the server 20 is only exemplary and explanatory. In an exemplary embodiment, the functions of the terminal device 10 and the server 20 can be flexibly set and adjusted. For example, in the process of model training for a heterogeneous network graph, if the load capacity of the server 20 allows, the server 20 does not rely on the above-mentioned terminal device 10, and performs data collection, data processing and model training at the same time; or, in the process of model training for a heterogeneous network graph, the terminal device 10 provides a visual configuration interface to the staff, so that the staff can configure relevant training parameters in the visual configuration interface, such as the type of nodes contained in the heterogeneous network graph, the type of edges to be deleted, the number of edges to be deleted, etc., and then the server 20 performs data collection, data processing and model training based on the relevant training parameters configured by the staff.
[0047] Please refer to Figure 3 , which shows a flow chart of a model training method for heterogeneous network graphs provided by an embodiment of the present application. The steps in this method can be Figure 1 The terminal device 10 and / or server 20 (hereinafter collectively referred to as "computer device") is executed. The method may include at least one of the following steps (301-306):
[0048] Step 301: construct a heterogeneous network matrix based on the heterogeneous network graph.
[0049] A heterogeneous network graph refers to a network structure composed of different types of nodes and edges. For example, Figure 4 As shown, the heterogeneous network graph 40 includes four different types of nodes: author (A), paper (P), conference (C), and keyword (T), and three different types of edges: paper-author (PA), paper-conference (PC), and paper-keyword (PT). In the embodiment of the present application, before model training, the computer device obtains the heterogeneous network graph.
[0050] In one possible implementation, in order to improve the efficiency of obtaining heterogeneous network diagrams, the heterogeneous network diagrams are pre-stored data. The heterogeneous network diagrams can be stored locally on a computer device or on other electronic devices outside the computer device, and the embodiments of the present application are not limited thereto. For example, the heterogeneous network diagrams are stored in a database. In short, a database can be regarded as an electronic filing cabinet - a place where electronic files are stored, and users can add, query, update, delete, and perform other operations on the data in the files. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application program. A database management system (DBMS) is a computer software system designed for managing databases, which generally has basic functions such as storage, interception, security, and backup. Database management systems can be classified based on the database models they support, such as relational and XML (Extensible Markup Language); or based on the types of computers they support, such as server clusters and mobile phones; or based on the query languages used, such as SQL (Structured Query Language) and XQuery; or based on performance focus, such as maximum scale and maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages at the same time. In some embodiments, different heterogeneous network graphs are classified and stored in the database based on the node types contained in the heterogeneous network graphs; or different heterogeneous network graphs are classified and stored in the database based on the edge types contained in the heterogeneous network.
[0051] In another possible implementation, to improve the real-time performance of the heterogeneous network graph, the heterogeneous network graph is data acquired in real time. In some embodiments, the computer device uses web crawler technology to determine and collect multiple nodes of various types, and constructs the heterogeneous network graph in real time based on the relationships between the nodes.
[0052] In some embodiments, the computer device obtains a heterogeneous network diagram based on the downstream tasks corresponding to the heterogeneous network diagram. For example, if the downstream task corresponding to the target model is the research on author articles in the field of education, the heterogeneous network diagram obtained by the computer device includes three types of nodes: authors, papers, and keywords; if the downstream task corresponding to the target model is the research on symptoms and diseases in the medical field, the heterogeneous network diagram obtained by the computer device includes three types of nodes: symptoms, diseases, and drugs; and so on. It should be noted that the downstream tasks only limit some node types in the heterogeneous network diagram; for example, in the research on author articles, the three types of nodes: authors, papers, and keywords are important nodes. In addition to the three types of nodes: authors, papers, and keywords, the heterogeneous network diagram may also include other types of non-important nodes, which are not limited in the embodiments of the present application.
[0053] In an embodiment of the present application, after obtaining the above-mentioned heterogeneous network graph, the computer device constructs a heterogeneous network matrix based on the heterogeneous network graph. The heterogeneous network matrix is used to characterize the structural characteristics of the heterogeneous network graph. In the heterogeneous network matrix, each row of data represents the adjacency relationship between a node and other nodes in the heterogeneous network graph. Taking the first target row in the heterogeneous network matrix as an example, the data of the first target row is used to characterize the adjacency relationship between the first target node and other nodes in the heterogeneous network graph. The first target node can be any node in the heterogeneous network graph. Exemplarily, the heterogeneous network matrix can also be called the adjacency matrix of the nodes in the heterogeneous network graph.
[0054] It should be noted that the above introduction to the collection of heterogeneous network graphs and the construction of heterogeneous network matrices is merely exemplary and explanatory. In exemplary embodiments, the collection of heterogeneous network graphs and the construction of heterogeneous network matrices can be flexibly set and adjusted. Exemplarily, the above heterogeneous network matrix is a matrix constructed in real time. When the computer device determines to train the target model, the heterogeneous network matrix is constructed in real time based on the collected heterogeneous network graph; or, the above heterogeneous network matrix is a pre-constructed matrix. After collecting the heterogeneous network graph, the computer device constructs and stores the heterogeneous network matrix based on the heterogeneous network graph to improve the efficiency of obtaining the heterogeneous network matrix when subsequently obtaining the heterogeneous network matrix.
[0055] Step 302: Perform data enhancement processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix.
[0056] In an embodiment of the present application, after obtaining the above-mentioned heterogeneous network matrix, the computer device performs data enhancement processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix. Among them, the positive sample node representation matrix is used to characterize the node features in the heterogeneous network graph after data enhancement processing, and the positive sample graph representation vector is used to characterize the graph features in the heterogeneous network graph after data enhancement processing. Exemplarily, the above-mentioned node features are local features, which can be understood as the features between a single node and adjacent nodes; the above-mentioned graph features are global features, which can be understood as the structural features of the network structure composed of each node in the heterogeneous network graph.
[0057] In some embodiments, the computer device constructs a heterogeneous network sub-matrix based on the heterogeneous network matrix, and then linearly fuses the heterogeneous network sub-matrix to achieve data enhancement processing for the heterogeneous network matrix. Please refer to the following for details and will not be described here.
[0058] Step 303: perform edge deletion processing on the heterogeneous network matrix to obtain a negative sample node representation matrix and a negative sample graph representation vector corresponding to the heterogeneous network matrix.
[0059] In an embodiment of the present application, after obtaining the heterogeneous network matrix, the computer device performs edge deletion processing on the heterogeneous network matrix to obtain a negative sample node representation matrix and a negative sample graph representation vector corresponding to the heterogeneous network matrix. The negative sample node representation matrix is used to represent the node features in the heterogeneous network graph after the edge deletion processing, and the negative sample graph representation vector is used to represent the graph features in the heterogeneous network graph after the edge deletion processing.
[0060] In some embodiments, the computer device deletes a certain number of edges of a certain type to implement edge deletion processing in a heterogeneous network matrix. Please refer to the following for details and will not be described in detail here.
[0061] It should be noted that the above-mentioned timing limitation of step 302 and step 303 is only exemplary and explanatory. In the exemplary embodiment, the execution order of step 302 and step 303 can be flexibly set and adjusted according to the actual situation. For example, when the computer device load allows, step 302 and step 303 are executed at the same time; when the computer device load is large, step 302 is executed first and then step 303, or step 303 is executed first and then step 302. The embodiment of the present application does not limit this. Of course, in the exemplary embodiment, step 302 can also be executed by the first computer device and step 303 can be executed by the second computer device. Then, during model training, data aggregation is performed by the first computer device and the second computer device. The embodiment of the present application does not limit this.
[0062] Step 304: Determine a first loss of the target model based on the positive sample node representation matrix and the negative sample node representation matrix.
[0063] In an embodiment of the present application, after obtaining the positive sample node representation matrix and the negative sample node representation matrix, the computer device determines a first loss of the target model based on the positive sample node representation matrix and the negative sample node representation matrix. The first loss is used to measure the accuracy of the target model from a node dimension.
[0064] In some embodiments, the computer device clusters the nodes to measure the accuracy of the target model from the node dimension. In an exemplary embodiment, the above step 304 includes at least one of the following steps:
[0065] 1. Based on the positive sample node representation matrix, determine the distance between the positive sample node pairs in the positive sample node representation matrix;
[0066] 2. Based on the negative sample node representation matrix, determine the distance between the negative sample node pairs in the negative sample node representation matrix;
[0067] 3. Determine the first loss of the target model based on the distance between the positive sample node pairs and the distance between the negative sample node pairs.
[0068] The positive sample node pair includes two nodes having an adjacency relationship in the positive sample node representation matrix. The negative sample node pair includes two nodes having an adjacency relationship in the negative sample node representation matrix. In an embodiment of the present application, after obtaining the above-mentioned positive sample node representation matrix, the computer device determines the distance between the positive sample node pairs in the positive sample node representation matrix based on the positive sample node representation matrix to characterize the clustering results between the positive sample nodes in the positive sample node representation matrix; similarly, after obtaining the above-mentioned negative sample node representation matrix, the computer device determines the distance between the negative sample node pairs in the negative sample node representation matrix based on the negative sample node representation matrix to characterize the clustering results between the negative sample nodes in the negative sample node representation matrix. Thereafter, the computer device determines the first loss of the target model based on the distance between the positive sample node pairs and the distance between the negative sample node pairs.
[0069] For example, assume that the positive sample node representation matrix is Z n-sub And the negative sample node representation matrix is Z n-del , then the first loss L node for:
[0070]
[0071] Among them, the sim() function is used to calculate the cosine similarity between two vectors, Z n-sub , Z n-del ∈RN×D , R represents the Euclidean space, N represents the total number of nodes in the heterogeneous network graph, and D represents the dimension of the vector.
[0072] It should be noted that the above-mentioned formula for the first loss is only exemplary and explanatory. In the exemplary embodiment, the calculation method of the distance between node pairs can be flexibly set and adjusted according to actual conditions, and the embodiments of the present application do not limit this.
[0073] Step 305: Determine a second loss of the target model based on the positive sample image representation vector and the negative sample image representation vector.
[0074] In an embodiment of the present application, after obtaining the positive sample image representation vector and the negative sample image representation vector, the computer device determines a second loss of the target model based on the positive sample image representation vector and the negative sample image representation vector. The second loss is used to measure the accuracy of the target model from the graph dimension.
[0075] In some embodiments, the computer device determines the second loss of the target model by using the mutual information between the positive sample image representation vector and the negative sample image representation vector. In an exemplary embodiment, the above step 305 includes at least one of the following steps:
[0076] 1. Obtain the mutual information between the positive sample image representation vector and the negative sample image representation vector;
[0077] 2. Determine the second loss of the target model based on the mutual information.
[0078] For example, assume that the positive sample image representation vector is Z g-sub , the negative sample map represents the vector Z g-del , then the positive sample graph represents the vector Z g-sub and negative sample graph representation vector Z g-del The mutual information between them is I(Z g-sub , Z g-del )≥log(N)-L graph , then the second loss L graph for:
[0079] L graph =-log(exp(sim(Z g-sub , Z g-del )));
[0080] Among them, Z g-sub , Z g-del ∈R 1×D .
[0081] Step 306: Train the target model according to the first loss and the second loss.
[0082] In an embodiment of the present application, after obtaining the first loss and the second loss, the computer device trains the target model based on the first loss and the second loss. In some embodiments, after obtaining the first loss and the second loss, the computer device determines the loss of the target model based on the first loss and the second loss, and then trains the target model based on the loss.
[0083] For example, the loss of the target model L = L node +L graph It can be understood that in the embodiment of the present application, during the model training process, the accuracy of the target model is measured from the node dimension (i.e., the local feature dimension) using the first loss. Based on the first loss, positive sample node pairs are promoted to be close to each other in space, and negative sample node pairs are promoted to be separated from each other in space. The accuracy of the target model is measured from the graph dimension (i.e., the global feature dimension) using the second loss. The mutual information is maximized to minimize the second loss.
[0084] In an embodiment of the present application, the target model is used to determine the low-dimensional node representation matrix and low-dimensional graph vector representation after dimensionality reduction of the heterogeneous network graph. In some embodiments, the above-mentioned target model includes: an encoding layer, a dimensionality reduction layer, and an output layer. Among them, the encoding layer is used to encode the positive sample matrix corresponding to the heterogeneous network matrix to obtain the positive sample node representation matrix, and, to encode the negative sample matrix corresponding to the heterogeneous network matrix to obtain the negative sample node representation matrix; the dimensionality reduction layer is used to perform dimensionality reduction processing on the positive sample node representation matrix to obtain the positive sample graph representation vector, and, to perform dimensionality reduction processing on the negative sample node representation matrix to obtain the negative sample graph representation vector; the output layer is used to output the low-dimensional node representation matrix obtained by optimizing the positive sample node representation matrix through contrast learning, and, the low-dimensional graph vector representation obtained by optimizing the positive sample graph representation vector.
[0085] To sum up, in the technical solution provided by the embodiment of the present application, positive samples corresponding to the heterogeneous network matrix are constructed by data enhancement processing on the heterogeneous network matrix, and negative samples corresponding to the heterogeneous network matrix are constructed by edge deletion processing on the heterogeneous network matrix, and then model training is performed based on the positive samples and negative samples, that is, the model is trained by comparative learning between the positive samples and the negative samples, and there is no need to obtain label data corresponding to the sample data, thereby improving the overall efficiency of model training for the heterogeneous network graph; moreover, the positive sample includes a positive sample node representation matrix and a positive sample graph representation vector, and the negative sample includes a negative sample node representation matrix and a negative sample graph representation vector. The node representation matrix is used to represent the local features of the node level in the heterogeneous network graph, and the graph representation vector is used to represent the global features of the graph level in the heterogeneous network graph. In the model training process, both global features and fine-grained local features are taken into account, thereby improving the accuracy of model training.
[0086] In addition, the first loss of the model is determined by representing the distance between pairs of positive sample nodes in the positive sample node representation matrix, and the distance between pairs of negative sample nodes in the negative sample node representation matrix. The model is trained based on contrastive learning, which expands the application of contrastive learning in heterogeneous network graphs and provides an unsupervised learning training method for heterogeneous network graphs.
[0087] In addition, the heterogeneous network matrix is reduced in dimensionality through the model's encoding layer, dimensionality reduction layer, and output layer to obtain a low-dimensional node representation matrix and a low-dimensional graph vector representation, reducing the computational complexity of processing the low-dimensional node representation matrix and low-dimensional graph vector in subsequent downstream tasks.
[0088] The following is an introduction to the specific method of the above data enhancement processing.
[0089] In an exemplary embodiment, step 302 includes at least one of the following steps:
[0090] 1. Determine the heterogeneous network sub-matrices corresponding to the multiple heterogeneous network sub-graphs from the heterogeneous network matrix.
[0091] In an embodiment of the present application, during data augmentation processing, a computer device determines heterogeneous network submatrices corresponding to multiple heterogeneous network subgraphs from a heterogeneous network matrix. One semantic constraint corresponds to one heterogeneous network subgraph, and one heterogeneous network submatrix is used to represent the adjacency relationship of nodes in the heterogeneous network subgraph under one semantic constraint.
[0092] In some embodiments, a heterogeneous network graph may correspond to one or more different non-semantic constraints, different semantic constraints correspond to different heterogeneous network subgraphs, and different heterogeneous network subgraphs correspond to different heterogeneous network submatrices. Figure 4 For example, the heterogeneous network graph 40 corresponds to the first meta-path: author paper author (APA), the second meta-path: author paper conference author (APCPA), and the third meta-path: author paper keyword paper author (APTPA). Among them, the first meta-path is used to represent the co-author relationship between authors, the second meta-path represents the joint conference relationship between authors, and the third meta-path is used to represent the keyword association relationship between the papers written by authors. Different meta-paths correspond to different heterogeneous network subgraphs, such as Figure 5As shown, the first meta-path corresponds to the first heterogeneous network subgraph 51, which includes two types of nodes: authors and papers; the second meta-path corresponds to the second heterogeneous network subgraph 52, which includes three types of nodes: authors, papers, and conferences; the third meta-path corresponds to the third heterogeneous network subgraph 53, which includes three types of nodes: authors, papers, and keywords. It should be noted that the above three meta-paths are all used to characterize the relationship between authors, and the connecting nodes between authors are used to characterize the association between authors under semantic constraints. In some embodiments, when determining the meta-path corresponding to the heterogeneous network graph, the computer device can determine the corresponding meta-path based on the downstream task corresponding to the heterogeneous network graph. For example, if the downstream task is to study authors with co-author relationships, the meta-path can be the author of the paper.
[0093] In some embodiments, taking a target semantic constraint among multiple semantic constraints as an example, a random walk is performed on the heterogeneous network matrix based on the meta-path corresponding to the target semantic constraint to determine a node sequence under the target semantic constraint. This node sequence is used to characterize the structural characteristics of the heterogeneous network subgraph under the target semantic constraint. Subsequently, a matrix reconstruction is performed on the node sequence under the target semantic constraint to obtain a heterogeneous network submatrix under the target semantic constraint. The heterogeneous network submatrices corresponding to the multiple heterogeneous network subgraphs include heterogeneous network submatrices under the multiple semantic constraints.
[0094] In some embodiments, when obtaining the node sequence under the target semantic constraint, the computer device randomly selects a first node from the heterogeneous network matrix, where the first node is any node in the heterogeneous network matrix. Subsequently, based on the meta-path corresponding to the target semantic constraint, at least one adjacent node of the first node is determined, and a new first node is randomly selected from the unselected nodes included in the at least one adjacent node. This process continues from the step of determining at least one adjacent node of the first node based on the meta-path corresponding to the target semantic constraint until no unselected nodes exist in the heterogeneous network matrix. After traversing all nodes in the heterogeneous network matrix, a node sequence under the target semantic constraint is generated based on the adjacency relationships between the nodes.
[0095] In some embodiments, when obtaining the heterogeneous network submatrix under the target semantic constraint, the computer device determines the adjacency relationship between the i-th node and the j-th node from the node sequence under the target semantic constraint. Wherein, i and j are both positive integers. Thereafter, if there is an adjacency relationship between the i-th node and the j-th node, the element in the i-th row and j-th column of the heterogeneous network submatrix under the target semantic constraint is assigned a value of 1; if there is an adjacency relationship between the i-th node and the j-th node, the element in the i-th row and j-th column of the heterogeneous network submatrix under the target semantic constraint is assigned a value of 0.
[0096] 2. Linearly fuse multiple heterogeneous network sub-matrices to obtain the positive sample matrix corresponding to the heterogeneous network matrix.
[0097] In an embodiment of the present application, after obtaining the above-mentioned multiple heterogeneous network sub-matrices, the computer device linearly fuses the multiple heterogeneous network sub-matrices to obtain a positive sample matrix corresponding to the heterogeneous network matrix. The positive sample matrix is used to represent the adjacency relationship of the nodes after the data enhancement processing of the heterogeneous network matrix.
[0098] In some embodiments, when obtaining a positive sample matrix, multiple heterogeneous network matrices are added element by element to achieve the above linear fusion to obtain a positive sample matrix corresponding to the heterogeneous network matrix.
[0099] 3. Encode the positive sample matrix to obtain the positive sample node representation matrix.
[0100] In an embodiment of the present application, after obtaining the above-mentioned positive sample matrix, the computer device encodes the positive sample matrix to obtain a positive sample node representation matrix. The positive sample node representation matrix is used to characterize the node characteristics of the heterogeneous network graph after data enhancement processing. In the positive sample node representation matrix, each row of data represents the node characteristics of a node. Taking the second target row in the positive sample node representation matrix as an example, the data of the second target row is used to characterize the node characteristics of the second target node in the heterogeneous network graph after data enhancement processing. The above-mentioned second node can be any node in the positive sample node representation matrix.
[0101] 4. Perform dimensionality reduction on the positive sample node representation matrix to obtain the positive sample graph representation vector.
[0102] In an embodiment of the present application, after obtaining the positive sample node representation matrix, the computer device performs dimensionality reduction processing on the positive sample node representation matrix to obtain the positive sample graph representation vector. Exemplarily, the computer device performs dimensionality reduction processing on the positive sample node representation matrix using an MLP (Multilayer Perceptron) to obtain the positive sample graph representation vector.
[0103] To sum up, in the technical solution provided by the embodiment of the present application, the heterogeneous network sub-matrices corresponding to multiple heterogeneous network sub-graphs are determined from the heterogeneous network matrix through the meta-path corresponding to the semantic constraint, the multi-hop relationship between the nodes in the heterogeneous network graph is captured, and the data enhancement processing of the heterogeneous network graph is realized through linear fusion to obtain the positive sample matrix, which increases the amount of information contained in the positive sample matrix, making the positive sample node representation matrix and positive sample graph representation vector subsequently obtained based on the positive sample matrix more accurate.
[0104] The specific method of the above edge deletion processing is introduced below.
[0105] In an exemplary embodiment, step 303 includes at least one of the following steps:
[0106] 1. Get the type of edges to be deleted and the number of edges to be deleted.
[0107] In an embodiment of the present application, during edge deletion, a computer device obtains the type of edge to be deleted and the number of edges to be deleted. In some embodiments, different numbers of edges are associated with different types. For example, in a heterogeneous network matrix, 30% of the edges of the first type are deleted, and 20% of the edges of the second type are deleted.
[0108] In one possible embodiment, the number of types of edges to be deleted is different from the number of types of edges contained in the heterogeneous network graph. In some embodiments, the types of important edges in the heterogeneous network graph are determined from the heterogeneous network matrix, and then the number of edges to be deleted in the type is determined based on the importance of the type to which the edge belongs. Exemplarily, the importance of the edge of the target type in the heterogeneous network graph is positively correlated with the number of edges of the target type, that is, the more the number of edges of the target type in the heterogeneous network graph, the more important the edges of the target type are; conversely, the fewer the number of edges of the target type in the heterogeneous network graph, the less important the edges of the target type are; the number of edges of the target type to be deleted is positively correlated with the importance of the edges of the target type, that is, the more important the edges of the target type in the heterogeneous network graph, the more the edges of the target type to be deleted; conversely, the less important the edges of the target type in the heterogeneous network graph, the fewer the edges of the target type to be deleted.
[0109] In another possible implementation, the number of edge types to be deleted is the same as the number of edge types included in the heterogeneous network graph. In some embodiments, the types of edges included in the heterogeneous network graph are determined from the heterogeneous network matrix, and then the number of edges to be deleted in each type is determined based on the importance of the edge type. Exemplarily, the number of edges of the target type to be deleted is positively correlated with the importance of the edges of the target type.
[0110] In some embodiments, the type of edges to be deleted and the number of edges to be deleted can be flexibly determined by the computer device according to actual conditions, or can be flexibly configured by the staff according to actual conditions, and the embodiments of this application do not limit this. Of course, in exemplary embodiments, the type of edges to be deleted and the number of edges to be deleted can also be determined based on the downstream tasks corresponding to the heterogeneous network graph.
[0111] 2. Based on the type and number of edges to be deleted, the heterogeneous network matrix is subjected to edge deletion processing to obtain a negative sample matrix corresponding to the heterogeneous network matrix.
[0112] In an embodiment of the present application, after obtaining the type of edges to be deleted and the number of edges to be deleted, the computer device performs edge deletion processing on the heterogeneous network matrix based on the type of edges to be deleted and the number of edges to be deleted, thereby obtaining a negative sample matrix corresponding to the heterogeneous network matrix. The negative sample matrix is used to represent the adjacency relationship of nodes after the edge deletion processing is performed on the heterogeneous network matrix.
[0113] In some embodiments, the edge deletion process destroys the original structure of the heterogeneous network graph. Figure 4 For example, after deleting 30% of the edges of the paper-author (PA) type, the network structure of the heterogeneous network graph 40 is destroyed as follows: Figure 6 shown.
[0114] 3. Encode the negative sample matrix to obtain the negative sample node representation matrix.
[0115] In an embodiment of the present application, after obtaining the negative sample matrix, the computer device encodes the negative sample matrix to obtain a negative sample node representation matrix. The negative sample node representation matrix is used to characterize the node characteristics of the heterogeneous network graph after edge deletion. In the negative sample node representation matrix, each row of data represents the node characteristics of a node. Taking the third target row in the negative sample node representation matrix as an example, the data in the third target row is used to characterize the node characteristics of the third target node in the heterogeneous network graph after edge deletion. The third node can be any node in the negative sample node representation matrix.
[0116] 4. Perform dimensionality reduction on the negative sample node representation matrix to obtain the negative sample graph representation vector.
[0117] In an embodiment of the present application, after obtaining the negative sample node representation matrix, the computer device performs dimensionality reduction processing on the negative sample node representation matrix to obtain the negative sample graph representation vector. Exemplarily, the computer device performs dimensionality reduction processing on the negative sample node representation matrix using an MLP to obtain the negative sample graph representation vector.
[0118] To sum up, in the technical solution provided by the embodiment of the present application, the original structure of the heterogeneous network graph is destroyed by edge deletion processing to construct a negative sample matrix corresponding to the heterogeneous network matrix. When performing edge deletion processing, the type of edges to be deleted is limited. On the one hand, the needs of downstream tasks are taken into account. On the other hand, compared with the direct deletion of edges and edge connections in related technologies, the edge deletion processing is controllable, avoiding data inaccuracy caused by too many deleted edges, improving the accuracy of the negative sample matrix, and thereby improving the accuracy of subsequent comparative learning.
[0119] In addition, combined with reference Figure 7 , a complete introduction to the model training method of the present application for heterogeneous network graphs is given. For the heterogeneous network graph, a heterogeneous network matrix is constructed, and the heterogeneous network sub-matrices corresponding to the multiple heterogeneous network sub-graphs are determined based on multi-path random walks, and the multiple heterogeneous network sub-matrices are linearly fused to obtain the positive sample matrix corresponding to the heterogeneous network matrix; the original structure of the heterogeneous network graph is destroyed based on edge deletion processing, and the negative sample matrix corresponding to the heterogeneous network matrix is constructed. Afterwards, the positive sample matrix is encoded to obtain the positive sample node representation matrix, and the negative sample matrix is encoded to obtain the negative sample node representation matrix, and node-level comparative learning is performed on the target model based on the positive sample node representation matrix and the negative sample node representation matrix. Afterwards, the positive sample node representation matrix is dimensionality reduced to obtain the positive sample graph representation vector, and the negative sample node representation matrix is dimensionality reduced to obtain the negative sample graph representation vector, and graph-level comparative learning is performed on the target model based on the positive sample graph representation vector and the negative sample graph representation vector.
[0120] Below, taking item recommendation in a shopping scenario as an example, the model training method for heterogeneous network graphs in this application is introduced.
[0121] Please refer to Figure 8 , which shows a flow chart of a model training method for heterogeneous network graphs provided by another embodiment of the present application. The steps in this method can be Figure 1 The terminal device 10 and / or server 20 (hereinafter collectively referred to as "computer device") is executed. The method may include at least one of the following steps (801-810):
[0122] Step 801: construct a first heterogeneous network matrix based on a first heterogeneous network graph.
[0123] The first heterogeneous network is used to represent the association relationship between nodes in the shopping scenario. For example, the first heterogeneous network includes four types of nodes: first user, first item, first price range, and first shopping platform, as well as four different types of edges: user-user, user-item, item-price range, and item-shopping platform. User-user is used to represent friendships between users, user-item is used to represent items purchased by users, item-price range is used to represent the range of the average price of an item's recent transaction, and item-shopping platform is used to represent the shopping platform where the item appears.
[0124] In an embodiment of the present application, a computer device obtains a first heterogeneous network graph and constructs a first heterogeneous network matrix based on the first heterogeneous network graph. The first heterogeneous network matrix is used to represent the structural characteristics of the first heterogeneous network graph. In the first heterogeneous network matrix, each row of data represents the adjacency relationship between a node and other nodes in the first heterogeneous network graph.
[0125] Step 802: Perform data enhancement processing on the first heterogeneous network matrix to obtain a first positive sample node representation matrix and a first positive sample graph representation vector.
[0126] In an embodiment of the present application, after obtaining the first heterogeneous network matrix, the computer device performs data augmentation processing on the first heterogeneous network matrix to obtain a first positive sample node representation matrix and a first positive sample graph representation vector. The first positive sample node representation matrix refers to the positive sample node representation matrix corresponding to the first heterogeneous network matrix, and the first positive sample node representation matrix is used to represent the node features in the first heterogeneous network graph after the data augmentation processing; the first sample graph representation vector refers to the positive sample graph representation vector corresponding to the first heterogeneous network matrix, and the first positive sample graph representation vector is used to represent the graph features in the first heterogeneous network graph after the data augmentation processing.
[0127] In some embodiments, the data enhancement is achieved by linear fusion of the first heterogeneous network sub-matrices.
[0128] In an exemplary embodiment, step 802 includes at least one of the following steps:
[0129] 1. Determine, from the first heterogeneous network matrix, first heterogeneous network sub-matrices corresponding to a plurality of first heterogeneous network sub-graphs;
[0130] 2. Linearly fuse multiple first heterogeneous network sub-matrices to obtain a first positive sample matrix corresponding to the first heterogeneous network matrix, where the first positive sample matrix refers to a positive sample matrix corresponding to the first heterogeneous network matrix;
[0131] 3. Encode the first positive sample matrix to obtain the first positive sample node representation matrix;
[0132] 4. Perform dimensionality reduction processing on the first positive sample node representation matrix to obtain the first positive sample graph representation vector.
[0133] Step 803: Perform edge deletion processing on the first heterogeneous network matrix to obtain a first negative sample node representation matrix and a first negative sample graph representation vector.
[0134] In an embodiment of the present application, after obtaining the first heterogeneous network matrix, the computer device performs edge deletion processing on the first heterogeneous network matrix to obtain a first negative sample node representation matrix and a first negative sample graph representation vector. The first negative sample node representation matrix refers to the negative sample node representation matrix corresponding to the first heterogeneous network matrix, and the first negative sample node representation matrix is used to represent the node features in the first heterogeneous network graph after the edge deletion processing; the first negative sample graph representation vector refers to the negative sample graph representation vector corresponding to the first heterogeneous network matrix, and the first negative sample graph representation vector is used to represent the graph features in the first heterogeneous network graph after the edge deletion processing.
[0135] In an exemplary embodiment, step 803 includes at least one of the following steps:
[0136] 1. Get the type of edges to be deleted and the number of edges to be deleted;
[0137] 2. Based on the type and number of edges to be deleted, perform edge deletion on the first heterogeneous network matrix to obtain a first negative sample matrix, where the first negative sample matrix refers to a negative sample matrix corresponding to the first heterogeneous network matrix;
[0138] 3. Encode the first negative sample matrix to obtain the first negative sample node representation matrix;
[0139] 4. Perform dimensionality reduction processing on the first negative sample node representation matrix to obtain the first negative sample graph representation vector.
[0140] Step 804 : Training the first target model based on the first positive sample node representation matrix, the first positive sample graph representation vector, the first negative sample node representation matrix, and the first negative sample graph representation vector.
[0141] In an embodiment of the present application, after obtaining a first positive sample node representation matrix, a first positive sample graph representation vector, a first negative sample node representation matrix, and a first negative sample graph representation vector, a computer device trains a first target model based on the first positive sample node representation matrix, the first positive sample graph representation vector, the first negative sample node representation matrix, and the first negative sample graph representation vector. The first target model is used to determine a low-dimensional node representation matrix and a low-dimensional graph vector representation of a heterogeneous network graph related to shopping scenarios after dimensionality reduction.
[0142] In an exemplary embodiment, step 804 includes at least one of the following steps:
[0143] 1. Determine a first loss of the first target model based on the first positive sample node representation matrix and the first negative sample node representation matrix;
[0144] 2. Determine a second loss of the first target model based on the first positive sample image representation vector and the first negative sample image representation vector;
[0145] 3. Train the first target model according to the first loss of the first target model and the second loss of the first target model.
[0146] Step 805 : Collect the relationship between the second user, the second item, the second price range, and the second purchase platform to construct a second heterogeneous network graph.
[0147] In some embodiments, after the first target model training is completed, the first target model can be put into a specific item recommendation process in a shopping scenario.
[0148] In this embodiment of the present application, a computer device collects the relationship between a second user, a second item, a second price range, and a second purchasing platform to construct a second heterogeneous network graph. The second heterogeneous network refers to a heterogeneous network graph constructed with the second user, the second item, the second price range, and the second purchasing platform as nodes. The second user may be the same as or different from the first user; the second item may be the same as or different from the first item; the second price range may be the same as or different from the first price range; and the second shopping platform may be the same as or different from the first shopping platform.
[0149] Step 806: construct a second heterogeneous network matrix based on the second heterogeneous network graph.
[0150] In an embodiment of the present application, after obtaining the second heterogeneous network graph, the computer device constructs a second heterogeneous network matrix based on the second heterogeneous network graph. The second heterogeneous network matrix is used to characterize the structural characteristics of the second heterogeneous network graph. In the second heterogeneous network matrix, each row of data represents the adjacency relationship between a node and other nodes in the second heterogeneous network graph.
[0151] Step 807: Perform data enhancement processing on the second heterogeneous network matrix to obtain a second positive sample node representation matrix and a second positive sample graph representation vector.
[0152] In an embodiment of the present application, after obtaining the second heterogeneous network matrix, the computer device performs data augmentation processing on the second heterogeneous network matrix to obtain a second positive sample node representation matrix and a second positive sample graph representation vector. The second positive sample node representation matrix refers to the positive sample node representation matrix corresponding to the second heterogeneous network matrix, and the second positive sample node representation matrix is used to represent the node features in the second heterogeneous network graph after the data augmentation processing; the second sample graph representation vector refers to the positive sample graph representation vector corresponding to the second heterogeneous network matrix, and the second positive sample graph representation vector is used to represent the graph features in the second heterogeneous network graph after the data augmentation processing.
[0153] In some embodiments, the data enhancement is achieved by linear fusion of the second heterogeneous network sub-matrix. In an exemplary embodiment, step 807 includes at least one of the following steps:
[0154] 1. Determine, from the second heterogeneous network matrix, second heterogeneous network sub-matrices corresponding to a plurality of second heterogeneous network sub-graphs;
[0155] 2. Linearly fuse multiple second heterogeneous network sub-matrices to obtain a second positive sample matrix corresponding to the second heterogeneous network matrix, where the second positive sample matrix refers to the positive sample matrix corresponding to the second heterogeneous network matrix;
[0156] 3. Encode the second positive sample matrix to obtain the second positive sample node representation matrix;
[0157] 4. Perform dimensionality reduction processing on the second positive sample node representation matrix to obtain the second positive sample graph representation vector.
[0158] Step 808: Perform edge deletion processing on the second heterogeneous network matrix to obtain a second negative sample node representation matrix and a second negative sample graph representation vector.
[0159] In an embodiment of the present application, after obtaining the second heterogeneous network matrix, the computer device performs edge deletion processing on the second heterogeneous network matrix to obtain a second negative sample node representation matrix and a second negative sample graph representation vector. The second negative sample node representation matrix refers to the negative sample node representation matrix corresponding to the second heterogeneous network matrix, and the second negative sample node representation matrix is used to represent the node features in the second heterogeneous network graph after the edge deletion processing; the second negative sample graph representation vector refers to the negative sample graph representation vector corresponding to the second heterogeneous network matrix, and the second negative sample graph representation vector is used to represent the graph features in the second heterogeneous network graph after the edge deletion processing.
[0160] In an exemplary embodiment, step 803 includes at least one of the following steps:
[0161] 1. Get the type of edges to be deleted and the number of edges to be deleted;
[0162] 2. Based on the type and number of edges to be deleted, perform edge deletion on the second heterogeneous network matrix to obtain a second negative sample matrix, where the second negative sample matrix refers to the negative sample matrix corresponding to the second heterogeneous network matrix;
[0163] 3. Encode the second negative sample matrix to obtain the second negative sample node representation matrix;
[0164] 4. Perform dimensionality reduction processing on the second negative sample node representation matrix to obtain the second negative sample graph representation vector.
[0165] Step 809: Input the second positive sample node representation matrix, the second positive sample graph representation vector, the second negative sample node representation matrix, and the second negative sample graph representation vector into the first target model to obtain a low-dimensional node representation matrix and a low-dimensional graph vector representation after dimensionality reduction of the second heterogeneous network graph.
[0166] In an embodiment of the present application, after obtaining the above-mentioned second positive sample node representation matrix, second positive sample graph representation vector, second negative sample node representation matrix and second negative sample graph representation vector, the computer device inputs the second positive sample node representation matrix, second positive sample graph representation vector, second negative sample node representation matrix and second negative sample graph representation vector into the first target model, thereby obtaining the low-dimensional node representation matrix and low-dimensional graph vector representation after dimensionality reduction of the second heterogeneous network graph output by the first target model.
[0167] Step 810 : Determine recommended items for the target user based on the low-dimensional node representation matrix and the low-dimensional graph vector representation.
[0168] In some embodiments, after obtaining a low-dimensional node representation matrix and a low-dimensional graph vector representation of the second heterogeneous network graph after dimensionality reduction based on the first target model, the low-dimensional node representation matrix and the low-dimensional graph vector representation can be applied to subsequent downstream tasks. For example, in a shopping scenario, the downstream task is to recommend items to users.
[0169] In an embodiment of the present application, after obtaining the output of the first target model, the computer device determines recommended items for a target user based on the output of the first target model. The target user may be any user included in the second heterogeneous network graph.
[0170] To sum up, in the technical solution provided in the embodiment of the present application, the dimensionality reduction processing of the heterogeneous network graph is performed through the target model. When subsequently coordinating downstream tasks, the low-dimensional node representation matrix and the low-dimensional graph vector need to be processed, which reduces the computational complexity of subsequent downstream tasks and improves the processing efficiency of downstream tasks.
[0171] It should be noted that the above is a simple introduction to item recommendations in shopping scenarios. For specific technical details, please refer to the above Figure 3 as well as Figure 3 The relevant embodiments are not described in detail here.
[0172] It should also be noted that the above description of this application is based on a shopping scenario. In exemplary embodiments, the technical solutions provided by this application can also be applied to other scenarios. For example, in a shopping scenario, the vector recall task of the top 10 most similar items; in the field of data mining, using this type of algorithm to find similar users or similar communities in large-scale networks, mining black market communities, and mining user profiles; in the field of chemistry, discovering new drugs based on existing drugs; and so on.
[0173] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0174] Please refer to Figure 9 , which shows a block diagram of a model training device for heterogeneous network graphs provided by one embodiment of the present application. The device has the function of implementing the above-mentioned model training method for heterogeneous network graphs. The function can be implemented by hardware or by hardware executing corresponding software. The device can be a computer device or can be set in a computer device. The device 900 can include: a matrix construction module 910, a data enhancement module 920, a data deletion module 930, a loss determination module 940 and a model training module 950.
[0175] The matrix construction module 910 is used to construct a heterogeneous network matrix based on the heterogeneous network graph, wherein the heterogeneous network matrix is used to characterize the structural characteristics of the heterogeneous network graph; wherein the data of the first target row in the heterogeneous network matrix is used to characterize the adjacency relationship between the first target node and other nodes in the heterogeneous network graph.
[0176] The data enhancement module 920 is used to perform data enhancement processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix; wherein the positive sample node representation matrix is used to represent the node features in the heterogeneous network graph after the data enhancement processing, and the positive sample graph representation vector is used to represent the graph features in the heterogeneous network graph after the data enhancement processing.
[0177] The data deletion module 930 is used to perform edge deletion processing on the heterogeneous network matrix to obtain a negative sample node representation matrix and a negative sample graph representation vector corresponding to the heterogeneous network matrix; wherein the negative sample node representation matrix is used to represent the node features in the heterogeneous network graph after the edge deletion processing, and the negative sample graph representation vector is used to represent the graph features in the heterogeneous network graph after the edge deletion processing.
[0178] The loss determination module 940 is used to determine a first loss of the target model based on the positive sample node representation matrix and the negative sample node representation matrix, where the first loss is used to measure the accuracy of the target model from a node dimension.
[0179] The loss determination module 940 is further used to determine a second loss of the target model based on the positive sample graph representation vector and the negative sample graph representation vector, where the second loss is used to measure the accuracy of the target model from a graph dimension.
[0180] The model training module 950 is used to train the target model according to the first loss and the second loss, and the target model is used to determine the low-dimensional node representation matrix and low-dimensional graph vector representation of the heterogeneous network graph after dimensionality reduction.
[0181] In an exemplary embodiment, as Figure 10 As shown, the data enhancement module 920 includes: a random walk unit 921, a linear fusion unit 922, a first encoding unit 923 and a first dimensionality reduction unit 924.
[0182] The random walk unit 921 is used to determine heterogeneous network sub-matrices corresponding to multiple heterogeneous network sub-graphs from the heterogeneous network matrix; wherein a heterogeneous network sub-matrix is used to represent the adjacency relationship of nodes in the heterogeneous network sub-graph under a semantic constraint.
[0183] The linear fusion unit 922 is used to linearly fuse the multiple heterogeneous network sub-matrices to obtain a positive sample matrix corresponding to the heterogeneous network matrix, and the positive sample matrix is used to characterize the adjacency relationship of the nodes after the heterogeneous network matrix is subjected to data enhancement processing.
[0184] The first encoding unit 923 is used to encode the positive sample matrix to obtain the positive sample node representation matrix, where the data of the second target row in the positive sample node representation matrix is used to represent the node characteristics of the second target node in the heterogeneous network graph after data enhancement processing.
[0185] The first dimensionality reduction unit 924 is configured to perform dimensionality reduction processing on the positive sample node representation matrix to obtain the positive sample graph representation vector.
[0186] In an exemplary embodiment, the random walk unit 921 is further configured to:
[0187] For a target semantic constraint among the multiple semantic constraints, performing a random walk on the heterogeneous network matrix based on a meta-path corresponding to the target semantic constraint to determine a node sequence under the target semantic constraint, wherein the node sequence is used to characterize a structural feature of the heterogeneous network subgraph under the target semantic constraint;
[0188] Performing matrix reconstruction on the node sequence under the target semantic constraint to obtain a heterogeneous network submatrix under the target semantic constraint;
[0189] The heterogeneous network sub-matrices corresponding to the multiple heterogeneous network sub-graphs include heterogeneous network sub-matrices under multiple semantic constraints.
[0190] In an exemplary embodiment, the random walk unit 921 is further configured to:
[0191] randomly selecting a first node from the heterogeneous network matrix;
[0192] determining at least one adjacent node of the first node based on a meta-path corresponding to the target semantic constraint;
[0193] Randomly selecting a new first node from unselected nodes included in the at least one adjacent node, and starting from the step of determining at least one adjacent node of the first node based on the meta-path corresponding to the target semantic constraint until no unselected nodes exist in the heterogeneous network matrix;
[0194] A node sequence under the target semantic constraint is generated according to the adjacency relationship between the nodes.
[0195] In an exemplary embodiment, as Figure 10 As shown, the data deletion module 930 includes: a data acquisition unit 931, a data deletion unit 932, a second encoding unit 933 and a second dimensionality reduction unit 934.
[0196] The data acquisition unit 931 is configured to acquire the type of edges to be deleted and the number of edges to be deleted.
[0197] The data deletion unit 932 is used to perform edge deletion processing on the heterogeneous network matrix based on the type of the edge to be deleted and the number of the edges to be deleted, and obtain a negative sample matrix corresponding to the heterogeneous network matrix, wherein the negative sample matrix is used to characterize the adjacency relationship of the nodes after the heterogeneous network matrix is subjected to edge deletion processing.
[0198] The second encoding unit 933 is used to encode the negative sample matrix to obtain the negative sample node representation matrix, where the data of the third target row in the negative sample node representation matrix is used to represent the node characteristics of the third target node in the heterogeneous network graph after edge deletion processing.
[0199] The second dimensionality reduction unit 934 is configured to perform dimensionality reduction processing on the negative sample node representation matrix to obtain the negative sample graph representation vector.
[0200] In an exemplary embodiment, the loss determination module 940 is further configured to:
[0201] Determining, based on the positive sample node representation matrix, a distance between positive sample node pairs in the positive sample node representation matrix, wherein the positive sample node pairs include two nodes having an adjacency relationship in the positive sample node representation matrix;
[0202] Determining, based on the negative sample node representation matrix, a distance between pairs of negative sample nodes in the negative sample node representation matrix, wherein the negative sample node pairs include two nodes having an adjacency relationship in the negative sample node representation matrix;
[0203] Determine a first loss of the target model according to the distance between the positive sample node pairs and the distance between the negative sample node pairs.
[0204] In an exemplary embodiment, the target model includes: an encoding layer, a dimensionality reduction layer and an output layer; wherein the encoding layer is used to encode the positive sample matrix corresponding to the heterogeneous network matrix to obtain the positive sample node representation matrix; and, encode the negative sample matrix corresponding to the heterogeneous network matrix to obtain the negative sample node representation matrix; the dimensionality reduction layer is used to perform dimensionality reduction processing on the positive sample node representation matrix to obtain the positive sample graph representation vector; and, perform dimensionality reduction processing on the negative sample node representation matrix to obtain the negative sample graph representation vector; the output layer is used to output a low-dimensional node representation matrix obtained by optimizing the positive sample node representation matrix through contrastive learning, and a low-dimensional graph vector representation obtained by optimizing the positive sample graph representation vector.
[0205] To sum up, in the technical solution provided by the embodiment of the present application, positive samples corresponding to the heterogeneous network matrix are constructed by data enhancement processing on the heterogeneous network matrix, and negative samples corresponding to the heterogeneous network matrix are constructed by edge deletion processing on the heterogeneous network matrix, and then model training is performed based on the positive samples and negative samples, that is, the model is trained by comparative learning between the positive samples and the negative samples, and there is no need to obtain label data corresponding to the sample data, thereby improving the overall efficiency of model training for the heterogeneous network graph; moreover, the positive sample includes a positive sample node representation matrix and a positive sample graph representation vector, and the negative sample includes a negative sample node representation matrix and a negative sample graph representation vector. The node representation matrix is used to represent the local features of the node level in the heterogeneous network graph, and the graph representation vector is used to represent the global features of the graph level in the heterogeneous network graph. In the model training process, both global features and fine-grained local features are taken into account, thereby improving the accuracy of model training.
[0206] It should be noted that the apparatus provided in the above embodiments, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0207] Please refer to Figure 11 , which shows a block diagram of the structure of a computer device provided by an embodiment of the present application. The computer device can be used to implement the functions of the above-mentioned model training method for heterogeneous network graphs. Specifically:
[0208] Computer device 1100 includes a central processing unit (CPU) 1101, a system memory 1104 including a random access memory (RAM) 1102 and a read-only memory (ROM) 1103, and a system bus 1105 connecting system memory 1104 and CPU 1101. Computer device 1100 also includes a basic input / output (I / O) system 1106 that facilitates information transfer between various components within the computer, and a mass storage device 1107 for storing an operating system 1113, application programs 1114, and other program modules 1115.
[0209] The basic input / output system 1106 includes a display 1108 for displaying information and an input device 1109, such as a mouse and keyboard, for user input. Both the display 1108 and the input device 1109 are connected to the central processing unit 1101 via an input / output controller 1110 connected to the system bus 1105. The basic input / output system 1106 may also include an input / output controller 1110 for receiving and processing input from a variety of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1110 also provides output to a display screen, printer, or other types of output devices.
[0210] The mass storage device 1107 is connected to the central processing unit 1101 via a mass storage controller (not shown) connected to the system bus 1105. The mass storage device 1107 and its associated computer-readable media provide non-volatile storage for the computer device 1100. In other words, the mass storage device 1107 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0211] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage devices, CD-ROM, DVD (Digital Video Disc) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above-mentioned ones. The above-mentioned system memory 1104 and mass storage device 1107 can be collectively referred to as memory.
[0212] According to various embodiments of the present application, the computer device 1100 may also be connected to a remote computer on a network such as the Internet for operation. That is, the computer device 1100 may be connected to the network 1112 via the network interface unit 1111 connected to the system bus 1105, or the network interface unit 1111 may be used to connect to other types of networks or remote computer systems (not shown).
[0213] The memory also includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the above-mentioned model training method for heterogeneous network graphs.
[0214] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored. When the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, the model training method for heterogeneous network graphs is implemented.
[0215] Optionally, the computer-readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory), SSD (Solid State Drives), or an optical disk, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0216] In an exemplary embodiment, a computer program product or computer program is also provided, the computer program product or computer program including 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 computer device to perform the above-described model training method for a heterogeneous network graph.
[0217] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application do not limit this.
[0218] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A model training method for heterogeneous network graphs, characterized in that: The method comprises: Constructing a heterogeneous network matrix based on the heterogeneous network graph, wherein the heterogeneous network matrix is used to characterize the structural characteristics of the heterogeneous network graph; wherein the data of the first target row in the heterogeneous network matrix is used to characterize the adjacency relationship between the first target node and other nodes in the heterogeneous network graph; Performing data augmentation processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix; wherein the positive sample node representation matrix is used to represent node features in the heterogeneous network graph after the data augmentation processing, and the positive sample graph representation vector is used to represent graph features in the heterogeneous network graph after the data augmentation processing; Obtain the type of edges to be deleted and the number of edges to be deleted; Based on the type of the edges to be deleted and the number of the edges to be deleted, performing edge deletion processing on the heterogeneous network matrix to obtain a negative sample matrix corresponding to the heterogeneous network matrix, wherein the negative sample matrix is used to characterize the adjacency relationship of the nodes after the edge deletion processing is performed on the heterogeneous network matrix; Encoding the negative sample matrix to obtain a negative sample node representation matrix corresponding to the heterogeneous network matrix, wherein the negative sample node representation matrix is used to represent node features in the heterogeneous network graph after edge deletion processing; Performing dimensionality reduction processing on the negative sample node representation matrix to obtain a negative sample graph representation vector corresponding to the heterogeneous network matrix, wherein the negative sample graph representation vector is used to represent graph features in the heterogeneous network graph after edge deletion processing; Determining a first loss of a target model based on the positive sample node representation matrix and the negative sample node representation matrix, where the first loss is used to measure the accuracy of the target model from a node dimension; Determining a second loss of the target model based on the positive sample graph representation vector and the negative sample graph representation vector, where the second loss is used to measure the accuracy of the target model from a graph dimension; The target model is trained according to the first loss and the second loss, and the target model is used to determine the low-dimensional node representation matrix and low-dimensional graph vector representation of the heterogeneous network graph after dimensionality reduction.
2. The method according to claim 1, characterized in that The performing data enhancement processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix includes: Determining heterogeneous network submatrices corresponding to a plurality of heterogeneous network subgraphs from the heterogeneous network matrix; wherein a heterogeneous network submatrix is used to represent the adjacency relationship of nodes in the heterogeneous network subgraph under a semantic constraint; Linearly fuse the heterogeneous network sub-matrices corresponding to the multiple heterogeneous network subgraphs to obtain a positive sample matrix corresponding to the heterogeneous network matrix, wherein the positive sample matrix is used to represent the adjacency relationship of the nodes after data enhancement processing is performed on the heterogeneous network matrix; Encoding the positive sample matrix to obtain the positive sample node representation matrix, wherein the data of the second target row in the positive sample node representation matrix is used to represent the node features of the second target node in the heterogeneous network graph after data enhancement processing; Performing dimensionality reduction processing on the positive sample node representation matrix to obtain the positive sample graph representation vector.
3. The method according to claim 2, characterized in that The determining, from the heterogeneous network matrix, heterogeneous network sub-matrices corresponding to the plurality of heterogeneous network sub-graphs respectively includes: For a target semantic constraint among the multiple semantic constraints, performing a random walk on the heterogeneous network matrix based on a meta-path corresponding to the target semantic constraint to determine a node sequence under the target semantic constraint, wherein the node sequence is used to characterize a structural feature of the heterogeneous network subgraph under the target semantic constraint; Performing matrix reconstruction on the node sequence under the target semantic constraint to obtain a heterogeneous network submatrix under the target semantic constraint; The heterogeneous network sub-matrices corresponding to the multiple heterogeneous network sub-graphs include heterogeneous network sub-matrices under multiple semantic constraints.
4. The method according to claim 3, characterized in that The step of performing a random walk on the heterogeneous network matrix based on the meta-path corresponding to the target semantic constraint to determine a node sequence under the target semantic constraint includes: randomly selecting a first node from the heterogeneous network matrix; determining at least one adjacent node of the first node based on a meta-path corresponding to the target semantic constraint; Randomly selecting a new first node from unselected nodes included in the at least one adjacent node, and starting from the step of determining at least one adjacent node of the first node based on the meta-path corresponding to the target semantic constraint until no unselected nodes exist in the heterogeneous network matrix; A node sequence under the target semantic constraint is generated according to the adjacency relationship between the nodes.
5. The method according to claim 1, wherein The determining a first loss of the target model based on the positive sample node representation matrix and the negative sample node representation matrix includes: Determining, based on the positive sample node representation matrix, a distance between positive sample node pairs in the positive sample node representation matrix, wherein the positive sample node pairs include two nodes having an adjacency relationship in the positive sample node representation matrix; Determining, based on the negative sample node representation matrix, a distance between pairs of negative sample nodes in the negative sample node representation matrix, wherein the negative sample node pairs include two nodes having an adjacency relationship in the negative sample node representation matrix; Determine a first loss of the target model according to the distance between the positive sample node pairs and the distance between the negative sample node pairs.
6. The method according to any one of claims 1 to 5, characterized in that The target model includes: an encoding layer, a dimensionality reduction layer and an output layer; wherein, The encoding layer is used to encode the positive sample matrix corresponding to the heterogeneous network matrix to obtain the positive sample node representation matrix; and encode the negative sample matrix corresponding to the heterogeneous network matrix to obtain the negative sample node representation matrix; The dimensionality reduction layer is used to perform dimensionality reduction processing on the positive sample node representation matrix to obtain the positive sample graph representation vector; and perform dimensionality reduction processing on the negative sample node representation matrix to obtain the negative sample graph representation vector; The output layer is used to output a low-dimensional node representation matrix obtained by optimizing the positive sample node representation matrix through contrast learning, and a low-dimensional graph vector representation obtained by optimizing the positive sample graph representation vector.
7. A model training device for heterogeneous network graphs, characterized in that: The device comprises: A matrix construction module is used to construct a heterogeneous network matrix based on a heterogeneous network graph, wherein the heterogeneous network matrix is used to characterize the structural characteristics of the heterogeneous network graph; wherein the data of the first target row in the heterogeneous network matrix is used to characterize the adjacency relationship between the first target node and other nodes in the heterogeneous network graph; A data enhancement module is used to perform data enhancement processing on the heterogeneous network matrix to obtain a positive sample node representation matrix and a positive sample graph representation vector corresponding to the heterogeneous network matrix; wherein the positive sample node representation matrix is used to represent the node features in the heterogeneous network graph after the data enhancement processing, and the positive sample graph representation vector is used to represent the graph features in the heterogeneous network graph after the data enhancement processing; A data deletion module is configured to obtain the type of edges to be deleted and the number of edges to be deleted; based on the type of edges to be deleted and the number of edges to be deleted, perform edge deletion processing on the heterogeneous network matrix to obtain a negative sample matrix corresponding to the heterogeneous network matrix, wherein the negative sample matrix is used to characterize the adjacency relationship of nodes after the edge deletion processing on the heterogeneous network matrix; encode the negative sample matrix to obtain a negative sample node representation matrix corresponding to the heterogeneous network matrix, wherein the negative sample node representation matrix is used to characterize the node features in the heterogeneous network graph after the edge deletion processing; perform dimensionality reduction processing on the negative sample node representation matrix to obtain a negative sample graph representation vector corresponding to the heterogeneous network matrix, wherein the negative sample graph representation vector is used to characterize the graph features in the heterogeneous network graph after the edge deletion processing; a loss determination module, configured to determine a first loss of a target model based on the positive sample node representation matrix and the negative sample node representation matrix, wherein the first loss is used to measure the accuracy of the target model from a node dimension; The loss determination module is further configured to determine a second loss of the target model based on the positive sample graph representation vector and the negative sample graph representation vector, wherein the second loss is used to measure the accuracy of the target model from a graph dimension; A model training module is used to train the target model according to the first loss and the second loss, and the target model is used to determine the low-dimensional node representation matrix and low-dimensional graph vector representation of the heterogeneous network graph after dimensionality reduction.
8. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one program, and the at least one program is loaded and executed by the processor to implement the model training method for heterogeneous network graphs as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The storage medium stores at least one program, which is loaded and executed by the processor to implement the model training method for heterogeneous network graphs as described in any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. The processor of the computer device reads and executes the computer instructions from the computer-readable storage medium, so that the computer device performs the model training method for heterogeneous network graphs as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for pre-training graph neural network
CN111860769A
Social platform rumor detection model construction method and prediction method based on comparative learning
CN113705099A