Sample generation method and device, electronic equipment and readable storage medium
By obtaining local subgraphs from the rule graph to generate graph guidance vectors, the problem of lack of business knowledge guidance in generative adversarial networks is solved, thereby improving the accuracy and usability of generated samples.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-21
AI Technical Summary
Existing generative adversarial networks lack guidance from business knowledge in generating samples, resulting in an uncontrollable generation process and difficulty in obtaining samples that meet domain requirements.
Local subgraphs are obtained from a pre-built rule graph, a graph guidance vector is generated, and this vector, along with a noise vector, is input into a trained generator to generate samples. The graph guidance vector provides business knowledge constraints.
The generated samples contain actual feature semantics, which improves the accuracy and usability of the samples and ensures that the generated samples are consistent with the real samples in terms of structure and semantics.
Smart Images

Figure CN121902872A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device, and readable storage medium for generating samples. Background Technology
[0002] During model training, generative adversarial networks (GANs) are typically used to generate samples in order to obtain a sufficient number of training samples. To achieve better training results, it is generally desirable to generate different types of samples that meet specific requirements, thereby enriching the diversity of training samples and improving their relevance.
[0003] However, existing generative adversarial networks (GANs) generally lack guidance from business knowledge in generating samples, resulting in an uncontrollable generation process and difficulty in obtaining samples that meet domain requirements. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and readable storage medium for generating samples, in order to address the problem of a lack of business knowledge guidance in the sample generation process.
[0005] To solve the above-mentioned technical problems, this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a method for generating a sample, comprising:
[0007] A local subgraph is obtained from a pre-constructed rule graph, which is built based on multiple preset rules. Each preset rule defines a subgraph template, which includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates.
[0008] Generate a graph guidance vector based on the local subgraph;
[0009] The graph guidance vector and noise vector are input into the trained generator to generate samples, thus obtaining the first sample.
[0010] Optionally, generating the graph guidance vector based on the local subgraph includes:
[0011] The local subgraph is aggregated with L neighbor information through an L-layer graph attention network to obtain the target feature vector corresponding to the first node, where the first node is the node corresponding to the target entity in the local subgraph and L is a positive integer.
[0012] The target feature vector is determined as the map guidance vector.
[0013] Optionally, through the first The layered graph attention network aggregates neighbor information for the first node, including:
[0014] Determine the second node corresponding to the first node, where the second node is a neighbor node of the first node;
[0015] For each of the second nodes, based on the second node at the... The intermediate feature vector output by layer -1 and the first node at the -1st layer are related to each other. The intermediate feature vector output from layer -1 is used to calculate the attention weights corresponding to the second node. A positive integer less than or equal to L;
[0016] Based on the attention weight, the second node at the... Aggregate the intermediate feature vectors output from layer -1 to obtain the first node at the -1st layer. The intermediate feature vector output by the layer;
[0017] Wherein, the first node is in the The intermediate feature vector output by the layer is the target feature vector, and the intermediate feature vectors output by the first node and the second node in layer 0 are both preset values.
[0018] Optionally, after inputting the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample, the method further includes:
[0019] Calculate a first score and a second score for the first sample, wherein the first score is determined based on the statistical distance between the first sample and the real sample, and the second score is determined based on the ratio of the number of preset rules matched by the first sample to the total number of preset rules;
[0020] The target score is determined based on the first score and the second score;
[0021] The first sample whose target score is greater than or equal to the threshold is identified as the second sample.
[0022] Optionally, the step of inputting the graph guidance vector and noise vector into a trained generator to generate samples and obtain the first sample includes:
[0023] The graph guidance vector, the noise vector, and the first category label vector are input into the trained generator to generate the first sample.
[0024] The first category label vector corresponds to the first sample category and is used to constrain the first sample to belong to the first sample category.
[0025] Optionally, before inputting the graph guidance vector, the noise vector, and the first category label vector into the trained generator to generate samples and obtain the first sample, the method further includes:
[0026] The generative adversarial network is iteratively trained based on the training dataset to obtain a trained generative adversarial network. The generative adversarial network includes a generator and a discriminator. The discriminator includes multiple sub-discriminators, each of which corresponds to a sample category. The first sample category is any one of the multiple sample categories.
[0027] The generator in the trained generative adversarial network is determined as the trained generator;
[0028] The loss value of the target sub-discriminator is determined based on the real samples of the second sample category corresponding to the target sub-discriminator and the samples generated by the generator. The second sample category is the sample category corresponding to the target sub-discriminator, and the target sub-discriminator is any one of the sub-discriminators.
[0029] Optionally, before obtaining the local subgraph from the pre-constructed rule graph, the method further includes:
[0030] Obtain multiple transaction data;
[0031] Extract entities and semantic relationships between entities from the transaction data, and determine the type of the entity and the type of the semantic relationship;
[0032] The rule graph is constructed based on the transaction data. Nodes in the rule graph are used to represent entities, and edges in the rule graph are used to represent semantic relationships between entities.
[0033] Secondly, embodiments of the present invention also provide a sample generation apparatus, comprising:
[0034] The first acquisition module is used to acquire local subgraphs from a pre-constructed rule graph. The rule graph is constructed based on multiple preset rules, and each preset rule defines a subgraph template. The subgraph template includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates.
[0035] The generation module is used to generate a graph guidance vector based on the local subgraph;
[0036] The input module is used to input the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample.
[0037] Thirdly, embodiments of the present invention also provide an electronic device, including: a memory, a processor, and a program stored in the memory and executable on the processor;
[0038] The processor is configured to read a program from the memory to implement the steps in the sample generation method as described in the first aspect.
[0039] Fourthly, embodiments of the present invention also provide a readable storage medium for storing a program, which, when executed by a processor, implements the steps in the sample generation method as described in the first aspect.
[0040] In this embodiment, local subgraphs are obtained from a pre-constructed rule graph; graph guidance vectors are generated based on the local subgraphs; and the graph guidance vectors and noise vectors are input into a trained generator to generate samples, resulting in generated samples. By injecting domain knowledge from the local subgraphs into the graph guidance vectors, business knowledge guidance is provided for sample generation, ensuring that the generated samples contain actual feature semantics and improving the accuracy and usability of the generated samples. Attached Figure Description
[0041] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 One of the flowcharts illustrating the sample generation method provided in this application embodiment;
[0043] Figure 2 This is a schematic diagram of the structure of a generative adversarial network provided in an embodiment of this application;
[0044] Figure 3 A second schematic flowchart illustrating the sample generation method provided in this application embodiment;
[0045] Figure 4 A schematic diagram of the structure of the sample generation device provided in the embodiments of this application;
[0046] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0047] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms "first," "second," and similar terms used in this application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms "a" or "one," and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms "connected" or "linked," and similar terms, are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right," etc., are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship also changes accordingly.
[0049] The following description, in conjunction with the accompanying drawings, further illustrates the sample generation method, apparatus, electronic device, and readable storage medium proposed in the embodiments of the application. Please refer to... Figure 1 , Figure 1 A schematic flowchart illustrating a sample generation method provided in this application embodiment is shown below. Figure 1 As shown, the method includes:
[0050] Step 101: Obtain a local subgraph from a pre-constructed rule graph. The rule graph is constructed based on multiple preset rules. Each preset rule defines a subgraph template. The subgraph template includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates.
[0051] It should be understood that the preset rules are constraints determined based on patterns from real samples, typically represented as subgraph templates, with a graph path being a special case of a subgraph template. In some embodiments, the subgraph template is a graph path; in other words, the preset rule is a graph path. In other embodiments, the subgraph template may be composed of multiple graph paths, and this is not specifically limited here.
[0052] As a specific implementation, the sources of the preset rules include: high-frequency paths obtained through statistical mining of historical real samples, rules accumulated by human experts, and structured patterns discovered with model assistance. In practice, multiple pre-determined preset rules are stored in a rule graph in a formalized manner, constituting a set of high-risk paths in the rule graph.
[0053] For example, child Figure 1 This includes node 1, node 2, and an edge connecting node 1 and node 2. Node 1 corresponds to entity A, which is of type 1. Node 2 corresponds to entity B, which is of type 2. The edge between node 1 and node 2 represents the semantic association between entity A and entity B, and its type is 1 semantic association type. If preset rule 1 defines a subgraph template that includes entities of type 1 and entities of type 2, and the semantic association between entities of type 1 and entities of type 2 is 1 semantic association type, then the above subgraph... Figure 1 Satisfies preset rule 1. Specifically, a local subgraph example: User A; Transaction 1 (initiator); IP_XYZ (source); Device_1 (binding).
[0054] For ease of understanding, the following explanation uses the application of this method to the field of financial fraud detection as an example. The samples generated through this embodiment are fraud samples. In this embodiment, the preset rules refer to high-risk behavioral constraints pre-constructed based on historical fraud behavior analysis, business risk control experience, and graph structure characteristics. These constraints are used to characterize abnormal patterns of fraudulent transactions across dimensions such as accounts, devices, Internet Protocol (IP), paths, and fields. Each preset rule is represented in the form of a graph path or graph substructure, specifically including node type, edge type, and their attribute constraints, such as abnormal associations between accounts and devices, cross-regional IP path jumps, abnormal transaction time windows, and abnormal combinations of field values. As a specific embodiment, the specific sources of the preset rules include: high-frequency risk paths obtained through statistical mining of historical fraud samples, rules accumulated by human experts, and structured fraud patterns discovered with model assistance.
[0055] It should be understood that the rule graph is constructed based on multiple preset rules. The total number of preset rules in the rule graph can be understood as the number of predefined and effective subgraph templates in the rule graph. This number is determined uniformly during system initialization or preset rule updates. Each rule corresponds to a unique subgraph template; therefore, the total number of preset rules is the count result of all preset rules in the rule graph.
[0056] Optionally, in some embodiments, before step 101, the method further includes:
[0057] Obtain multiple transaction data;
[0058] Extract entities and semantic relationships between entities from the transaction data, and determine the type of the entity and the type of the semantic relationship;
[0059] The rule graph is constructed based on the transaction data. Nodes in the rule graph are used to represent entities, and edges in the rule graph are used to represent semantic relationships between entities.
[0060] In this embodiment, by extracting entities, relationships, and constraints from transaction data in a structured manner and mapping them to nodes and edges in a rule graph, a rule graph is constructed. This allows the behavioral patterns in real transaction data to be extracted as preset rules, thereby providing graph guidance for sample generation and quality assessment.
[0061] In some embodiments, after acquiring multiple transaction data, the method further includes: preprocessing the transaction data, wherein the preprocessing includes at least one of data cleaning, missing value imputation, and normalization. After preprocessing the multiple transaction data, for each transaction data, the entities involved and the semantic relationships between entities are extracted to form a subgraph in the rule graph.
[0062] In some embodiments, after data cleaning, missing value imputation, and normalization of transaction data, entities and semantic relationships between entities are extracted from multiple transaction data, and multi-dimensional transaction features such as transaction amount, timestamp, IP address, user identifier (ID), device type, and geographic information are extracted.
[0063] Building a rule graph based on transaction data ,in, It is a set of nodes, where each node represents an entity. This is an edge set used to represent the semantic relationships between nodes. For example, entities are transaction participants, such as accounts, devices, IPs, time periods, and transactions, with semantic relationships such as "account logged into device", "device bound to IP", and "account's number of transactions within a short period".
[0064] For example, the transaction data is "user_123 initiated a transaction of ¥899 in city A through device 1 on 2025-01-01 at 10:30:00". Entity and semantic associations are extracted from this transaction data, and it is encoded into a feature vector according to preset rules: [User ID=123, Time=0.45, Amount=0.78, IP=encoded vector, Region=0.3, Device Type=0.1], and then converted into a unified matrix input model. By extracting features from multiple transaction data, the input feature matrix can be obtained. for:
[0065] ;
[0066] In this embodiment, multiple transaction data are acquired, entities and semantic relationships between entities are extracted from the transaction data, and the types of entities and semantic relationships are determined. A rule graph is then constructed based on the transaction data. By converting transaction data into a rule graph in this way, information in real data can be fully utilized to explicitly model complex relationships between multidimensional entities, ensuring that the generated samples not only closely approximate real data in statistical distribution but also conform to known paths in topological structure.
[0067] Step 102: Generate a graph guidance vector based on the local subgraph.
[0068] The fact that a local subgraph contains at least one subgraph template indicates that the local subgraph satisfies at least one preset rule. A graph guidance vector is generated based on the local subgraph, which can constrain the generated samples to satisfy a preset rule, ensuring that the generated samples are consistent with the real samples in terms of structure and semantics.
[0069] In this embodiment, the specific method for generating the graph guidance vector based on the local subgraph is not limited. As an optional implementation, graph convolution operations are used to capture the feature information of nodes and their neighbors. By stacking multiple Graph Convolutional Networks (GCN) layers, the information of neighboring nodes is aggregated at different levels to generate node representations containing local subgraph structure and feature information, thereby obtaining the graph guidance vector.
[0070] As another optional implementation, step 102 includes:
[0071] The local subgraph is aggregated with L neighbor information through an L-layer graph attention network to obtain the target feature vector corresponding to the first node, where the first node is the node corresponding to the target entity in the local subgraph and L is a positive integer.
[0072] The target feature vector is determined as the map guidance vector.
[0073] It should be understood that the specific method for determining the target entity is not limited here. In some embodiments, step 101 includes obtaining a local subgraph from a pre-constructed rule graph based on the target entity, wherein the target entity is predetermined. In other embodiments, the target entity is randomly determined. In still other embodiments, the type of entity is predetermined, and then the target entity is determined from the local subgraph according to the predetermined entity type.
[0074] In this embodiment, a multi-layer graph attention network (GAT) is used to aggregate neighbor information multiple times, and the feature vector of each node is updated multiple times so that the feature vector of a node contains the information of its neighboring nodes. The feature vector of the first node obtained is then determined as the target feature vector and used as the graph guidance vector for subsequent processing.
[0075] In this embodiment, L-layer GAT is used to aggregate neighbor information in the local subgraph L times to obtain the target feature vector corresponding to the first node, and the target feature vector is determined as the graph guidance vector. Since GAT can assign different attention weights to different neighbor nodes in the graph, it avoids the problem of information average propagation and is more suitable for modeling the difference between "strong association fraud paths" and "weak association paths" in the rule graph, resulting in a better graph guidance vector.
[0076] Optionally, in some embodiments, through the first The layered graph attention network aggregates neighbor information for the first node, including:
[0077] Determine the second node corresponding to the first node, where the second node is a neighbor node of the first node;
[0078] For each of the second nodes, based on the second node at the... The intermediate feature vector output by layer -1 and the first node at the -1st layer are related to each other. The intermediate feature vector output from layer -1 is used to calculate the attention weights corresponding to the second node. A positive integer less than or equal to L;
[0079] Based on the attention weight, the second node at the... Aggregate the intermediate feature vectors output from layer -1 to obtain the first node at the -1st layer. The intermediate feature vector output by the layer;
[0080] Wherein, the first node is in the The intermediate feature vector output by the layer is the target feature vector, and the intermediate feature vectors output by the first node and the second node in layer 0 are both preset values.
[0081] It should be understood that, in this embodiment, only the first node is used as an example to illustrate the process of passing through the first node. The process of neighbor information aggregation in the layered graph attention network is explained. In the specific implementation, each layered graph attention network will perform neighbor information aggregation in the above manner for each node in the local subgraph.
[0082] It should be understood that when constructing the rule graph, an initial feature vector is generated for each node, and the initial feature vector is a preset value. When the local subgraph is aggregated with neighbor information through the first-layer graph attention network, the input feature vector (the intermediate feature vector output by the 0th layer) is the initial feature vector.
[0083] The intermediate feature vector of each node output by the Lth layer graph attention network is the final feature vector obtained by that node. The final feature vector obtained by the first node is determined as the target feature vector and used as the graph guidance vector to execute subsequent steps.
[0084] For example, as a specific implementation, the graph attention network performs GAT encoding on each node to obtain any node i (denoted as ). Its output intermediate feature vector is:
[0085] ;
[0086] in, Let be the input feature vector of node j, which is the intermediate feature vector corresponding to that node output by the previous layer's graph attention network. Let be a trainable linear transformation matrix. For activation function, Let i be the set of neighboring nodes. Let be the attention weight of node j to node i, calculated as follows:
[0087] ;
[0088] in, This represents vector concatenation. It is a non-linear activation function, and the denominator is a normalized soft maximum function (softmax) to ensure that the sum of the attention weights of all neighboring nodes is 1.
[0089] Step 103: Input the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample.
[0090] In this embodiment, the noise vector is used to introduce random perturbations to prevent the generator from outputting a single sample under the same conditions, thereby ensuring the diversity of generated fraudulent samples. The graph guidance vector is used to constrain the generated samples to meet preset rules, ensuring that the generated samples are consistent with the real samples in terms of structure and semantics.
[0091] It should be understood that the generator is used to generate samples based on the input data, and its specific structure is not limited here. For example, in some embodiments, the generator is a three-layer fully connected network with a Leaky Rectified Linear Unit (LeakyReLU) activation function. Further, the dimensions of the hidden layers in the generator's three-layer fully connected network are 128, 256, and 512, respectively.
[0092] It should be understood that, in some embodiments, before step 103, the method further includes: iteratively training the generative adversarial network based on the training dataset to obtain a trained generative adversarial network, wherein the generative adversarial network includes a generator and a discriminator; and determining the generator in the trained generative adversarial network as the trained generator.
[0093] Optionally, in some embodiments, step 103 includes:
[0094] The graph guidance vector, the noise vector, and the first category label vector are input into the trained generator to generate the first sample.
[0095] The first category label vector corresponds to the first sample category and is used to constrain the first sample to belong to the first sample category.
[0096] In this embodiment, the input data of the generator also includes a first category label vector, which is used to explicitly specify the sample category to which the generated sample belongs, so that the generation process has task controllability and can perform targeted sample expansion for different scenarios.
[0097] In some embodiments, multiple different sample categories are predefined, and a category label vector corresponding to each sample category is generated. In a specific implementation, the category label vector corresponding to the sample category that needs to be generated is used as input data, and is input into the generator along with the graph guidance vector and the noise vector.
[0098] In practical implementation, multiple different sample categories are predefined based on the actual application domain, and a category label vector corresponding to each sample category is generated. When generating samples, to determine which sample category the currently generated sample belongs to, the category label vector corresponding to that sample category is input into the generator along with the noise vector and the graph guidance vector, thereby improving the targeting of sample generation.
[0099] For example, if the first sample category is field-specific fraud (such as "modify geolocation"), and the local subgraph is used to characterize the behavioral patterns constituted by nighttime transactions, abnormal IPs, and blacklisted devices, then the sample output by the generator may generate transaction records that mimic blacklisted devices, Shanghai IPs, and early morning times.
[0100] In this embodiment, the graph guidance vector, noise vector, and first category label vector are input into the trained generator to generate a first sample. The first category label vector corresponds to the category of the first sample and is used to constrain the first sample to belong to the first sample category. By setting the first category label vector, the generation process becomes task-controllable, and the generated sample categories are targeted. The three types of inputs—graph guidance vector, noise vector, and category label vector—complement each other functionally, jointly ensuring that the generated samples meet the actual application requirements in terms of diversity, controllability, and business rationality.
[0101] Optionally, in some embodiments, before inputting the graph guidance vector, the noise vector, and the first category label vector into the trained generator to generate samples and obtain the first sample, the method further includes:
[0102] The Generative Adversarial Network (GAN) is iteratively trained based on the training dataset to obtain a trained GAN. The GAN includes a generator and a discriminator. The discriminator includes multiple sub-discriminators, each of which corresponds to a sample class. The first sample class is any one of the multiple sample classes.
[0103] The generator in the trained generative adversarial network is determined as the trained generator;
[0104] The loss value of the target sub-discriminator is determined based on the real samples of the second sample category corresponding to the target sub-discriminator and the samples generated by the generator. The second sample category is the sample category corresponding to the target sub-discriminator, and the target sub-discriminator is any one of the sub-discriminators.
[0105] In this embodiment, there are multiple sub-discriminators, and the number of sub-discriminators is the same as the number of sample categories. Each sub-discriminator corresponds to one sample category. Each sub-discriminator independently receives real samples and generated samples of the corresponding type and calculates its corresponding loss value.
[0106] As a specific example, such as Figure 2 As shown, a Multi-Branch Conditional Generative Adversarial Network (MB-CGAN) structure is adopted. The discriminator consists of 5 sub-discriminators, each of which is dedicated to distinguishing samples of a corresponding sample class. All sub-discriminators share the underlying network, but their output layers are independent.
[0107] Taking financial fraud as an example, five sample categories are predefined based on the type of fraud, as follows:
[0108] The first sample category is account hijacking, whose data characteristics include device changes, increased login frequency, and rapid transactions.
[0109] The second sample category is device impersonation, whose data characteristics are that the device ID is an emulator / rare device and the first transaction amount is greater than the first threshold (e.g., 100,000).
[0110] The third sample category is path fraud, which is characterized by rapid IP changes within a short period of time, such as changing from city A to city B and then to city C within one hour.
[0111] The fourth sample category is field tampering, and its data characteristics are that the amount field is greater than the second threshold (e.g., 99999), the product name is empty, and the merchant ID is fictitious.
[0112] The fifth sample category is collusive transactions, characterized by multiple accounts transferring funds to each other within a short period of time (e.g., 1 hour), forming a highly correlated subgraph.
[0113] Specifically, the first sub-discriminator corresponds to the first sample class, the second sub-discriminator corresponds to the second sample class, the third sub-discriminator corresponds to the third sample class, the fourth sub-discriminator corresponds to the fourth sample class, and the fifth sub-discriminator corresponds to the fifth sample class.
[0114] Five sub-discriminators, categorized by fraud type, each receive samples from their respective categories and calculate their corresponding losses. These losses are then merged into a total discriminant loss to optimize the generator. Each sub-discriminator focuses on identifying a specific type of fraud sample, thus addressing the problem of weak detection caused by the average learning of a single discriminator.
[0115] In this embodiment, a multi-branch discriminator is used, which uses its corresponding sub-discriminator to distinguish different types of samples. This improves the rationality of the discriminator structure, thereby better dealing with the complex and varied sample types and improving the accuracy of the discrimination results.
[0116] It should be understood that the training process of Generative Adversarial Networks (GANs) employs an alternating optimization strategy, with the generator and discriminator trained separately and their loss functions calculated independently. Specifically, in each training iteration, the generator parameters are first fixed, and the discriminator is trained using both real samples and samples generated by the generator, enabling it to effectively distinguish between real and generated data. Then, the discriminator parameters are fixed, and only the generator parameters are updated. The generator is optimized by minimizing the probability that a generated sample is judged as "false" by the discriminator (or equivalently maximizing the probability that it is judged as "true"). The generator's loss value is calculated solely based on the output of the generated sample under the current discriminator. These two steps are performed alternately, forming an adversarial game process. Training continues until preset stopping conditions are met, including but not limited to: reaching the maximum number of training rounds, the loss values of the generator and discriminator stabilizing over several consecutive rounds (i.e., the change is less than a preset threshold), or external evaluation metrics confirming that the generation quality meets the requirements. Throughout the training process, the generator and discriminator continuously update their parameters with their own independent loss signals, thereby gradually improving the realism and diversity of the generated samples.
[0117] In some embodiments, to improve sample diversity, KL divergence (Kullback–Leibler Divergence) constraints are introduced during training to generate the distribution:
[0118] ;
[0119] in, For the true sample distribution, The distribution of samples generated by the generator. KL divergence is used to constrain the overall distribution consistency of the generated samples. Its calculation is based on sample class conditions and has no direct correspondence with the structure of the discriminator module. Therefore, it is uniformly calculated on the generator side.
[0120] In some embodiments, the generator's total loss function for:
[0121] ;
[0122] in, The weight of the k-th sample category, The number of sub-discriminators, The generator output is a noise vector as input. Label category vector Graph-guided vector , For the k-th sub-discriminator, The weight hyperparameters for the KL divergence regularization term control the importance of distribution matching. The loss value is determined based on KL divergence. The specific calculation method can be found in the description in the relevant technology, and will not be elaborated here.
[0123] It should be understood that the input to the discriminator is the sample generated by the generator. The output is the probability value of being true or false. This indicates whether the input sample is a fake sample. In this embodiment, each sub-discriminator independently receives real samples and generated samples of the corresponding type and calculates the binary classification loss:
[0124]
[0125] in, This represents the probability that the k-th sub-discriminator outputs a "real" sample. The first term in the formula is the loss for classifying real samples as true, and the second term is the loss for classifying generated samples as false. This loss is the standard binary cross-entropy loss, used for the discrimination optimization objective in adversarial training.
[0126] Optionally, in some embodiments, after step 103, the method further includes:
[0127] Calculate a first score and a second score for the first sample, wherein the first score is determined based on the statistical distance between the first sample and the real sample, and the second score is determined based on the ratio of the number of preset rules matched by the first sample to the total number of preset rules;
[0128] The target score is determined based on the first score and the second score;
[0129] The first sample whose target score is greater than or equal to the threshold is identified as the second sample.
[0130] In this embodiment, in order to control sample quality and filter invalid synthetic data, a dual-scale scoring mechanism is constructed by calculating the first score and the second score of the generated samples, thereby screening the samples generated by the generator and determining the first sample that meets the requirements as the second sample.
[0131] In this embodiment, the first score can also be called FID (Fréchet Inception Distance), which is used to measure the statistical distance between the generated sample and the real sample:
[0132] ;
[0133] in, and These represent the mean vectors of the real samples and the generated samples in the feature embedding space, respectively, and are used to characterize the overall central position of the distribution of the two types of samples; and These represent the covariance matrices of the feature distributions corresponding to the real samples and the generated samples, respectively, and are used to describe the correlation between transaction features and the degree of dispersion of their distributions.
[0134] Mean difference term The trace is used to measure the degree of deviation of generated samples from real samples at the overall behavioral level. This is used to measure the degree of consistency between generated samples and real samples in terms of feature-related structure. Through the joint calculation of the above parameters, the first score can comprehensively reflect the degree of similarity between generated samples and real samples in terms of distribution pattern, feature center, and behavioral structure.
[0135] The second score, also known as the rule coverage score, is determined by the ratio of the number of preset rules matched by the first sample to the total number of preset rules.
[0136] ;
[0137] It should be understood that each rule is represented in the form of a subgraph template. The number of matched rules refers to the number of subgraph templates that are satisfied after the generated sample is mapped to the rule graph. In the specific implementation, the first sample is first parsed into the attribute representation of nodes and edges in the graph; then, each preset rule in the rule graph is matched and judged. If the first sample simultaneously satisfies the constraints set in the subgraph template in terms of node type, edge type, and path structure, then the first sample is determined to have matched the preset rule, and the corresponding preset rule is added to the set of matched rules. Finally, the preset rules matched by the first sample are the number of preset rules in this set. The total number of rules in the graph refers to the total number of preset rules that are predefined and in effect in the rule graph.
[0138] The second score can be used to measure the extent to which the generated samples cover known high-risk patterns at the rule level. The higher the second score, the more high-risk behavior rules the samples conform to, and the higher the rationality of the sample structure and the higher the business credibility; conversely, it indicates that the samples are insufficient in terms of rule consistency.
[0139] It should be understood that the specific method for determining the target score based on the first score and the second score is not limited herein. In some embodiments, the target score is determined based on a weighted sum of the first score and the second score. In other embodiments, the target score is calculated based on the first score and the second score according to a preset method.
[0140] As a specific example, the target score for:
[0141] ;
[0142] in, and The predetermined weight values can be set and challenged according to the actual situation. For example, It is 0.6. It is 0.4. Furthermore, if... If the first sample is selected as the second sample and added to the training set, then the first sample is selected as the second sample and added to the training set; otherwise, it is removed.
[0143] In this embodiment, a first score and a second score are calculated for the generated samples. A target score is determined based on these scores, and samples with a target score greater than or equal to a threshold are selected for inclusion in the training set. The first score reflects the degree to which the generated samples closely resemble real samples in terms of distribution, feature centers, and behavioral structure. The second score measures the degree to which the generated samples cover known high-risk patterns at the rule level. This method allows for better selection of generated samples.
[0144] It should be understood that the sample generation method provided in this embodiment of the invention is applicable to different industry scenarios such as financial payment, credit reporting, insurance, and e-commerce, and is used to generate samples in the corresponding fields for training, thereby improving the system's ability to identify unknown fraud and saving a lot of labeling and repeated parameter tuning costs.
[0145] For example, in practical applications, in order to improve the model's ability to identify fraudulent transactions of this type of collusion, the sample generation method described in this invention is used to synthesize high-quality collusion fraud samples and use them to train the discrimination model. In this embodiment, the discrimination model is an independent business fraud identification model, which is different from the discriminator in the GAN network in terms of purpose and stage. Its specific details will not be elaborated here.
[0146] Please see Figure 3 The following is a specific example to illustrate the detailed process of generating fraudulent samples through an embodiment of the present invention.
[0147] S1: Perform data preprocessing and feature construction.
[0148] Historical transaction data from the system is obtained, including fields such as account ID, device ID, IP address, transaction time, amount, and merchant ID. After normalization and feature derivation, structured transaction samples as shown in Table 1 are generated.
[0149] Table 1: Sample Structured Transactions
[0150]
[0151] Based on the above, a transaction sample matrix is generated. .
[0152] S2: Construct a regular graph and extract local subgraphs.
[0153] The following rule relationships are extracted from the risk control rule base as preset rules, and a rule graph is constructed:
[0154] The predefined types of entities (nodes) include: account, device, IP, transaction time period, and merchant. The predefined types of semantic relationships (edges) include: account to device, account to IP, device to IP, account to merchant, and account to account (transfer).
[0155] Taking account A as the target entity, the following local subgraph is extracted from the rule graph: ; .
[0156] After encoding the local subgraph using the GAT model, the vector embedding of the first node corresponding to account A in the local subgraph is generated and used as the graph guiding vector. :
[0157] ;
[0158] It should be understood that the graph guidance vector input to the generator is not derived from the vector set of all nodes in the local subgraph. Instead, it is a subgraph-level vector obtained by extracting the associated local subgraphs from the regular graph for the target entity corresponding to the current generated sample, and aggregating the graph representations of the nodes in those subgraphs. This graph guidance vector is used to characterize the behavioral structural features of the target entity in multi-dimensional relationships such as accounts, devices, and IPs, thus serving as a conditional input constraint for the generator to ensure the structural rationality of the generated samples.
[0159] S3: Use a generator to generate fraudulent samples.
[0160] Obtain the input data, specifically including: noise vector ; Category label vector corresponding to the sample category "collusive transaction" The spectral guiding vector obtained in S2 The noise vector Category label vectors and spectral guiding vector Input generator G to obtain generated samples As shown in Table 2:
[0161] Table 2 Examples of Fraud Sample Features Generated
[0162]
[0163] Therefore, the generated samples have characteristics such as multi-account collaborative transactions and high-frequency small-amount transfers, and have strong simulation performance.
[0164] S4: MB-CGAN discrimination and training.
[0165] The generated sample is fed into a multi-branch discriminator. In this embodiment, there are 5 sub-discriminators, denoted as follows: ,in, The corresponding sample category is collusive transaction. Therefore, The discrimination probability of this sample is less than 0.3. The output probability is 0.92. The discriminator, combined with loss feedback, drives the generator in... Learn stronger fraud features in the discrimination dimension.
[0166] After 1000 rounds of adversarial training between the generator and the discriminator, the success rate of generating collusive samples was significantly improved.
[0167] S5: Sample selection and inclusion in the training set.
[0168] The generated samples undergo a two-scale quality assessment, calculating the first score (FID) and the second score (RuleCoverage) for each sample. For example, for any given generated sample, its FID is calculated to be 8.32 (below the threshold of 15, indicating a reasonable sample distribution); its RuleCoverage is 0.86 (hitting 5 out of 6 paths in the rule graph); and the final target score is 0.623. Since the target score is greater than the threshold (0.5), this generated sample is retained and added to the fraud training sample set.
[0169] According to the experimental data, after adding 3,000 collusion samples generated by the method provided in the above embodiments to the fraud training sample set, the accuracy of the discrimination model in identifying collusion-type transactions increased from 78.2% to 86.5%, and the discrimination effect of the discrimination model was significantly improved.
[0170] In this embodiment, by synthesizing diverse and semantically rich high-quality fraud samples, the overfitting and missed detection problems of the discrimination model on rare fraud types (such as collusive transactions and device impersonation) are effectively alleviated. Simultaneously, this invention can automatically generate controllable samples covering different fraud types as supplementary training sets, significantly replacing some manually labeled data and improving the efficiency and convenience of generating fraud samples.
[0171] Please see Figure 4 The present invention also provides a sample generation device 400. Figure 4 This is a structural diagram of the sample generation device 400 provided in an embodiment of the present invention. Because the principle of the sample generation device 400 in solving the problem is similar to that in the embodiment of the present invention... Figure 1The methods for generating the samples shown are similar, so the implementation of the sample generation apparatus 400 can be found in the implementation of the method, and the repeated parts will not be described again.
[0172] like Figure 4 As shown, the sample generation device 400 includes:
[0173] The first acquisition module 401 is used to acquire a local subgraph from a pre-constructed rule graph. The rule graph is constructed based on multiple preset rules. Each preset rule defines a subgraph template. The subgraph template includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates.
[0174] Generation module 402 is used to generate a graph guidance vector based on the local subgraph;
[0175] The input module 403 is used to input the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample.
[0176] Optionally, the generation module 402 includes:
[0177] An L-layer graph attention network is used to perform L-time neighbor information aggregation on the local subgraph to obtain the target feature vector corresponding to the first node, where the first node is the node corresponding to the target entity in the local subgraph, and L is a positive integer.
[0178] A determining unit is used to determine the target feature vector as the map guidance vector.
[0179] Optionally, through the first The layered graph attention network aggregates neighbor information for the first node, including:
[0180] Determine the second node corresponding to the first node, where the second node is a neighbor node of the first node;
[0181] For each of the second nodes, based on the second node at the... The intermediate feature vector output by layer -1 and the first node at the -1st layer are related to each other. The intermediate feature vector output from layer -1 is used to calculate the attention weights corresponding to the second node. A positive integer less than or equal to L;
[0182] Based on the attention weight, the second node at the... Aggregate the intermediate feature vectors output from layer -1 to obtain the first node at the -1st layer. The intermediate feature vector output by the layer;
[0183] Wherein, the first node is in the The intermediate feature vector output by the layer is the target feature vector, and the intermediate feature vectors output by the first node and the second node in layer 0 are both preset values.
[0184] Optionally, the sample generation apparatus 400 further includes:
[0185] The calculation module is used to calculate a first score and a second score for the first sample. The first score is determined based on the statistical distance between the first sample and the real sample, and the second score is determined based on the ratio of the number of preset rules matched by the first sample to the total number of preset rules.
[0186] A first determining module is used to determine a target score based on the first score and the second score;
[0187] The second determining module is used to determine the first sample whose target score is greater than or equal to the threshold as the second sample.
[0188] Optionally, the input module 403 is specifically used for:
[0189] The graph guidance vector, the noise vector, and the first category label vector are input into the trained generator to generate the first sample.
[0190] The first category label vector corresponds to the first sample category and is used to constrain the first sample to belong to the first sample category.
[0191] Optionally, the sample generation apparatus 400 further includes:
[0192] The iterative training module is used to iteratively train the generative adversarial network based on the training dataset to obtain a trained generative adversarial network. The generative adversarial network includes a generator and a discriminator. The discriminator includes multiple sub-discriminators. Each sub-discriminator corresponds to a sample class. The first sample class is any one of the multiple sample classes.
[0193] The third determining module is used to determine the generator in the trained generative adversarial network as the trained generator;
[0194] The loss value of the target sub-discriminator is determined based on the real samples of the second sample category corresponding to the target sub-discriminator and the samples generated by the generator. The second sample category is the sample category corresponding to the target sub-discriminator, and the target sub-discriminator is any one of the sub-discriminators.
[0195] Optionally, the sample generation apparatus 400 further includes:
[0196] The second acquisition module is used to acquire multiple transaction data.
[0197] The processing module is used to extract entities and semantic associations between entities from the transaction data, and to determine the type of the entity and the type of the semantic association;
[0198] A construction module is used to construct the rule graph based on the transaction data. Nodes in the rule graph are used to represent entities, and edges in the rule graph are used to represent semantic relationships between entities.
[0199] The sample generation apparatus 400 provided in this embodiment of the invention can execute the sample generation method embodiment described above. Its implementation principle and technical effect are similar, and will not be described again here.
[0200] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0201] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can be physically comprised separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or in the form of hardware plus software functional units.
[0202] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute some steps of the transmission and reception methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0203] like Figure 5 As shown, this embodiment of the invention also provides an electronic device 500, which includes a processor 501, configured to read a program from a memory 502 and execute the following steps:
[0204] A local subgraph is obtained from a pre-constructed rule graph, which is built based on multiple preset rules. Each preset rule defines a subgraph template, which includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates.
[0205] Generate a graph guidance vector based on the local subgraph;
[0206] The graph guidance vector and noise vector are input into the trained generator to generate samples, thus obtaining the first sample.
[0207] Optionally, the processor 501 is further configured to read the program in the memory 502 and perform the following steps:
[0208] The local subgraph is aggregated with L neighbor information through an L-layer graph attention network to obtain the target feature vector corresponding to the first node, where the first node is the node corresponding to the target entity in the local subgraph and L is a positive integer.
[0209] The target feature vector is determined as the map guidance vector.
[0210] Optionally, the processor 501 is further configured to read the program in the memory 502 and perform the following steps:
[0211] Determine the second node corresponding to the first node, where the second node is a neighbor node of the first node;
[0212] For each of the second nodes, based on the second node at the... The intermediate feature vector output by layer -1 and the first node at the -1st layer are related to each other. The intermediate feature vector output from layer -1 is used to calculate the attention weights corresponding to the second node. A positive integer less than or equal to L;
[0213] Based on the attention weight, the second node at the... Aggregate the intermediate feature vectors output from layer -1 to obtain the first node at the -1st layer. The intermediate feature vector output by the layer;
[0214] Wherein, the first node is in the The intermediate feature vector output by the layer is the target feature vector, and the intermediate feature vectors output by the first node and the second node in layer 0 are both preset values.
[0215] Optionally, the processor 501 is further configured to read the program in the memory 502 and perform the following steps:
[0216] Calculate a first score and a second score for the first sample, wherein the first score is determined based on the statistical distance between the first sample and the real sample, and the second score is determined based on the ratio of the number of preset rules matched by the first sample to the total number of preset rules;
[0217] The target score is determined based on the first score and the second score;
[0218] The first sample whose target score is greater than or equal to the threshold is identified as the second sample.
[0219] Optionally, the processor 501 is further configured to read the program in the memory 502 and perform the following steps:
[0220] The graph guidance vector, the noise vector, and the first category label vector are input into the trained generator to generate the first sample.
[0221] The first category label vector corresponds to the first sample category and is used to constrain the first sample to belong to the first sample category.
[0222] Optionally, the processor 501 is further configured to read the program in the memory 502 and perform the following steps:
[0223] The generative adversarial network is iteratively trained based on the training dataset to obtain a trained generative adversarial network. The generative adversarial network includes a generator and a discriminator. The discriminator includes multiple sub-discriminators, each of which corresponds to a sample category. The first sample category is any one of the multiple sample categories.
[0224] The generator in the trained generative adversarial network is determined as the trained generator;
[0225] The loss value of the target sub-discriminator is determined based on the real samples of the second sample category corresponding to the target sub-discriminator and the samples generated by the generator. The second sample category is the sample category corresponding to the target sub-discriminator, and the target sub-discriminator is any one of the sub-discriminators.
[0226] Optionally, the processor 501 is further configured to read the program in the memory 502 and perform the following steps:
[0227] Obtain multiple transaction data;
[0228] Extract entities and semantic relationships between entities from the transaction data, and determine the type of the entity and the type of the semantic relationship;
[0229] The rule graph is constructed based on the transaction data. Nodes in the rule graph are used to represent entities, and edges in the rule graph are used to represent semantic relationships between entities.
[0230] The electronic device 500 provided in this embodiment of the invention can execute the above-described sample generation method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0231] This application also provides a readable storage medium storing a program. When the program is executed by a processor, it implements the various processes of the above-described sample generation method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0232] The readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as compact disks (CD), digital video discs (DVD), Blu-ray discs (BD), high-definition universal discs (HVD), etc.), and semiconductor storage (such as read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), non-volatile memory (NAND FLASH), solid-state disks (SSD), etc.).
[0233] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0234] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0235] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for generating a sample, characterized in that, include: A local subgraph is obtained from a pre-constructed rule graph, which is built based on multiple preset rules. Each preset rule defines a subgraph template, which includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates. Generate a graph guidance vector based on the local subgraph; The graph guidance vector and noise vector are input into the trained generator to generate samples, thus obtaining the first sample.
2. The method according to claim 1, characterized in that, The generation of the graph guidance vector based on the local subgraph includes: The local subgraph is aggregated with L neighbor information through an L-layer graph attention network to obtain the target feature vector corresponding to the first node, where the first node is the node corresponding to the target entity in the local subgraph and L is a positive integer. The target feature vector is determined as the map guidance vector.
3. The method according to claim 2, characterized in that, Through the first The layered graph attention network aggregates neighbor information for the first node, including: Determine the second node corresponding to the first node, where the second node is a neighbor node of the first node; For each of the second nodes, based on the second node at the... The intermediate feature vector output by layer -1 and the first node at the -1st layer are related to each other. The intermediate feature vector output from layer -1 is used to calculate the attention weights corresponding to the second node. A positive integer less than or equal to L; Based on the attention weight, the second node at the... Aggregate the intermediate feature vectors output from layer -1 to obtain the first node at the -1st layer. The intermediate feature vector output by the layer; Wherein, the first node is in the The intermediate feature vector output by the layer is the target feature vector, and the intermediate feature vectors output by the first node and the second node in layer 0 are both preset values.
4. The method according to claim 1, characterized in that, After inputting the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample, the method further includes: Calculate a first score and a second score for the first sample, wherein the first score is determined based on the statistical distance between the first sample and the real sample, and the second score is determined based on the ratio of the number of preset rules matched by the first sample to the total number of preset rules; The target score is determined based on the first score and the second score; The first sample whose target score is greater than or equal to the threshold is identified as the second sample.
5. The method according to claim 1, characterized in that, The step of inputting the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample includes: The graph guidance vector, the noise vector, and the first category label vector are input into the trained generator to generate the first sample. The first category label vector corresponds to the first sample category and is used to constrain the first sample to belong to the first sample category.
6. The method according to claim 5, characterized in that, Before inputting the graph guidance vector, the noise vector, and the first category label vector into the trained generator to generate samples and obtain the first sample, the method further includes: The generative adversarial network is iteratively trained based on the training dataset to obtain a trained generative adversarial network. The generative adversarial network includes a generator and a discriminator. The discriminator includes multiple sub-discriminators, each of which corresponds to a sample category. The first sample category is any one of the multiple sample categories. The generator in the trained generative adversarial network is determined as the trained generator; The loss value of the target sub-discriminator is determined based on the real samples of the second sample category corresponding to the target sub-discriminator and the samples generated by the generator. The second sample category is the sample category corresponding to the target sub-discriminator, and the target sub-discriminator is any one of the sub-discriminators.
7. The method according to any one of claims 1-6, characterized in that, Before obtaining the local subgraph from the pre-constructed rule graph, the method further includes: Obtain multiple transaction data; Extract entities and semantic relationships between entities from the transaction data, and determine the type of the entity and the type of the semantic relationship; The rule graph is constructed based on the transaction data. Nodes in the rule graph are used to represent entities, and edges in the rule graph are used to represent semantic relationships between entities.
8. A sample generation apparatus, characterized in that, include: The first acquisition module is used to acquire local subgraphs from a pre-constructed rule graph. The rule graph is constructed based on multiple preset rules, and each preset rule defines a subgraph template. The subgraph template includes node type, edge type, and attribute constraints. The node type is used to limit the type of entity represented by the node in the subgraph template. The edge type is used to limit the type of semantic association represented by the edge in the subgraph template. The attribute constraints are used to limit the attribute value range corresponding to the node type and / or the edge type. The local subgraph contains at least one of the subgraph templates. The generation module is used to generate a graph guidance vector based on the local subgraph; The input module is used to input the graph guidance vector and noise vector into the trained generator to generate samples and obtain the first sample.
9. An electronic device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; characterized in that, The processor is configured to read a program from the memory to implement the steps in the sample generation method as described in any one of claims 1 to 7.
10. A readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps in the sample generation method as described in any one of claims 1 to 7.