A graph neural network training method and device
Constructing an input matrix by calculating the closeness between nodes in the graph data expands the receptive field of the graph neural network, solves the problem of being unable to learn global information in the existing technology, and achieves more accurate and efficient representation of financial fraud risk characteristics. training process.
Patent Information
- Application Number
- CN202111081570.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-09-15
AI Technical Summary
The existing graph neural network cannot effectively learn global information in financial fraud risk detection, resulting in inaccurate feature representation, small receptive field, high complexity, and inability to effectively detect financial fraud risks.
By calculating the closeness between every two nodes in the graph data, an input matrix is constructed, in which the feature vector of each node is composed of the feature vectors of other nodes sorted from large to small by closeness, and is used as the graph neural network. Input, train a graph neural network to classify transaction risks, expand the receptive field of node updates, and consider high-order neighborhood information.
It improves the global information learning ability of node updates, enhances the accuracy of feature representation, reduces network complexity, improves training efficiency, and can more effectively detect financial fraud risks.
Smart Images

Figure CN113850381B
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computer application technology, and in particular, to a graph neural network training method and device. Background Art
[0002] In financial risk control scenarios, in order to better identify financial fraud risks, each transaction data is usually characterized based on machine learning, and then the features are classified through trained classifiers to determine whether there is a financial fraud risk. In order to better detect financial fraud risks, related technologies usually use graph neural networks that can reflect the relationship information between multiple transaction data for feature characterization. The graph in the graph neural network refers to a graph with a topological structure composed of several nodes and edges connecting the nodes. In a graph neural network, each node generally represents one party to the transaction, and the edge is generally used to represent the relationship between two nodes, that is, the relationship between the two parties to the transaction.
[0003] However, the current training methods of graph neural networks are unable to learn global information during the node update process, which makes it impossible for current graph neural networks to effectively represent sample features and effectively detect financial fraud risks. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a graph neural network training method and device.
[0005] According to a first aspect of one or more embodiments of this specification, a graph neural network training method is proposed, the method comprising:
[0006] Acquire initial graph data; the initial graph data is data of a graph containing a plurality of nodes and having a topological structure;
[0007] Calculating the intimacy between every two nodes in the initial graph data; the magnitude of the intimacy is positively correlated with the similarity of the topological structures of the two nodes corresponding to the intimacy;
[0008] For each node i, i = 1, 2, 3, ... N, N is the total number of nodes in the graph, construct the input matrix H of the node i , where the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N;
[0009] Taking the input matrix of each node as input and the transaction risk classification of each node as output, the graph neural network is trained according to the transaction risk classification label corresponding to the node; the graph neural network is used to classify the transaction risk of the user corresponding to each node.
[0010] According to a second aspect of one or more embodiments of this specification, a graph neural network training device is provided, the device comprising:
[0011] An initial graph data acquisition module is used to acquire initial graph data; the initial graph data is data of a graph containing a plurality of nodes and having a topological structure;
[0012] An intimacy calculation module, used to calculate the intimacy between every two nodes in the initial graph data; the magnitude of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy;
[0013] An input matrix construction module is used to construct an input matrix Hi of each node i, i=1,2,3,...N, where N is the total number of nodes in the graph, wherein the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N;
[0014] The graph neural network training module is used to take the input matrix of each node as input and the transaction risk classification of each node as output, and train the graph neural network according to the transaction risk classification label corresponding to the node; the graph neural network is used to classify the transaction risk of the user corresponding to each node.
[0015] According to a third aspect of an embodiment of this specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the graph neural network training method as described in the first aspect of the embodiment of this specification is implemented.
[0016] According to a fourth aspect of the embodiments of this specification, there is provided an electronic device, including:
[0017] processor;
[0018] a memory for storing processor-executable instructions;
[0019] In which, the processor implements the graph neural network training method as described in the first aspect of the embodiment of this specification by running the executable instructions.
[0020] One or more embodiments of the present specification provide a graph neural network training method and device. After obtaining the initial graph data, the intimacy between each two nodes in the obtained initial graph data is calculated. The size of the intimacy reflects the similarity of the topological structures of the two nodes. According to the size of the intimacy, for each node, in the order of intimacy from large to small, the nodes used to update the node are constructed into an input matrix, and the input matrix of each node is used as input, and the classification label of the transaction risk of each node is used as output. According to the node classification label of each node, the graph neural network is trained. In this way, the nodes are screened according to the intimacy, and the nodes considered for updating the nodes are not limited to the nodes in the first-order neighborhood, but also the nodes in the higher-order neighborhood can be considered, so that the node update can consider the global information and the feature representation is more accurate.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.
[0023] Figure 1 It is a flowchart of a graph neural network training method shown in this specification according to an exemplary embodiment.
[0024] Figure 2 It is a schematic diagram of a graph neural network training method shown in this specification according to a specific embodiment.
[0025] Figure 3 It is a block diagram of a graph neural network training device shown in this specification according to an exemplary embodiment.
[0026] Figure 4 This specification provides a hardware structure diagram of a computer device where a graph neural network training device is located according to an exemplary embodiment. DETAILED DESCRIPTION
[0027] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0028] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0029] In the era of big data, in order to prevent financial fraud, it is generally based on machine learning. A network that can identify financial fraud is trained through a large amount of labeled transaction data, and transaction data that may be risky is found through the network. In order to more effectively find transaction data with risks, it is necessary to effectively characterize the characteristics of financial fraud (such as credit card theft, transaction fraud, cheating, illegal activities, etc.) in transaction data. There are many feature characterization methods in the relevant technology, and these feature characterization methods and their shortcomings will be explained one by one below.
[0030] The first is a feature extraction method based on a tree model. This method uses a tree model to extract transaction data, uses the distribution of values under each attribute, and adds a series of complex manually designed rules to distinguish whether each transaction data has a financial fraud risk. Although this method has strong interpretability, the manually designed rules are limited by human experience and are relatively complex to design. Usually, in order to ensure that the model does not lose some features, new rules need to be continuously added to the model, which ultimately makes the entire model large and difficult to maintain. In addition, this method is prone to losing high-order implicit features.
[0031] Secondly, in the risk control scenario, in addition to the transaction data itself, transaction relationships, community relationships (whether two users are friends, whether they have joined the same group, etc.) and device relationships (whether two user accounts use the same device, etc.), etc., will all contribute to the characterization of the financial fraud characteristics of the transaction data. In order to learn these relationships, the relevant technology first converts the transaction data and other business data (such as the user's risk profile, operation behavior and relationship data, etc.) into a graph, uses each node to represent a user (one party to the transaction), and uses the edge to represent the relationship between two users, and then uses the graph neural network method to perform high-level feature characterization of the characteristics of financial fraud. In addition, it should be noted that after the feature characterization, the nodes must be classified according to their characteristics, so that it can be known whether the transaction of the user corresponding to each node has a financial fraud risk.
[0032] In the graph neural network method, in order to learn high-order features, the nodes are generally updated through a specific algorithm first, so that the feature representation of the node can represent the high-order features. Since each node in the graph data is affected by other nodes in the graph, the closer the relationship with the node to be updated, the greater the impact on the node. Therefore, during the update process, the update is generally performed through other nodes in the graph. After explaining the basic update method of the graph neural network, the common graph neural networks in related technologies will be explained in detail.
[0033] Graph Convolutional Networks (GCN) can characterize the risk of financial fraud. GCN learns the low-dimensional representation of nodes based on the Laplace matrix on the graph. Using the convolution theorem, the graph and convolution kernel are first mapped to the Fourier domain, the two are multiplied in the Fourier domain, and then the inverse Fourier transform is performed to achieve the convolution of the two in the original domain. In GCN, due to the Fourier domain multiplication, the node feature matrix, adjacency matrix and degree matrix of the entire graph are generally used. When used on a large-scale graph, it will be difficult to parallelize or even impossible to calculate due to its high complexity. In addition, for each node, the GCN method generally uses the adjacency matrix and the feature matrix to multiply. If there is no connection between two nodes, the value of the corresponding position of the adjacency matrix will be 0. Then, only the nodes in the first-order neighborhood (that is, the nodes directly connected to the node) will play a role in updating the node, which will make the node's receptive field (receptive path) smaller.
[0034] Graph Attention Network (GAT) can also characterize financial fraud risks. GAT performs weighted summation of the features of the first-order neighboring nodes of a node based on the attention mechanism, and uses a multi-head attention mechanism to learn the feature vectors of the nodes in the graph. The attention mechanism can learn the influence of different nodes on the nodes that need to be updated within the first-order neighboring nodes, and assign different weights to different nodes according to the learned influence. However, the process of learning weights by the attention mechanism is added to GAT, which increases the number of parameters and the complexity. In addition, for each node, the GAT method, although its high-order neighboring nodes (nodes that are not directly connected to the node) will indirectly play a role in the update of the node (the first-order neighboring nodes of the node update themselves through the attention mechanism at the same time, and the node updates itself through the updated first-order neighboring nodes), for the node, its receptive field (the maximum number of hops that will directly affect the node) is still small.
[0035] From the above description of the related technology, it can be seen that although the related technology uses graph neural networks to characterize the characteristics of nodes, there are problems such as small receptive field and high complexity. As a result, the related technology cannot learn global information during the node update process, the feature representation is not accurate enough, and the training of large-scale graph networks is slow or even impossible to train.
[0036] First, regarding the problem of inaccurate node feature representation, the above analysis shows that the inability to learn global information is because the related technology can only update the node through the first-order neighborhood nodes, and the receptive field is small. In order to solve the above problem, considering that the related technology generally uses the number of hops to judge the influence of the node on the node that needs to be updated, and in some cases, in the field of financial fraud, there are nodes with similar topological structures. Although they are not directly connected, the feature representations of the two nodes are similar. In other words, two nodes with similar topological structures will affect each other's feature representations. Therefore, consider finding nodes with similar topological structures to the nodes that need to be updated, and use these nodes to update the nodes that need to be updated, so that the node can not only learn the information of the nodes in the first-order neighborhood, but also learn the information of the nodes similar to the node in the high-order neighborhood, so that the receptive field is increased and the feature representation is more accurate.
[0037] Furthermore, although updating the nodes that need to be updated through all nodes can allow the node update to learn global information, this is too complex and may make the network unable to be trained. In order to reduce the complexity, parallel training can be performed. Considering that for each node, the greatest impact on it may be only a small part of the nodes in the graph data, therefore, only a small part of the nodes can be used to update a node. In other words, before updating the node, a subgraph is generated for each node, and the subgraph includes several nodes that have the greatest impact on the node. When updating the node, each node is updated according to the business data of each node and the characteristics of the reaction topological structure of each node in the subgraph. In this way, the update tasks of multiple nodes can be executed in parallel. At the same time, for the network, there is no need to learn how to update a large graph, only to learn how to update a small graph, and then the entire large graph can be updated, which reduces the complexity of the network and improves the training efficiency.
[0038] Based on this, this specification provides a graph neural network training method. After obtaining the initial graph data, the intimacy between each two nodes in the obtained initial graph data is calculated. The size of the intimacy reflects the similarity of the topological structures of the two nodes. According to the size of the intimacy, for each node, in the order of intimacy from large to small, the nodes used to update the node are constructed into an input matrix, and the input matrix of each node is used as input, and the classification label of the financial fraud risk of each node is used as output. According to the node classification label of each node, the graph neural network is trained. In this way, the nodes are screened according to the intimacy, and the nodes considered for updating the nodes are not only limited to the nodes in the first-order neighborhood, but also the nodes in the higher-order neighborhood can be considered, so that the node update can consider the global information and the feature representation is more accurate.
[0039] Next, a graph neural network training method provided in an embodiment of this specification will be described in detail.
[0040] like Figure 1 As shown, Figure 1 This is a flowchart of a graph neural network training method according to an exemplary embodiment of the present specification, comprising the following steps:
[0041] Step 101, obtaining initial graph data; the initial graph data is data of a graph containing a plurality of nodes and having a topological structure.
[0042] The initial graph data obtained is converted from transaction data samples and other business data with labels indicating whether they are financial frauds according to preset rules.
[0043] For the nodes in the initial graph data, each node is used to characterize the payee or payee of the transaction data. In other words, each node is used to characterize the user in the transaction data. Other business data may include: user risk profile, operation behavior, etc. The user risk profile may include information such as the user's attributes, the device's attributes, and whether there is fraud in the transaction history. Operation behavior may include transaction behavior within a period of time (such as 7 days) before and after the transaction data corresponding to the node occurs. In addition to the transaction amount and the identification of the two parties to the transaction, the transaction data may also include information such as the transaction location and transaction time. In addition, for the label of the transaction data, since the label is used to reflect whether the transaction corresponding to each transaction data is financial fraud, the label is generally used as the label of the corresponding payee in the transaction data. In other words, the corresponding label will be used as the classification label of the payee node.
[0044] As for the edges of the initial graph data, the initial graph data is a graph with a topological structure. There are several edges used to connect two nodes. The edges represent the relationship between the two nodes. The relationship can be a transaction relationship, a device relationship, a community relationship, etc. The specific meaning of each relationship is described above and will not be repeated here.
[0045] The representation method of graph data is generally represented by the feature matrix and adjacency matrix of the node. When there are N nodes on a graph, the feature matrix of the node is an N×D-dimensional matrix, where D represents the dimension of the feature vector of each node. The adjacency matrix is generally an N×N-dimensional matrix, and the value of the i-th row and j-th column of the adjacency matrix is used to represent whether the i-th node and the j-th node are connected / or the weight of the connected edge.
[0046] As for the significance of the initial graph data obtained, since the initial graph data is converted according to manually set rules, and the high-order implicit features refer to the features updated by the neural network, the initial graph data lacks high-order implicit features, and the characteristic representation of financial fraud risks is not accurate. Therefore, it is necessary to update the graph data through a neural network to characterize the features more accurately. Therefore, it is necessary to train a graph neural network to update the feature vector of each node and determine the transaction risk classification of the node based on the updated feature vector.
[0047] In addition, it should be noted that although this specification only illustrates the graph neural network training method provided in this specification through the scenario of financial fraud, this does not mean that the graph neural network training method provided in this specification can only be applied to the financial fraud scenario, but can also be applied to other scenarios, such as road condition prediction, by inputting historical traffic map data to predict future traffic map data.
[0048] Step 103, calculating the intimacy between every two nodes in the initial graph data; the magnitude of the intimacy is positively correlated with the similarity of the topological structures of the two nodes corresponding to the intimacy.
[0049] Specifically, compared to the related art, in which whether two nodes will affect each other is determined by the number of hops (if two nodes affect each other, the feature vector of one node will affect the update of the feature vector of the other node), the method provided in this specification determines whether two nodes will affect each other by the intimacy that reflects the similarity of the topological structures of the two nodes.
[0050] The hop count of a node refers to the number of edges contained in the shortest path between two nodes. For example, if two nodes are directly connected, one node is a one-hop node relative to the other node. The topological structure of a node refers to the position of two nodes in the graph and their relationship with other nodes.
[0051] The reason for using the topological structure of the node instead of the number of hops is that some nodes may be directly connected, but the influence between them is not strong. Although some nodes are not directly connected, they still affect each other. For example, two nodes may be connected only because there has been a transaction or friendship between the two nodes. This does not guarantee that the transaction data of one of the two nodes has a financial fraud risk, and the transaction of the other node also has a financial fraud risk. For example, there is a transaction between two nodes, and the transaction is a financial fraud transaction. The recipient of the financial fraud transaction is a fraudulent party, which does not mean that the payee of the financial fraud transaction is also a fraudulent party. Therefore, it is not accurate to use the number of hops to measure whether the two nodes will affect each other. The topological structures between the two nodes are relatively similar, indicating that the behaviors of the two nodes may be more similar, indicating that the labels of the two nodes should also be similar, and the corresponding feature representations should also be similar. Therefore, the topological structure of the node is chosen to measure whether the two nodes will affect each other.
[0052] As for the calculation method of intimacy, considering the graph theory, the i-th row of the Laplace matrix is actually the accumulated benefits generated by the i-th node to other nodes when a disturbance occurs. Therefore, it is considered that the intimacy calculation matrix can be obtained based on the Laplace matrix. The obtained intimacy calculation matrix can be shown in the following formula (1) and formula (2). In other words, step 103 specifically includes: according to the intimacy calculation formula, the intimacy between every two nodes in the initial graph data is calculated; the intimacy calculation formula is:
[0053]
[0054]
[0055] Among them, S is the calculated intimacy matrix, S(i,j) represents the intimacy between node i and node j; α∈[0,1] is a hyperparameter; A is the adjacency matrix of the initial graph data, and D is the degree matrix of the initial graph data. The degree matrix is a diagonal matrix, and the calculation formula is as follows and shown in (3):
[0056] D(i,i)=∑ j A(i,j) (3)
[0057] The above-mentioned intimacy calculation method is only a feasible method and does not represent a limitation on the embodiments of this specification. Other intimacy calculation methods that can reflect the similarity of topological structures can also be applied to the embodiments of this specification.
[0058] Step 105: for each node i (i = 1, 2, 3, ... N, N is the total number of nodes in the graph), construct the input matrix H of the node i, where the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N.
[0059] Among them, the input matrix of each node can be constructed for the node, but further considering that in the initial graph data, since the sample label follows the payee user, not every node in the initial graph data has a label. After updating the node, it is necessary to classify the transaction risk of the node through supervised learning, and further update the weight according to the classification loss. Therefore, for the training of the graph neural network, updating the feature vector of the node without a label is useless for network training. The input matrix is constructed for node update and transaction risk classification and discrimination after the update. Therefore, for nodes without labels, it is not necessary to construct the input matrix of these nodes. Therefore, in step 105, the input matrix of the node can be constructed only for each node with a transaction risk classification label.
[0060] For the purpose of constructing the input matrix in the form of step 105, in order to complete the node update with as few parameters as possible and reduce complexity, only the nodes that affect the node update are input into the input matrix, and no other information, such as the intimacy information of each node, is input. In this case, since different intimacy has different influences on the nodes that need to be updated, the network needs to learn the difference in intimacy. Therefore, the input matrices constructed for all nodes have the same form, so that after inputting into the network, the network can learn the difference in influence of nodes with different intimacy sizes on the nodes that need to be updated according to this order, so that when the trained network updates the feature vector of the node, it considers more nodes with high intimacy and less nodes with low intimacy.
[0061] In addition, in order for the model to learn the position of the intimacy size in the input matrix, it is only necessary to ensure that the input matrices of all nodes are constructed in the same way. Therefore, in addition to the construction method in step 105, the input matrix can also be constructed according to other methods. For example, the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to: the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from small to large; M is a preset natural number less than or equal to N. In this case, the preset network weights must also be changed accordingly, otherwise the network may be difficult to train.
[0062] As for the value of M, if the initial graph data is large, if M is very large, the network may not be able to be input into existing electronic devices for training. In addition, considering that the reduction of M can reduce the number of network parameters and the complexity of the network, and for any node in the initial graph data, most nodes have little influence on the node, so M can be taken as small as possible while ensuring accuracy. For example, M can be 500, of course, 500 is just an example and does not constitute a limitation of this specification.
[0063] In addition, since each node update only uses M nodes, a subgraph consisting of M nodes can be constructed for each node. In other words, for each node, a subgraph is constructed with the node as the central node; the subgraph includes M nodes, and the intimacy between any node in the subgraph except the central node and the central node is greater than the intimacy between any node not in the subgraph and the central node; M<<N, M is a natural number. For the network, as long as the central node of the subgraph including M nodes can be updated, the entire network can be used for node updates.
[0064] For the feature vector of the node, it can only include the business data of each node. Furthermore, since the input matrix is constructed according to the size of intimacy, and the size of intimacy is used to reflect the size of the similarity of the topological structure, in order to enable the network to learn the topological structure of the network, the feature vector of the node can also include the topological structure characteristics of the node. Since each node is only updated through a subgraph of M nodes, the topological structure characteristics of the node included in the feature vector of the node are actually the topological structure characteristics of the node in the subgraph. In other words, the feature vector of the node in the input matrix includes: the business characteristics corresponding to the node, and the topological structure characteristics of the node in the subgraph.
[0065] For the topological structure features of the node in the subgraph, the topological structure features include at least one of the following: the absolute role embedding value of the node; the intimacy between the node and the central node; the number of hops from the node to the central node of the subgraph; the degree of the node; the number of kernels of the node; the neighborhood influence of the node; and the one-hop neighborhood connectivity of the node. Among them, the absolute role embedding value refers to the Weisfeiler-Lehman absolute role embedding value; the intimacy can be obtained according to the intimacy calculated by formula (1); the central node of the subgraph is the node to be updated, and is also the node in the first column of the input matrix constructed in step 105; the calculation method of the number of hops and the degree is detailed above and will not be repeated here; the calculation formula of the one-hop neighborhood connectivity of the node is shown in the following formula (4):
[0066]
[0067] Among them, CC(i) refers to the one-hop neighborhood connectivity of node i, and Deg(i) refers to the degree of node i. In addition, when the feature vector of a node includes multiple vectors, the same position of the feature vectors of different nodes should have the same meaning. For example, the first row of the feature vector of node i is a business feature, and the i-th row of the feature vectors of other nodes is also a business feature. Since some of the above topological structure features are related to subgraphs, the feature vectors of the same node in different subgraphs may be different.
[0068] Step 107, taking the input matrix of each node as input and the transaction risk classification of each node as output, and training the graph neural network according to the transaction risk classification label corresponding to the node; the graph neural network is used to classify the transaction risk of the user corresponding to each node.
[0069] As mentioned above, the process of training a graph neural network mainly includes updating each node, obtaining the transaction risk classification category of each node, determining the output loss based on the transaction risk classification category and the transaction risk classification label, and then updating the weight based on the output loss. The weights that need to be updated include the weights used in the process of updating each node and the weights used in the process of obtaining the transaction risk classification category of each node.
[0070] In other words, the method takes the input matrix of each node as input, takes the transaction risk classification of each node as output, and trains the graph neural network according to the transaction risk classification label corresponding to the node, including: iteratively executing the following steps until the output loss is less than a preset loss threshold, or the number of iterations is greater than a preset number threshold: for each node, based on the self-attention mechanism, update the feature vector of the node through the input matrix and attention weight of the node; determine the transaction risk classification result of each updated node based on the updated feature vector and classification weight of the node, and obtain the output loss according to the transaction risk classification label of each node; update the attention weight and node classification weight according to the output loss; after the iteration, determine the graph neural network based on the current attention weight and node classification weight.
[0071] It should also be noted that in this embodiment, only the transaction risk classification label is used as the supervisory signal for supervised training. Of course, when there are other judgment purposes, supervised learning can also be performed based on other supervisory signals. In addition, in step 107 of this embodiment, the entire graph neural network used to judge the transaction risk classification is used as the output network. Of course, if you just want to obtain a network that can accurately represent the financial fraud risk of graph data, you can also use only the first half of the network used to update the nodes as the final network.
[0072] During the network training process, the node updating process, for each node, based on the self-attention mechanism, updates the feature vector of the node through the input matrix and attention weight of the node, including: for each node, based on at least one layer of self-attention layer, update the input matrix of the node; average the columns of the input matrix updated by the last layer of self-attention layer to obtain the updated feature vector of the node. The above method can be implemented by Transform. Of course, using Transform to implement node update knowledge is an achievable method and does not constitute a limitation on the embodiments of this specification.
[0073] Nodes are updated through Transform. The specific node methods of each layer can be found in formulas (5)-(8):
[0074]
[0075]
[0076]
[0077]
[0078] in, Represents the input matrix H i The output of the lth layer, softmax is an activation function that can be normalized. The embodiments of this specification can also use other activation functions. Here, only the softmax function is used as an example. Represents the input matrix H i The output of layer l-1, and are the three weight matrices of the lth layer, d h is the dimension of the key vector K. Then the process of updating nodes in the network can be described by the following formulas (9)-(11):
[0079]
[0080]
[0081]
[0082] in, Represents the input of the first layer, which is the input matrix H i , The feature vector representing the nodes in the initial graph data or subgraph that need to be updated. It is the feature vector of the node in the initial graph data or subgraph determined in step 105 and having the highest intimacy with the node to be updated. The method for obtaining z is detailed in step 105 and will not be repeated here. The GTSD in formula (10) represents the network. The calculation method of formula (10) is detailed in formula (5). i Represents the updated input matrix H i The corresponding node. Represents the output of the last layer.
[0083] After updating the nodes, each updated node needs to be used as input to obtain the transaction risk classification of each updated node, and the output of the network is obtained based on the transaction risk classification label, and the relevant weights of the network are updated based on the output. The transaction risk classification can be obtained based on the fully connected layer, and the updated weight can be updated based on the gradient descent method, etc. Of course, other methods of obtaining classification and updating weights can also be used.
[0084] In addition, after the training is completed, the network can be used to classify the transaction risks of nodes. The specific method of use is as follows: After the training is completed, the method also includes: obtaining the graph data to be judged, which does not contain the node transaction risk classification label; calculating the intimacy between every two nodes in the graph data to be judged; the size of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy; for each node i, i = 1, 2, 3, ... N, N is the total number of nodes in the graph, constructing the input matrix H of the node i , where the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to: the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N; for each node, the input matrix of the node is input into the graph neural network to obtain the transaction risk classification of the node.
[0085] Through the above method, accurate characterization of financial fraud risk characteristics is achieved. Since the distance between nodes is measured by intimacy in the above method, the receptive field is improved, so that the node update is updated through global information, and the hidden layer representation of the node can be learned more effectively. In addition, through subgraph decomposition, the shortcomings of traditional graph neural networks that require overall modeling of the graph when training on graph data and cannot be trained on large-scale graph data sets are eliminated. The method provided in this specification can process large graph data in a parallel manner. The graph neural network trained in this specification uses the Transformer in NLP instead of the graph convolutional neural network (GCN) to learn graph data, avoiding the use of a large number of parameters to deepen the convolution layer in methods such as GCN, reducing the number of parameters and computational complexity.
[0086] Next, the graph neural network training method provided in this specification will be described in detail through a specific embodiment.
[0087] like Figure 2 As shown, Figure 2 Schematic diagram of a graph neural network training method according to a specific embodiment of this specification. Figure 2 As shown, the graph neural network includes an embedding layer, an attention representation layer and a node classification layer.
[0088] The embedding layer is used to decompose the initial graph data into subgraphs, and for each subgraph, construct the feature vector of each node in the subgraph, and construct the input matrix of the central node based on the feature vector of each node in the subgraph and the intimacy between these nodes and the central node.
[0089] The subgraph decomposition is performed based on the intimacy and the preset M value. For the specific decomposition method, please refer to the description of step 103. The feature vector may include the business feature and the topological structure feature of the node in the subgraph. For the specific method of constructing the feature vector and input matrix of each node, please refer to the description of step 105 above.
[0090] The attention representation layer updates the feature vector of the central node of each subgraph according to Transform. The specific updating method is described in the above description of step 107. The attention representation layer takes the input matrix as input and the feature vector of the central node of the subgraph as output.
[0091] The node classification layer can be a fully connected layer, which takes the feature vector of the node as input and the transaction risk classification of the node as output. The weights of the node classification layer and the attention representation layer are updated according to the transaction risk classification label of the node.
[0092] Corresponding to the embodiments of the aforementioned methods, this specification also provides embodiments of a graph neural network training device and an electronic device to which it is applied.
[0093] like Figure 3 As shown, Figure 3 is a block diagram of a graph neural network training device according to an exemplary embodiment of the present specification, the device comprising:
[0094] The initial graph data acquisition module 310 is used to acquire initial graph data; the initial graph data is data of a graph containing a number of nodes and having a topological structure.
[0095] The intimacy calculation module 320 is used to calculate the intimacy between every two nodes in the initial graph data; the magnitude of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy.
[0096] The input matrix construction module 330 is used to construct the input matrix Hi of each node i, i=1,2,3,...N, N is the total number of nodes in the graph, wherein the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to: the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N.
[0097] The graph neural network training module 340 is used to take the input matrix of each node as input and the transaction risk classification of each node as output, and train the graph neural network according to the transaction risk classification label corresponding to the node; the graph neural network is used to classify the transaction risk of the user transaction corresponding to each node.
[0098] In addition, the device also includes a subgraph construction module 300, which is used to construct a subgraph for each node with the node as the central node; the subgraph includes M nodes, and the intimacy between any node in the subgraph except the central node and the central node is greater than the intimacy between any node not in the subgraph and the central node; M<<N, M is a natural number.
[0099] The feature vector of the node in the input matrix includes: the business feature corresponding to the node, and the topological structure feature of the node in the subgraph. The topological structure feature includes at least one of the following: the absolute role embedding value of the node; the intimacy between the node and the central node; the number of hops from the node to the central node of the subgraph; the degree of the node; the number of cores of the node; the neighborhood influence of the node; and the one-hop neighborhood connectivity of the node.
[0100] The graph neural network training module 340 includes:
[0101] The iterative training submodule 341 is used to iteratively perform the following steps until the output loss is less than a preset loss threshold, or the number of iterations is greater than a preset number threshold: for each node, based on the self-attention mechanism, the feature vector of the node is updated through the input matrix and attention weight of the node. Based on the updated feature vector and classification weight of the node, the transaction risk classification result of each updated node is determined, and the output loss is obtained according to the transaction risk classification label of each node. The attention weight and node classification weight are updated according to the output loss.
[0102] The graph neural network determination submodule 342 determines the graph neural network based on the current attention weight and node classification weight after the iteration.
[0103] In the iterative training submodule 341, for each node, based on the self-attention mechanism, the feature vector of the node is updated through the input matrix and attention weight of the node, including: for each node, based on at least one layer of self-attention layer, the input matrix of the node is updated; the columns of the input matrix after the last layer of self-attention layer is updated are averaged to obtain the updated feature vector of the node.
[0104] After the training is completed, it also includes: a transaction risk classification acquisition module 350, which is used to obtain the graph data to be judged, and the graph data to be judged does not contain the node transaction risk classification label; calculate the intimacy between every two nodes in the graph data to be judged; the size of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy; for each node i, i = 1, 2, 3, ... N, N is the total number of nodes in the graph, construct the input matrix H of the node i , where the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to: the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N; for each node, the input matrix of the node is input into the graph neural network to obtain the transaction risk classification of the node.
[0105] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0106] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0107] like Figure 4 As shown, Figure 4 The embodiment diagram shows a hardware structure diagram of an electronic device in which the neural network training device is located, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other in communication within the device through the bus 1050.
[0108] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0109] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0110] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0111] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0112] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0113] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0114] The embodiments of this specification also provide a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the graph neural network training method described in the first aspect of the embodiments of this specification is implemented.
[0115] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0116] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0117] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Claims
1. A graph neural network training method, the method comprising: Obtain initial graph data; The initial graph data is data of a graph that includes a number of nodes and edges and has a topological structure. The edges represent the relationships between two nodes, and the relationships include transaction relationships; Calculate the intimacy between every two nodes in the initial graph data; the magnitude of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy; For each node i, i = 1, 2, 3, ... N, N is the total number of nodes in the graph, construct the input matrix H of the node i , where the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N; Using the input matrix of each node as the input and the transaction risk classification of each node as the output, train a graph neural network according to the transaction risk classification label corresponding to the node. The graph neural network is used to classify the transaction risks of the users corresponding to each node.
2. The method according to claim 1, further comprising: For each node, construct a subgraph with this node as the central node; This subgraph includes M nodes. The intimacy between any node other than the central node and the central node in this subgraph is greater than the intimacy between any node not in this subgraph and the central node; M << N, and M is a natural number.
3. According to the method of claim 2, the characteristic vectors of the nodes in the input matrix include: The business features corresponding to the node and the topological structure features of the node in this subgraph.
4. The method according to claim 3, wherein the topological structure feature comprises at least one of the following: The absolute role embedding value of the node; the closeness between the node and the central node; the number of hops from the node to the central node of the subgraph; the degree of the node; the number of cores of the node; the neighborhood influence of the node; and the one-hop neighborhood connectivity of the node.
5. According to the method of claim 1, the method takes the input matrix of each node as input, takes the transaction risk classification of each node as output, and trains the graph neural network according to the transaction risk classification label corresponding to the node, comprising: Iteratively execute the following steps until the output loss is less than a preset loss threshold or the number of iterations is greater than a preset number threshold: For each node, based on the self-attention mechanism, update the feature vector of this node through the input matrix and attention weights of this node; Based on the updated feature vector of the node and the classification weights, determine the transaction risk classification result of each updated node, and obtain the output loss according to the transaction risk classification label of each node; Update the attention weights and node classification weights according to the output loss; After the iteration ends, determine the graph neural network based on the current attention weights and node classification weights.
6. According to the method of claim 5, for each node, based on the self-attention mechanism, updating the feature vector of the node through the input matrix and attention weight of the node, comprising: For each node, update the input matrix of the node based on at least one self-attention layer; Take the average of each column of the input matrix updated by the last self-attention layer to obtain the updated feature vector of this node.
7. The method according to claim 1, after the training is completed, the method further comprises: Obtain the graph data to be judged, and the graph data to be judged does not include node transaction risk classification labels; Calculate the intimacy between every two nodes in the graph data to be judged; the magnitude of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy; For each node i, i = 1, 2, 3, ... N, N is the total number of nodes in the graph, construct the input matrix H of the node i , where the first column of the input matrix corresponds to the eigenvector of node i, and the second to M columns correspond to the eigenvectors of the other M-1 nodes whose intimacy with node i is ranked from large to small; M is a preset natural number less than or equal to N; For each node, input the input matrix of this node into the graph neural network to obtain the transaction risk classification of this node.
8. A graph neural network training device, the device comprising: An initial graph data acquisition module, used to obtain initial graph data; The initial graph data is data of a graph that includes a number of nodes and edges and has a topological structure. The edges represent the relationships between two nodes, and the relationships include transaction relationships; An intimacy calculation module, used to calculate the intimacy between every two nodes in the initial graph data; the magnitude of the intimacy is positively correlated with the topological structure similarity of the two nodes corresponding to the intimacy; An input matrix construction module, used to, for each node i, i = 1, 2, 3,... N, where N is the total number of nodes in the graph, construct the input matrix Hi of this node. Among them, the first column of the input matrix corresponds to the feature vector of node i, and the 2nd to Mth columns respectively correspond to: the feature vectors of the other M - 1 nodes sorted in descending order of intimacy with node i; M is a preset natural number less than or equal to N; The graph neural network training module is used to take the input matrix of each node as input and the transaction risk classification of each node as output, and train the graph neural network according to the transaction risk classification label corresponding to the node; the graph neural network is used to classify the transaction risk of the user corresponding to each node.
9. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the graph neural network training method as described in any one of claims 1 to 7 by running the executable instructions.
10. A computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions, when executed by a processor, implement the graph neural network training method as described in any one of claims 1-7.
