A training sample generation method and a federated learning method

By receiving and generating feature value distribution sets, it solves the problems of data privacy protection and insufficient model training samples, and implements a federated learning method that improves model accuracy and training efficiency without sharing original data.

CN113850309BActive Publication Date: 2024-09-17ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111082326.X
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

Technical Problem

In scenarios such as financial risk control, each institution has limited data, which affects model accuracy. Since data is an asset, institutions are unwilling to share original data, making it difficult to share data without infringing on data privacy.

Method used

By receiving the feature value distribution set sent by the collaborative data provider, new training samples that conform to the distribution are generated for model training, ensuring that the data provider cannot reversely decode the original data and achieve data sharing.

Benefits of technology

While protecting data privacy, it generates sufficient training samples, improves the accuracy and efficiency of model training, reduces the cost of third-party servers participating in training, and avoids data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113850309B
    Figure CN113850309B
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a training sample generation and federated learning method, which is applied to any data provider between at least two mutually cooperating data providers, receives a feature value distribution set sent by the cooperating data provider to characterize the value distribution of each feature, and generates data that conforms to the distribution characterized by the feature value distribution set based on the feature value distribution set, and uses the generated data as a new training sample. Since what is received is the feature value distribution set that characterizes the value distribution of the feature, the data provider cannot reverse-solve the received data to obtain the data of each user, thereby protecting data privacy; and the data provider is able to generate sufficient training samples, thereby realizing data sharing while protecting data privacy.
Need to check novelty before this filing date? Find Prior Art

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 training sample generation method and a federated learning method. Background Art

[0002] In the era of big data, models can be trained with large amounts of data to obtain applicable models. For example, in financial risk control scenarios, existing transaction data can be used to obtain a model to determine whether each transaction has a risk of fraud. However, the amount and type of data for each institution is limited, which affects the accuracy of the final trained model. To address this problem, one solution in related technologies is for multiple institutions to cooperate with each other and share data so that there are enough training samples for model training, so that the final trained model can have better accuracy.

[0003] Data itself is an asset, and in order to protect privacy, organizations generally do not share original data. So how to achieve data sharing without infringing data privacy so that there are enough samples for model training is an urgent problem to be solved. Summary of the invention

[0004] In view of this, this specification provides a training sample generation method and a federated learning method.

[0005] According to a first aspect of one or more embodiments of this specification, a training sample generation method is proposed, which is applied to any data provider of at least two data providers in a collaborative relationship, and pre-sets a feature structure of a new training sample of the data provider; the method includes:

[0006] Receive a feature value distribution set sent by a collaborative data provider; the feature value distribution set is used to characterize the feature value distribution of each feature in the training sample set of the collaborative data provider;

[0007] According to the received feature value distribution set and the preset feature structure, new training samples are generated.

[0008] According to a second aspect of one or more embodiments of the present specification, a federated learning method is proposed, which is applied to any data provider including a federated training system, wherein the federated training system includes at least two data providers having a data collaboration relationship, and any data provider obtains a new training sample by the above training sample generation method, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set; the method includes:

[0009] The following steps are iteratively performed until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold:

[0010] Input the new training sample set into the model to obtain the output loss;

[0011] Calculate the gradient of the model based on the output loss;

[0012] Send the calculated gradient to the collaborative data provider and receive the gradient sent by the collaborative data provider;

[0013] Get the average of the received gradient and the calculated gradient, and update the model weights based on the obtained average.

[0014] According to a third aspect of an embodiment of this specification, a training sample generating device is provided, which is applied to any data provider among at least two data providers having a collaborative relationship, and pre-sets a feature structure of a new training sample of the data provider; the device comprises:

[0015] The feature value distribution set receiving module is used to receive the feature value distribution set sent by the collaborative data provider; the feature value distribution set is used to characterize the feature value distribution of each feature in the training sample set of the collaborative data provider;

[0016] The training sample generation module is used to generate new training samples according to the received feature value distribution set and the preset feature structure.

[0017] According to a fourth aspect of the embodiments of this specification, a federated learning device is provided, which is applied to any data provider including a federated training system, wherein the federated training system includes at least two data providers having a data collaboration relationship, and any data provider obtains a new training sample through the above-mentioned training sample generation method, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set; the device includes:

[0018] The following steps are iteratively performed until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold:

[0019] The output loss acquisition module is used to input the obtained new training sample set into the model to obtain the output loss;

[0020] The gradient calculation module is used to calculate the gradient of the model based on the output loss;

[0021] A gradient transceiver module is used to send the calculated gradient to the collaborative data provider and receive the gradient sent by the collaborative data provider;

[0022] The weight update module is used to obtain the average value of the received gradient and the calculated gradient, and update the weight of the model according to the obtained average value.

[0023] According to a fifth aspect of the embodiments 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 above-mentioned training sample generation method or federated learning method is implemented.

[0024] According to a sixth aspect of the embodiments of this specification, there is provided an electronic device, including:

[0025] processor;

[0026] a memory for storing processor-executable instructions;

[0027] The processor implements the above-mentioned training sample generation method or federated learning method by running the executable instructions.

[0028] One or more embodiments of the present specification provide a training sample generation method and device, which is applied to any data provider between at least two mutually cooperating data providers, receives a feature value distribution set sent by the cooperating data provider to characterize the value distribution of each feature, and generates data that conforms to the distribution characterized by the feature value distribution set based on the feature value distribution set, and uses the generated data as a new training sample. Since what is received is the feature value distribution set that characterizes the value distribution of the feature, the data provider cannot reverse-solve the received data to obtain the data of each user, thereby protecting data privacy; and the data provider is able to generate sufficient training samples, thereby realizing data sharing while protecting data privacy.

[0029] 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

[0030] 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.

[0031] Figure 1 This is a flowchart of a training sample generation method shown in this specification according to an exemplary embodiment.

[0032] Figure 2A This is a flowchart of a training sample generation method shown in this specification according to a specific embodiment.

[0033] Figure 2B It is a schematic diagram of a training sample generation method shown in this specification according to a specific embodiment.

[0034] Figure 3 It is a flowchart of a federated learning method shown in this specification according to an exemplary embodiment.

[0035] Figure 4 It is a block diagram of a training sample generating device shown in this specification according to an exemplary embodiment.

[0036] Figure 5 It is a block diagram of a federated learning device according to an exemplary embodiment of this specification.

[0037] Figure 6 It is a hardware structure diagram of a computer device where a federated learning device or a training sample generating device is located according to an exemplary embodiment shown in this specification. DETAILED DESCRIPTION

[0038] 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.

[0039] 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.

[0040] Federated learning is a machine learning framework that was created to solve the problem of data silos. It allows two data providers to share data while ensuring data privacy. Federated learning is generally divided into vertical federated learning, horizontal federated learning, and federated transfer learning.

[0041] Vertical federated learning refers to the situation where two or more data providers have more overlap in users but less overlap in features. For example, each subsidiary of a group has a graph. Since each subsidiary corresponds to the user group of the group and the businesses of different subsidiaries are different, the users corresponding to the nodes in different graphs overlap more, and the business meanings expressed by the attributes of the nodes and edges of different graphs will be different.

[0042] Horizontal federated learning refers to two or more data providers with less user overlap but more feature overlap. For example, there are multiple companies with the same or similar businesses, and each of these companies has a graph. Since different graphs are used to describe the same business, the business meanings expressed by the attributes of their nodes and edges are basically the same, but different companies have different user groups, and the users corresponding to the nodes of different graphs are basically different.

[0043] Federated transfer learning refers to the situation where the users and features of two or more data providers have little overlap. For example, there are companies with similar businesses in different countries. Each of these companies has a graph. Since different graphs belong to companies in different countries, although the businesses of different companies are similar, the properties of nodes and edges of different graphs are different due to differences in countries. However, since the businesses of different companies are similar, the properties of nodes and edges of different graphs still have commonalities. For users, since different companies belong to different countries, their users are basically different.

[0044] In the current federated learning method, in order to maximize the training efficiency (that is, to reduce the amount of data transmitted) and to protect data privacy as much as possible so that the transmitted data cannot be reversed to obtain the original data, dimension alignment is usually achieved by: assuming that each feature of a data provider obeys a well-known distribution, such as a normal distribution, calculating the mean and variance of the feature value of each feature of the data provider, and using the calculated mean and variance as parameters of the normal distribution and passing them to other data providers, so that other data providers can simulate and generate samples for training according to the received mean and variance in the form of a normal distribution. In most cases, the features of a data provider generally do not obey a specific distribution, which will make the samples generated by other data providers for training inaccurate, affecting the final training effect.

[0045] In order to solve the above problems, this specification provides a training sample generation method, which is applied to any data provider between at least two mutually cooperating data providers, receives a feature value distribution set sent by the cooperating data provider, which is used to characterize the value distribution of each feature, and generates data that conforms to the distribution represented by the feature value distribution set based on the feature value distribution set, and uses the generated data as a new training sample. Since what is received is the feature value distribution set that characterizes the value distribution of the feature, the data provider cannot reverse-solve the received data to obtain the data of each user, thereby protecting data privacy; and the data provider is able to generate training samples sufficient to complete model training, thereby realizing data sharing while protecting data privacy.

[0046] First, this specification provides a training sample generation method, which is applied to any data provider of at least two data providers in a collaborative relationship, and pre-sets the feature structure of the new training sample of the data provider. This method can be applied to horizontal federated learning or vertical federated learning. In this method, the correlation between different features is not paid attention to. In other words, each feature is independent of each other. When each feature is independent of each other, a relatively stable training result can be obtained for a linear model. Even if the correlation between features is ignored, the effect of the model obtained by this joint training is better than that of the model obtained by ordinary single training. In addition, it should be noted that the data providers can communicate with each other.

[0047] like Figure 1 As shown, Figure 1 This is a flowchart of a training sample generation method according to an exemplary embodiment of the present specification, comprising the following steps:

[0048] Step 101, receiving a feature value distribution set sent by a collaborative data provider; the feature value distribution set is used to characterize the feature value distribution of each feature in the training sample set of the collaborative data provider.

[0049] The collaborative data provider refers to a data provider other than the data provider to which the method is applied among several data providers in a collaborative relationship. Since the method can be applied to any data provider, each data provider is a collaborative data provider for other data providers. For example, if data provider A and data provider B have a collaborative relationship, when the method is applied to data provider A, data provider B is a collaborative data provider, and when the method is applied to data provider B, data provider A is a collaborative data provider.

[0050] In addition, considering that in the process of federated learning or data transmission, although the participation of a third-party server can guarantee the accuracy of the training results to a certain extent, training or data integration on a third-party server will increase costs (the cost of renting and maintaining a third-party server), and the data needs to be handled by a third-party server, which is prone to data leakage. Therefore, in the various methods and devices provided in this specification, in order to reduce costs and prevent data leakage, no third-party server participates in training or data integration. In other words, in the process of generating training samples and model training, only a number of data providers with a collaborative relationship participate, and no third-party server participates.

[0051] In order to protect data privacy, make data non-reversible, and improve training efficiency as much as possible, so that the training efficiency is not lower than the training efficiency when no federated learning is performed (in other words, it is necessary to ensure that the transmitted data is as small as possible), choose to obtain data from other data providers by receiving eigenvalue distribution sets, so that the data provider can know the eigenvalue distribution provided by other data through less data transmission, and thus generate new training samples based on the eigenvalue distribution.

[0052] The feature value distribution set of each collaborative data provider includes the feature value distribution of each feature in the training samples of the collaborative data provider. Taking graph data as an example, the graph includes a number of nodes and a number of edges. The feature vector of the node includes three features A, B and C. When the feature of the edge is D, the feature value distribution set sent by the collaborative data provider includes data for characterizing the feature value distribution of the four features A, B, C and D.

[0053] The distribution of eigenvalues ​​of each feature can be characterized by a probability density function, a probability mass function, or the number of eigenvalues ​​falling within each value range.

[0054] In the case where the eigenvalue value distribution is characterized by the number of eigenvalues ​​falling within each value range, the method for generating the eigenvalue distribution of each feature may be: determining the minimum value of the eigenvalue of the feature; using a preset segmentation parameter as the difference between the upper limit and the lower limit of each eigenvalue value range, using the minimum value of the eigenvalue as the lower limit of the first value range, and generating a number of continuous eigenvalue value ranges in order from small to large, wherein the maximum value in the eigenvalue is less than the upper limit of the last eigenvalue value range and greater than the lower limit of the last eigenvalue value range; and counting the number of eigenvalues ​​falling within each eigenvalue value range to generate the eigenvalue distribution of the feature.

[0055] For example, suppose that the eigenvalue values ​​are 5, 3, 2, 3, 2, 6, 8, 10, 11, and 15 (for the convenience of examples, only a few values ​​are listed here, which does not limit the number of eigenvalues). According to the above method, the minimum value of the eigenvalue is determined to be 2, the preset segmentation parameter is 2, and 2 is used as the difference between the upper and lower limits of each eigenvalue range, generating 7 eigenvalue ranges: [2,4), [4,6), [6,8), [8,10), [10,12), [12,14), and [14,16). The number of eigenvalues ​​in these 7 ranges is counted, which are 4, 1, 1, 1, 2, 0, and 1, respectively. In this way, the eigenvalue distribution of the feature is obtained.

[0056] It should be noted that in the above method, if the number of eigenvalues ​​within each eigenvalue range is converted into the probability of the eigenvalue falling within each eigenvalue range, the probability density function can also be transmitted in the above method. Taking the above example, the probabilities of each value range are: 0.4, 0.1, 0.1, 0.1, 0.2, 0, 0.1. In this way, the corresponding discontinuous probability density function can be generated, and the probability density function can be used to characterize the eigenvalue distribution of the feature.

[0057] In the case of characterization by a probability mass function, the method for generating the eigenvalue distribution of each feature can be: according to the principle of rounding, each eigenvalue is converted into an approximate eigenvalue of the feature, where the approximate eigenvalue can be an integer, or a multiple of 10, a multiple of 100, etc., which can be determined based on the number, distribution and amount of transmittable data of the eigenvalues; according to the converted approximate eigenvalue, the eigenvalue distribution of the feature is statistically analyzed. The above method is only an example and does not constitute a limitation on the method of generating a probability mass function in this specification.

[0058] For example, if there is an eigenvalue between 0 and 1000, in order to save the amount of transmitted data, each eigenvalue is converted into an approximate eigenvalue (multiple of 100), and the number of approximate eigenvalues ​​of 0, 100, 200, 300, 400, 500, 600, 700, 800, 900 and 1000 is counted to generate the probability mass function of the feature. Of course, the probability mass function can also be converted into the number of approximate eigenvalues ​​of each of the above 11 numbers.

[0059] In the case of characterization by a probability density function, the method for generating the eigenvalue distribution of each feature can be as described above, that is, obtaining the eigenvalue distribution by counting the number of eigenvalues ​​within each eigenvalue value range, or it can be obtained by the following method: for each feature in the training sample set of the data provider, sorting the eigenvalues ​​of the feature in the training sample set in ascending order, and fitting to generate the probability density function of the feature; dividing the probability density function of the feature according to a preset segmentation parameter to obtain the eigenvalue distribution of the feature; wherein the eigenvalue distribution includes the probability of the eigenvalue falling into each eigenvalue value range, and the difference between the upper limit and the lower limit of each eigenvalue value range is the preset segmentation parameter; according to the eigenvalue distribution of each feature, generate the eigenvalue distribution set of the data provider.

[0060] In other words, the above process is actually to fit and generate a continuous probability density function based on the eigenvalue distribution, and then divide the continuous probability density function to obtain an approximate histogram (the vertical axis of the histogram is the frequency divided by the group interval, and the horizontal axis is the value of the eigenvalue, which is actually also a probability density function), and the data represented by the obtained histogram is used as the eigenvalue distribution of the feature.

[0061] The preset segmentation parameter is a hyperparameter, and its size can be determined according to the amount of data that can be transmitted and the accuracy of the simulated data. In addition, after segmentation, the sum of the probabilities must still be guaranteed to be 1.

[0062] In the case of characterization by a probability density function, the method for generating the eigenvalue distribution of each feature can also be: for each feature in the training sample set of the data provider, the eigenvalues ​​of the feature in the training sample set are sorted in ascending order, the probability density function of the feature is fitted and generated, and the probability density function is divided into multiple segments, and each segment is represented by a well-known distribution similar to the segment.

[0063] In addition, considering that in some cases, for each data provider, the users corresponding to its training samples actually include multiple user groups, and the feature value distribution of the same feature between different user groups is quite different, in order to reflect the above differences and train to obtain a more accurate model, for any data provider, the feature value distribution set may include feature value distribution subsets of multiple batches of training samples (each batch of training samples corresponds to a user group, and different batches of training samples correspond to different user groups). Specifically, for any data provider, the method for generating a feature value distribution set includes: for each batch of training samples in the training sample set of the data provider, according to the feature value of each feature in the batch of training samples, generating a feature value distribution subset of the batch of training samples; wherein the users corresponding to different batches of training samples belong to different communities; according to the feature value distribution subset of each batch of training samples, generating the feature value distribution set of the data provider.

[0064] Step 103: Generate new training samples according to the received feature value distribution set and the preset feature structure.

[0065] Since this method can be applied to horizontal federated learning and vertical federated learning, step 103 will be explained from the perspectives of horizontal federated learning and vertical federated learning respectively.

[0066] In the case where the method is applied to vertical federated learning, step 103 includes: determining the number of training samples in the training sample set; for each received feature value distribution, taking the determined number of training samples as the total amount, and generating a value set of the feature according to the feature value distribution; for each value set, determining the position of the feature corresponding to the value set in the new training sample according to a preset feature structure, taking each value in the value set as the value of the position of a training sample, and generating a new training sample set; wherein the values ​​in the value set correspond one-to-one to the training samples in the training sample set.

[0067] Specifically, in the case of vertical federated learning, in order to generate data more easily, it is assumed that the users of multiple data providers with a collaborative relationship are consistent, the features of any two data providers are inconsistent, or the features in the feature value distribution set sent by other collaborative data providers received by any data provider are different from the features of the data provider. In this case, in the feature structure of the preset new training sample, some bits in the feature vector are the features of the original training sample, and the other bits are newly added features. When generating new training samples, each original training sample is first converted into a new training sample with a vacancy, and then a value is taken out from each value set without replacement and filled in the corresponding position (the position of the feature corresponding to the value set in the preset feature structure). In this way, a new training sample is generated, and when training the model, the generated new training sample can be used for training.

[0068] In addition, for vertical federated training, if it is supervised training, the label of each new training sample is the label of the original training sample contained in the new training sample.

[0069] If the training sample is a graph, for the graph, each node can be used as a training sample, and each edge can be used as another training sample. The feature structure is preset for the two training samples, and new training samples are generated respectively. Under this condition, the connection structure of the edge of the original graph is not changed, only the feature vector of each edge and each node is changed.

[0070] When the method is applied to horizontal federated learning, step 103 includes: determining the number of training samples that need to be supplemented; for each feature value distribution of each collaborative data provider, taking the determined number of training samples as the total amount, and generating a value set corresponding to the feature value distribution according to the feature value distribution; for each collaborative data provider, determining the position of the features corresponding to each feature set in the new training sample according to a preset feature structure; and adding a value of each value set to each new training sample according to the determined position of each feature, to generate a new training sample.

[0071] Specifically, in the case of horizontal federated learning, in order to generate data more easily, it is assumed that the users of any two data providers with a collaborative relationship are different, and the features of any two data providers are the same. In this case, the feature structure of the preset new training sample is the feature structure of the training sample set of the data provider. When generating new training samples, for each new training sample, from each value set of a collaborative data provider, take out a value from each value set without replacement, and fill it into the corresponding position in the new training sample (the position of the feature corresponding to the value in the feature structure) until there is no data in the value sets corresponding to all collaborative data providers. In this way, the newly generated training samples and the original training sample set together constitute the training samples used for model training.

[0072] In addition, for horizontal federated learning, if it is supervised training, the label value distribution can also be transmitted in the above way. The label value distribution is used to characterize the value distribution of the label value of the collaborative data provider. When generating a new training sample, the label value of the new training sample can also be generated according to the label value distribution.

[0073] In addition, if the specific method of generating a numerical set is to generate a numerical set based on the number of eigenvalues ​​within each eigenvalue value range, or the probability that an eigenvalue falls within each eigenvalue value range, or a discontinuous probability density function, or a probability mass function, since the collaborative data provider only sends the probability or number of the eigenvalue falling within the eigenvalue value range or certain eigenvalues, in order to make the numerical set diverse, it is necessary to randomly generate a number of eigenvalues ​​within each eigenvalue value range, or randomly generate a number of eigenvalues ​​between certain eigenvalues, or uniformly generate a number of eigenvalues ​​within the eigenvalue value range.

[0074] For example, there is an eigenvalue range of 100-200. If the number of values ​​to be generated within this eigenvalue range is 100, 100 random numbers need to be generated within the range of 100-200. For example, in the case of a transmission probability mass function, the three consecutive eigenvalues ​​in the probability mass function are 100, 200 and 300. For 200, if the number of values ​​to be generated is 100, 100 random numbers can be generated between 150-250.

[0075] In addition to generating random numbers, you can also generate a number of values ​​uniformly, in other words, the difference between every two consecutive eigenvalues ​​is the same. For example, if you need to generate 100 eigenvalues ​​in the range of 100-200, you can generate 100 numbers uniformly between 100-200, and the generated values ​​can be 100, 101, 102...199.

[0076] It can be seen that the above method does not consider the association between different features. For a collaborative data provider, suppose one of its feature vectors is (10, 20, 30), but when it is transmitted, 10, 20 and 30 are transmitted separately. When generating new training samples, 10, 20 and 30 are not necessarily placed in the same new training sample. Therefore, the method provided in this specification is more suitable for scenarios where the correlation between features is not strong. For scenarios where the correlation between features is not strong, ignoring the correlation between features can make the trained model more stable, and the training effect is better than that of training only using its own training sample set.

[0077] In addition, after obtaining the training samples through the above-mentioned training sample generation method, the data provider can use the obtained training samples to train the model independently (without performing federated learning, but only performing independent training through its own training samples).

[0078] The data provider can also perform model training through the obtained training samples and other collaborative data providers through the federated learning method. In this case, in order to enable other collaborative data providers to obtain new training samples, the data provider is also required to send the data provider's feature value distribution set to the collaborative data provider. In other words, the method also includes: for each feature of the data provider's training sample set, generating the feature value distribution of the feature; generating the data provider's feature value distribution set based on the generated feature value distribution of each feature; and sending the generated feature value distribution set to the collaborative data provider, so that the collaborative data provider generates new training samples based on the received feature value distribution set.

[0079] Through the above method, each data provider can obtain more training samples or more features. For each data provider, the data that can be used for model training is more diverse, making the trained model more accurate. In addition, since the transmitted data is a set of feature value distributions, the amount of data transmitted is small, making the training efficiency no less than that of using only the original training sample set.

[0080] Next, the training sample generation method provided in this specification will be described through a specific embodiment.

[0081] Assume that there are two data providers, data provider A and data provider B, and there is a collaborative relationship between the two data providers. The two data providers are two subsidiaries of the same group, and the users corresponding to the data are basically the same. However, due to the difference in the business of A and B, the characteristics of the training samples of A and B are different (in other words, if the two parties want to conduct federated learning, the method used is vertical federated learning). Now data provider A wants to obtain enough training samples for training, and then obtain a model for judging whether there is a fraud risk in each transaction based on these training samples. Among them, there are two user groups in the data of data provider A and data provider B, namely user group 1 and user group 2. In data provider B, user group 1 and user group 2 correspond to 2 batches of training samples, namely batch 1 and batch 2, and the characteristic value distribution of at least one feature of batch 1 and batch 2 is different.

[0082] like Figure 2A As shown, data provider A needs to perform the following steps to obtain training samples sufficient for training:

[0083] Step 201: Receive a feature value distribution set sent by collaborative data provider B.

[0084] The eigenvalue distribution set includes two eigenvalue distribution subsets, namely, eigenvalue distribution subset 1 and eigenvalue distribution subset 2. The eigenvalue distribution subset 1 corresponds to the training sample batch 1, and the eigenvalue distribution subset 2 corresponds to the training sample batch 2. Each eigenvalue distribution subset includes the eigenvalue distribution of each feature of the batch of training samples.

[0085] The process of collaborative data provider B obtaining each feature value distribution subset may be as follows: for each feature in the batch of training samples, the feature value is sorted in ascending order, the probability density function of the feature is fitted, and the probability density function of the feature is segmented according to the preset segmentation parameter to obtain the feature value distribution of the feature in the batch of training samples, wherein the feature value distribution includes the probability that the feature value falls within each feature value range, and the difference between the upper and lower limits of each feature value range is the preset segmentation parameter. The histogram diagram of the feature value distribution of a feature of a batch of training samples is finally obtained as follows: Figure 2B As shown, the horizontal axis X represents the value of the eigenvalue, and the vertical axis Y represents the frequency divided by the group distance.

[0086] Step 203: Generate new training samples according to the received eigenvalue distribution set.

[0087] Data provider A needs to generate two batches of new training samples. One batch of training samples is used as an example to describe in detail the process of data provider A generating new training samples. The user group corresponding to training sample batch 1 of collaborative data provider B is user group 1. In data provider A, the training samples corresponding to user group 1 are training sample batch 1'. The generation process of new training samples corresponding to training sample batch 1' will be described in detail below.

[0088] In order to generate new training samples corresponding to batch 1', we first need to determine the number of training samples in batch 1', assuming that this number is 10,000. After determining the number of 10,000, for each eigenvalue distribution in the eigenvalue distribution subset 1 provided by the collaborative data provider B, generate a numerical set corresponding to each eigenvalue distribution, and each generated numerical set conforms to the eigenvalue distribution corresponding to the data set.

[0089] A specific method for generating a numerical set may be: for each eigenvalue range of the feature corresponding to the numerical set, according to the frequency with which the eigenvalue falls within the eigenvalue range (the frequency is the area enclosed by the probability density function within the eigenvalue range and the X-axis in the probability density function), determine the number of numerical values ​​that need to be generated within the eigenvalue range, and generate that number of random numbers within the eigenvalue range.

[0090] For example, assuming that a certain eigenvalue ranges from 100 to 200, and in the probability density function, the Y axis of this function is 0.005, then the frequency of the eigenvalue falling within the eigenvalue range is 0.05, and the total number of new training samples to be generated is 10,000. 10,000 multiplied by 0.05, the number of values ​​to be generated is 500, and then 500 random numbers are generated between 100 and 200 according to the preset random number algorithm. According to the above method, the value set corresponding to each feature in the eigenvalue distribution subset can be obtained.

[0091] After obtaining several value sets, new training samples are combined according to these data sets. Specifically, it is assumed that batch 1' originally has two features, namely C and D, and the feature value distribution subset 1 includes two feature value distributions. The two feature value distributions correspond to two features of the collaborative data provider training sample batch 1, namely E and F, and the preset feature structure is (C, D, E, F). In this case, to generate a new training sample, first, a training sample must be taken out from batch 1' without replacement, and the values ​​of the features C and D in the training sample are filled into the positions of a new training sample C and D, and then a value is taken out from the two generated value sets without replacement, and the corresponding positions of E and F are filled, so that a new training sample is obtained. Then the above method is executed repeatedly to obtain new training samples until the value set does not contain any value (since the number of values ​​in the value set is 10,000, and the number of training samples in batch 1' is also not 10,000, in the above process, each time a training sample is taken out from 1', a value is also taken out from each value set at the same time, so the value set does not contain any value, which is equivalent to batch 1' not containing any value).

[0092] In this way, new training samples are obtained, and the new training samples are used as training samples for model training for training.

[0093] As described above, the samples generated by the training sample generation method of this specification can be used for federated learning. This specification also provides a federated learning method, which is applied to any data provider including a federated training system, wherein the federated training system includes at least two data providers with a data collaboration relationship, and any data provider obtains a new training sample through the above-mentioned training sample method, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set. Among them, for horizontal federated learning, the new training sample set is composed of the original training sample set and the generated new training samples; for vertical federated learning, the new training sample set is composed only of the generated new training samples.

[0094] like Figure 3 As shown, Figure 3 This is a federated learning method according to an exemplary embodiment of the present specification, which iteratively performs the following steps until the output loss of each data provider is less than a preset loss threshold, or the number of iterations is greater than a preset number threshold:

[0095] Step 301, input the obtained new training sample set into the model to obtain the output loss.

[0096] Step 303, calculate the gradient of the model according to the output loss.

[0097] Step 305: Send the calculated gradient to the collaborative data provider, and accept the gradient sent by the collaborative data provider.

[0098] Step 307, obtaining an average value of the received gradient and the calculated gradient, and updating the weight of the model according to the obtained average value.

[0099] Among them, the above-mentioned preset loss threshold and preset number threshold can be determined according to actual training needs. For example, if the accuracy of the trained model is required to be high, the preset loss threshold can be set smaller, and the number threshold can be set larger; if the training efficiency is required to be high, the preset loss threshold can be set larger, and the number threshold can be set smaller.

[0100] In the above steps, the calculated gradient is chosen to be sent to the collaborative data provider. Of course, in step 305, the calculated gradient is not sent to the collaborative data provider, and the gradient sent by the collaborative data provider is not received. For each weight, after the weight is updated through the gradient, each updated weight is chosen to be sent to the collaborative data provider, and the weight sent by the collaborative data provider is received. Then, based on the received weights and the updated weights, the average of these weights is calculated, and the average is used as the weight output for this iteration.

[0101] In the above process, federated learning can be completed by sending gradients or weights. If the output loss is sent and the average output loss is calculated to update the weight, it will affect the calculation of the gradient during the back propagation process. Therefore, the weight cannot be updated by sending and receiving the output loss and calculating the average of each output loss.

[0102] In addition, in each iteration, multiple batches of training samples are sequentially input. Since different batches of training samples correspond to different user groups, different batches of training samples correspond to different gradients. In order to reduce the number of communications, in step 305, the gradients of multiple batches of training samples can be accumulated and calculated, and then these gradients can be uniformly transmitted to the collaborative data provider.

[0103] Through the above method, federated learning based on the above training sample generation method is realized.

[0104] In addition, this specification also provides a federated learning system, including at least two data providers with a data collaboration relationship, wherein any data provider obtains a new training sample through the above-mentioned training sample acquisition method, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set.

[0105] Any data provider iteratively performs the following steps until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold:

[0106] Input the new training sample set into the model to obtain the output loss; calculate the gradient of the model based on the output loss; send the calculated gradient to the collaborative data provider, and accept the gradient sent by the collaborative data provider; obtain the average of the received gradient and the calculated gradient, and update the model weight based on the obtained average.

[0107] The specific implementation methods and implementation processes of each step in the above system are detailed in the implementation process of the corresponding steps in the above-mentioned federated learning method and training sample generation method, and will not be repeated here.

[0108] Corresponding to the embodiments of the aforementioned methods, this specification also provides embodiments of a training sample generating device, a federated learning device, and electronic devices used therein.

[0109] like Figure 4 As shown, Figure 4 This is a block diagram of a training sample generating device according to an exemplary embodiment of the present specification, the device is applied to any data provider of at least two data providers in a collaborative relationship, and pre-sets the feature structure of a new training sample of the data provider; the device includes:

[0110] The feature value distribution set receiving module 410 is used to receive the feature value distribution set sent by the collaborative data provider; the feature value distribution set is used to characterize the feature value distribution of each feature in the training sample set of the collaborative data provider;

[0111] The training sample generation module 420 is used to generate new training samples according to the received feature value distribution set and the preset feature structure.

[0112] Among them, for any data provider, the method for generating a feature value distribution set includes: for each feature in the training sample set of the data provider, sorting the feature values ​​of the feature in the training sample set in ascending order, and fitting to generate a probability density function of the feature; according to a preset segmentation parameter, segmenting the probability density function of the feature to obtain the feature value distribution of the feature; wherein the feature value distribution includes the probability of the feature value falling into each feature value range, and the difference between the upper limit and the lower limit of each feature value range is the preset segmentation parameter; according to the feature value distribution of each feature, generating the feature value distribution set of the data provider.

[0113] Among them, for any data provider, the method for generating a feature value distribution set includes: for each batch of training samples in the training sample set of the data provider, generating a feature value distribution subset of the batch of training samples according to the feature value of each feature in the batch of training samples; wherein the users corresponding to different batches of training samples belong to different communities; and generating the feature value distribution set of the data provider according to the feature value distribution subset of each batch of training samples.

[0114] Among them, when applied to vertical federated learning, the training sample generation module 420 is specifically used to: determine the number of training samples in the training sample set; for each received feature value distribution, use the determined number of training samples as the total amount, and generate a value set of the feature according to the feature value distribution; for each value set, determine the position of the feature corresponding to the value set in the new training sample according to the preset feature structure, use each value in the value set as the value of the position of a training sample, and generate a new training sample set; wherein the values ​​in the value set correspond one-to-one to the training samples in the training sample set.

[0115] Among them, when applied to horizontal federated learning, the training sample generation module 420 is specifically used to: determine the number of training samples that need to be supplemented; for each eigenvalue distribution of each collaborative data provider, use the determined number of training samples as the total amount, and generate a value set corresponding to the eigenvalue distribution according to the eigenvalue distribution; for each collaborative data provider, determine the position of the features corresponding to each feature set in the new training sample according to a preset feature structure; according to the determined position of each feature, add a value of each value set to each new training sample to generate a new training sample.

[0116] In addition, the device also includes: a feature value distribution set sending module 430, which is used to: generate a feature value distribution of each feature of the data provider's training sample set; generate a feature value distribution set of the data provider based on the generated feature value distribution of each feature; and send the generated feature value distribution set to the collaborative data provider so that the collaborative data provider generates a new training sample based on the received feature value distribution set.

[0117] like Figure 5 As shown, Figure 5 This is a block diagram of a federated learning device according to an exemplary embodiment of the present specification, which is applied to any data provider including a federated training system, wherein the federated training system includes at least two data providers having a data collaboration relationship, and any data provider obtains a new training sample through the above training sample generation method, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set; the device includes:

[0118] The following steps are iteratively performed until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold:

[0119] The output loss obtaining module 510 is used to input the obtained new training sample set into the model to obtain the output loss.

[0120] The gradient calculation module 520 is used to calculate the gradient of the model according to the output loss.

[0121] The gradient transceiver module 530 is used to send the calculated gradient to the collaborative data provider and receive the gradient sent by the collaborative data provider.

[0122] The weight updating module 540 is used to obtain the average value of the received gradient and the calculated gradient, and update the weight of the model according to the obtained average value.

[0123] 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.

[0124] 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.

[0125] like Figure 6 As shown, Figure 6 A hardware structure diagram of an electronic device in which a training sample generating device or a federated learning device of an embodiment is located is shown. The device may include only the above-mentioned training sample generating device, or only the above-mentioned federated learning device, or may include both the above-mentioned training sample generating device and the federated learning device. 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.

[0126] 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.

[0127] 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.

[0128] 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.

[0129] 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.).

[0130] 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).

[0131] 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.

[0132] The embodiments of this specification also provide a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the training sample generation method or the federated learning method described above is implemented. In other words, the computer-readable storage medium may only include a computer program for executing the training sample generation method described above, or may only include a training program for the federated learning method described above.

[0133] 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.

[0134] 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.

[0135] 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 training sample generation method, applied to any data provider among at least two data providers in a collaborative relationship, presetting a feature structure of a new training sample of the data provider; the method comprises: Receive a feature value distribution set sent by a collaborative data provider; The feature value distribution set is used to characterize the feature value distribution of each feature in the training sample set of the collaborative data provider; Generate new training samples according to the received feature value distribution set and the preset feature structure; The step of generating new training samples according to the received feature value distribution set and the preset feature structure includes: When the method is applied to vertical federated learning, the number of training samples in the training sample set is determined; for each received feature value distribution, the determined number of training samples is used as the total amount, and a value set of the feature is generated according to the feature value distribution; for each value set, the position of the feature corresponding to the value set in the new training sample is determined according to a preset feature structure, and each value in the value set is used as the value of the position of a training sample to generate a new training sample set; wherein the values ​​in the value set correspond to the training samples in the training sample set one by one; When the method is applied to horizontal federated learning, the number of training samples that need to be supplemented is determined; for each eigenvalue distribution of each collaborative data provider, the determined number of training samples is used as the total amount, and a value set corresponding to the eigenvalue distribution is generated according to the eigenvalue distribution; for each collaborative data provider, the position of the features corresponding to each feature set in the new training sample is determined according to a preset feature structure; according to the determined position of each feature, a value of each value set is added to each new training sample to generate a new training sample.

2. According to the method of claim 1, for any data provider, the method for generating a eigenvalue distribution set comprises: For each feature in the training sample set of the data provider, the feature values ​​of the feature in the training sample set are sorted in ascending order, and a probability density function of the feature is generated by fitting; According to a preset segmentation parameter, the probability density function of the feature is segmented to obtain the eigenvalue distribution of the feature; wherein the eigenvalue distribution includes the probability that the eigenvalue falls within each eigenvalue value range, and the difference between the upper limit and the lower limit of each eigenvalue value range is the preset segmentation parameter; According to the feature value distribution of each feature, a feature value distribution set of the data provider is generated.

3. According to the method of claim 1, for any data provider, the method for generating a eigenvalue distribution set comprises: For each batch of training samples in the training sample set of the data provider, a feature value distribution subset of the batch of training samples is generated according to the feature value of each feature in the batch of training samples; wherein the users corresponding to different batches of training samples belong to different communities; The feature value distribution set of the data provider is generated according to the feature value distribution subset of each batch of training samples.

4. The method according to claim 1, further comprising: For each feature of the training sample set of the data provider, generate a feature value distribution of the feature; Generate a feature value distribution set of the data provider according to the generated feature value distribution of each feature; The generated feature value distribution set is sent to the collaborative data provider, so that the collaborative data provider generates new training samples according to the received feature value distribution set.

5. A federated learning method, applied to any data provider including a federated training system, wherein the federated training system includes at least two data providers having a data collaboration relationship, wherein any data provider obtains a new training sample through the method described in any one of claims 1 to 4, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set; the method comprises: The following steps are iteratively performed until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold: Input the new training sample set into the model to obtain the output loss; Calculate the gradient of the model based on the output loss; Send the calculated gradient to the collaborative data provider and receive the gradient sent by the collaborative data provider; Get the average of the received gradient and the calculated gradient, and update the model weights based on the obtained average.

6. A training sample generating device, applied to any one of at least two data providers in a collaborative relationship, presetting a feature structure of a new training sample of the data provider; the device comprises: A feature value distribution set receiving module, used to receive a feature value distribution set sent by a collaborative data provider; The feature value distribution set is used to characterize the feature value distribution of each feature in the training sample set of the collaborative data provider; A training sample generation module is used to generate new training samples according to the received feature value distribution set and the preset feature structure; The training sample generation module is used to: When the device is applied to vertical federated learning, the number of training samples in the training sample set is determined; for each received feature value distribution, the determined number of training samples is used as the total amount, and a value set of the feature is generated according to the feature value distribution; for each value set, the position of the feature corresponding to the value set in the new training sample is determined according to a preset feature structure, and each value in the value set is used as the value of the position of a training sample to generate a new training sample set; wherein the values ​​in the value set correspond to the training samples in the training sample set one by one; When the device is applied to horizontal federated learning, the number of training samples that need to be supplemented is determined; for each eigenvalue distribution of each collaborative data provider, the determined number of training samples is used as the total amount, and a value set corresponding to the eigenvalue distribution is generated according to the eigenvalue distribution; for each collaborative data provider, the position of the features corresponding to each feature set in the new training sample is determined according to a preset feature structure; according to the determined position of each feature, a value of each value set is added to each new training sample to generate a new training sample.

7. A federated learning device, applied to any data provider including a federated training system, wherein the federated training system includes at least two data providers having a data collaboration relationship, wherein any data provider obtains a new training sample by the method described in any one of claims 1 to 4, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set; the device comprises: The following is iterated until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold: The output loss acquisition module is used to input the obtained new training sample set into the model to obtain the output loss; The gradient calculation module is used to calculate the gradient of the model based on the output loss; A gradient transceiver module is used to send the calculated gradient to the collaborative data provider and receive the gradient sent by the collaborative data provider; The weight update module is used to obtain the average value of the received gradient and the calculated gradient, and update the weight of the model according to the obtained average value.

8. A federated learning system, comprising at least two data providers having a data collaboration relationship, wherein any data provider obtains a new training sample by the method described in any one of claims 1 to 4, and obtains a new training sample set of the data provider based on the obtained new training sample and the existing training sample set; Any data provider iteratively performs the following steps until the output loss of each data provider is less than the preset loss threshold, or the number of iterations is greater than the preset number threshold: Input the new training sample set into the model to obtain the output loss; Calculate the gradient of the model based on the output loss; Send the calculated gradient to the collaborative data provider and receive the gradient sent by the collaborative data provider; Get the average of the received gradient and the calculated gradient, and update the model weights based on the obtained average.

9. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 5 by running the executable instructions.

10. A computer-readable storage medium storing computer instructions, wherein the computer instructions are executed by a processor to implement the method according to any one of claims 1 to 5.