Compiling method, device, apparatus and storage medium
By generating target code containing sub-target codes of multiple different types of client terminals, the client terminals execute the corresponding sub-target codes according to their own identifiers and calculate feature correlation coefficients, thus solving the problem of high code complexity in vertical federated learning and achieving the effect of easy management and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEBANK (CHINA)
- Filing Date
- 2020-11-13
- Publication Date
- 2026-05-12
AI Technical Summary
In vertical federated learning, the strong correlation between different features of the same user leads to poor model performance. Furthermore, existing technologies require the development of separate code for data users and data providers, resulting in complex code that is difficult to manage and maintain.
A compilation method and apparatus are provided to generate target code containing sub-target codes of multiple different types of client terminals. The client terminals execute the corresponding sub-target codes according to their own identifiers, and feature correlation coefficients are calculated to reduce code complexity.
By using a unified target code to calculate feature correlation coefficients, the development complexity of feature correlation code in vertical federated learning is reduced, making code management and maintenance easier.
Smart Images

Figure CN114489654B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of code compilation technology, and in particular to a compilation method, apparatus, device, and storage medium. Background Technology
[0002] As a novel machine learning framework, Federated Learning ensures information security during data exchange, protects terminal and personal data privacy, and guarantees legality and compliance while enabling efficient machine learning among multiple participants or computing nodes. Specifically, in vertical federated learning, the data application party initiates model training, collaborating with the data provider. Both the data application and data provider share the same users, but their user characteristics differ. The dataset is split vertically (i.e., along the feature dimension), and the portion with the same users but different user characteristics is aggregated in an encrypted state to enhance model capabilities.
[0003] However, if there is a strong correlation between different features of the same user used for model training, training the model with these different features will result in poor model performance. Therefore, in vertical federated learning, it is necessary to calculate the feature correlation between two features of the same user on both the data application side and the data provider side, and filter out features with strong correlation.
[0004] Currently, in the development of the vertical federated feature correlation algorithm, since the two features come from the data user and the data provider, different code needs to be developed for the data user and the data provider respectively, which makes the code complex and difficult to develop and maintain. Summary of the Invention
[0005] The main objective of this invention is to provide a compilation method, apparatus, device, and storage medium, which aims to reduce the code complexity of different client terminals in the feature relevance calculation of vertical federated learning.
[0006] To achieve the above objectives, the present invention provides a compilation method, comprising:
[0007] The client terminal obtains the compiled target code, which includes sub-target codes of multiple different types of client terminals. Each type of client terminal sub-target code is used to participate in obtaining the feature correlation coefficients of model training data between different types of client terminals in longitudinal federated learning.
[0008] The client terminal determines the sub-target code belonging to the client terminal from the target code;
[0009] The client terminal executes the sub-target code belonging to the client terminal to obtain the feature correlation coefficient of the model training feature data between the client terminal and other client terminals. The feature correlation coefficient is used for longitudinal federated learning.
[0010] Optionally, the plurality of different types of client terminals include: data users for vertical federated learning, and data providers for vertical federated learning.
[0011] Optionally, the client terminal determines sub-target code belonging to the client terminal from the target code, including:
[0012] The client terminal determines whether it is a data user or a data provider for vertical federated learning;
[0013] If the client terminal is a data application party for vertical federated learning, then the client terminal determines the sub-target code belonging to the data application party from the target code;
[0014] If the client terminal is a data provider for longitudinal federated learning, then the client terminal determines the sub-target code belonging to the data provider from the target code.
[0015] Optionally, the target code includes an identifier for the data user and an identifier for the data provider used in vertical federated learning.
[0016] The determination of whether the client terminal is a data user or a data provider for vertical federated learning includes:
[0017] The client terminal determines whether its identifier is an identifier of a data application party for vertical federated learning or an identifier of a data provider for vertical federated learning;
[0018] If the identifier of the client terminal is the identifier of the data application party used for vertical federated learning in the target code, then the client terminal is determined to be the data application party used for vertical federated learning.
[0019] If the identifier of the client terminal is the identifier of the data provider used for vertical federated learning in the target code, then the client terminal is determined to be the data provider used for vertical federated learning.
[0020] Optionally, the client terminal executes the sub-target code belonging to the client terminal, including:
[0021] If the client terminal is a data application party for vertical federated learning, then the client terminal obtains locally encrypted model training feature data according to the sub-target code, sends the encrypted model training feature data to the data provider for vertical federated learning, and receives feature correlation coefficients obtained from the data provider based on the encrypted model training feature data.
[0022] Optionally, the client terminal executes the sub-target code belonging to the client terminal, including:
[0023] If the client terminal is a data provider for vertical federated learning, then the client terminal receives encrypted model training feature data from the data provider for vertical federated learning according to the sub-target code, obtains feature correlation coefficients based on the encrypted model training feature data and local model training feature data, and sends them to the data application party for federated learning.
[0024] Optionally, the client terminal acquires the target compiled file, including:
[0025] The client terminal obtains source code based on the Python programming language, and the source code includes multiple sub-source codes of different types of client terminals, each used to participate in obtaining feature correlation coefficients;
[0026] The client terminal compiles the source code into the target code.
[0027] The present invention also provides a compilation apparatus, comprising:
[0028] The acquisition module is used for the client terminal to acquire the compiled target code. The target code includes sub-target codes of multiple different types of client terminals. The sub-target codes of each type of client terminal are used to participate in the acquisition of feature correlation coefficients of model training data between different types of client terminals in vertical federated learning.
[0029] The execution module is used for the client terminal to determine the sub-target code belonging to the client terminal from the target code; and is also used for the client terminal to execute the sub-target code belonging to the client terminal to obtain the feature correlation coefficient of the model training feature data between the client terminal and other client terminals, the feature correlation coefficient being used for longitudinal federated learning.
[0030] The present invention also provides a compilation device, the compilation device comprising: a memory, a processor, and a model training program stored in the memory and executable on the processor, wherein the model training program, when executed by the processor, implements the steps of the compilation method as described in any of the preceding claims.
[0031] The present invention also provides a computer-readable storage medium storing a model training program, which, when executed by a processor, implements the steps of the compilation method as described in any of the preceding claims.
[0032] In this invention, the compiled target code includes sub-target codes for multiple different types of client terminals. This allows different client terminals to run the compiled target code, determine their own sub-target codes from it, and execute their specific sub-target codes to obtain feature correlation coefficients between the client terminal and other client terminals' model training feature data. This is then used for training the model in vertical federated learning. It eliminates the need to develop corresponding code for each type of client terminal, reducing the development complexity of feature correlation code in vertical federated learning and facilitating code management and maintenance. Attached Figure Description
[0033] Figure 1a This is a schematic diagram illustrating an application scenario of vertical federated learning provided in an embodiment of the present invention;
[0034] Figure 1b A schematic diagram of the model training process for vertical federated learning provided in an embodiment of the present invention;
[0035] Figure 2 A flowchart illustrating a compilation method provided in an embodiment of the present invention;
[0036] Figure 3 A flowchart illustrating a compilation method provided in another embodiment of the present invention.
[0037] Figure 4 A computational graph for a data application provided in an embodiment of the present invention;
[0038] Figure 5 A computational graph for data application provided in another embodiment of the present invention;
[0039] Figure 6 A calculation diagram of the data provider provided in an embodiment of the present invention;
[0040] Figure 7 This is a schematic diagram of the structure of a compiler device provided in an embodiment of the present invention;
[0041] Figure 8 This is a schematic diagram of the structure of a compilation device provided in an embodiment of the present invention.
[0042] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0043] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0044] In federated learning, each enterprise participating in the joint modeling is called a participant. Based on the different data distributions among multiple participants, federated learning is divided into three categories: horizontal federated learning, vertical federated learning, and federated transfer learning.
[0045] Vertical federated learning, in essence, is the jointing of features and is suitable for scenarios with high user overlap but low feature overlap. During training, the training dataset is split vertically (i.e., along the feature dimension), and the portion of data where users from both sides share the same features but not identical features is used for training.
[0046] For example, consider two different institutions in the same region: one a bank, the other an e-commerce platform. Both institutions primarily serve local residents, resulting in significant overlap in their user base. However, their businesses differ (their characteristics differ). The bank records users' income and expenditure behavior and credit ratings, while the e-commerce platform retains users' browsing and purchase history. Therefore, their user characteristics overlap less.
[0047] Figure 1a This is a schematic diagram illustrating an application scenario of vertical federated learning according to an embodiment of the present invention. For example... Figure 1a As shown, the example of e-commerce companies and banks jointly training a vertical federated learning model is used for illustration.
[0048] exist Figure 1a In the scenario depicted, the e-commerce platform and the bank's business systems each possess their own user data. Additionally, the bank has the tag data that the model needs to predict. Due to data privacy and security concerns, the e-commerce platform and the bank cannot directly exchange data. Therefore, a longitudinal federated learning system is used to build the model.
[0049] like Figure 1a As shown, building a longitudinal federated learning model requires two steps:
[0050] Step 1: Align the encrypted samples.
[0051] Specifically, e-commerce platforms and banks align the model training feature data (i.e., samples) used to train the longitudinal federated learning model within their respective systems. For example, the data format is converted to the target format, so that non-cross-users are not exposed at the enterprise-aware level.
[0052] Step 2: Align the samples and perform encrypted model training.
[0053] like Figure 1b As shown, in order to ensure the confidentiality of data during training, encrypted training is required with the help of a third-party collaborator, C.
[0054] S101: A third party, C, sends a public key to e-commerce platforms and banks to encrypt the model training feature data that needs to be transmitted.
[0055] S102: E-commerce companies and banks respectively calculate the intermediate results of features related to themselves and exchange them in encrypted form to obtain their respective gradients and losses;
[0056] When training a longitudinal federated learning model using model training feature data from e-commerce platforms and banks, there will be certain feature correlations between some of these data. For example, when a user makes a purchase on an e-commerce platform, their bank card will incur expenditures; therefore, there is a correlation between the user's transaction history recorded by the bank and the user's purchase history held by the e-commerce platform.
[0057] Therefore, if, in training a vertical federated learning model, banks use their own recorded user spending and income behavior as model training feature data, and e-commerce platforms use their own user purchase history as model training feature data, the jointly trained vertical federated learning model will perform poorly, and may even fail to converge. Furthermore, using two highly correlated model training feature data sets increases the compilation load during model training, impacting training efficiency. Therefore, when jointly training a vertical federated learning model, for the user spending and income behavior recorded by the bank and the user purchase history held by the e-commerce platform, it is advisable to use either the bank's recorded user spending and income behavior or the e-commerce platform's user purchase history as model training feature data.
[0058] Therefore, when training a longitudinal federated learning model, before S102, it is necessary to calculate the feature correlation coefficient between the e-commerce model training feature data and the bank model training feature data, and then filter out one of the two model training feature data with strong correlation based on the feature correlation coefficient.
[0059] Thus, in S102, the model training feature data used by e-commerce companies to calculate their intermediate feature results does not contain model training feature data that is strongly correlated with the model training feature data used by banks to calculate their intermediate feature results.
[0060] S103: The e-commerce platform and the bank each calculate their own encrypted gradients and add masks before sending them to C. At the same time, the bank calculates its encrypted loss and sends it to C.
[0061] S104: After decrypting the gradient and loss, C is fed back to the e-commerce and banking systems. The e-commerce and banking systems remove the mask and update the model.
[0062] Iterate the above steps until the loss function converges, thus completing the entire training process. During sample alignment and model training, the data from both the e-commerce platform and the bank remains locally, and data interaction during training does not lead to data privacy leaks. Therefore, with the help of vertical federated learning, the two parties are able to collaboratively train the model.
[0063] In vertical federated learning, the training data for the user's vertical federated learning model is divided into two categories: one from the data user and the other from the data provider. Specifically, the data user initiates the training of the vertical federated learning model, and the model is trained jointly with the data provider.
[0064] For example, a bank acts as the data user, and an e-commerce platform as the data provider. Therefore, the bank and e-commerce platform are two separate participants. When calculating the feature correlation coefficient between the bank's and e-commerce platform's model training feature data, the computational tasks include joint tasks performed by both data users and data providers, as well as separate tasks performed by each. This necessitates writing separate code for each data user and data provider. Currently, different codebases need to be developed for each data user and data provider to implement their respective computational tasks, resulting in complex code that is difficult to develop and maintain.
[0065] To address the technical problems existing in the prior art, this invention proposes a compilation method. When calculating the feature correlation coefficients of model training data between different types of client terminals, a single set of code is developed, containing code corresponding to multiple different types of client terminals. In this way, one set of code can be applied to different client terminals, allowing each client terminal to execute the necessary sub-code within that single set during the calculation of the feature correlation coefficients of the model training data. This eliminates the need to develop code for each type of client terminal, reducing code complexity and facilitating code management and maintenance.
[0066] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Where there is no conflict between the embodiments, the following embodiments and features thereof can be combined with each other.
[0067] Figure 2This is a flowchart illustrating a compilation method provided in an embodiment of the present invention. In this embodiment, the executing entity of the method can be an electronic device, such as... Figure 1a The diagram shows the customer terminals corresponding to banks and e-commerce platforms. The method in this embodiment can be implemented through software, hardware, or a combination of both. For example... Figure 2 As shown, the method may include:
[0068] S201, The client terminal obtains the compiled target code.
[0069] The target code includes sub-target codes for multiple different types of client terminals. Each type of client terminal sub-target code is used to participate in obtaining the feature correlation coefficients of model training data between different types of client terminals in longitudinal federated learning.
[0070] In this step, optionally, the target code to be compiled is obtained by compiling source code in advance from other client terminals or servers based on Python programming language source code. The source code includes sub-source code for multiple different types of client terminals, each used to participate in obtaining feature correlation coefficients.
[0071] Alternatively, another possible implementation of S201 is:
[0072] S2011. The client terminal obtains source code based on the Python programming language.
[0073] The source code includes multiple sub-source codes for different types of client terminals, each used to participate in obtaining feature correlation coefficients.
[0074] Specifically, the developers developed an algorithm for calculating the feature correlation coefficients of feature data trained on different types of client terminals, and wrote the source code using the Python programming language. The source code includes sub-source code for multiple different types of client terminals, each used to participate in obtaining the feature correlation coefficients.
[0075] Optionally, in the training of the longitudinal federated learning model, multiple different types of client terminals include: data users and data providers. The source code then includes sub-source code that can be compiled and run on the client terminals of both the data users and the data providers, respectively.
[0076] It should be noted that developers can write source code directly on the data provider's client terminal, or on other client terminals (e.g., the data initiator) or servers, and then send the source code to the client terminals of the participants in the training of the longitudinal federated learning model.
[0077] S2012, The client terminal compiles the source code into object code.
[0078] Specifically, after the client terminal obtains the source code, it compiles the source code to obtain the compiled target code.
[0079] Therefore, the target code includes sub-target codes for multiple different types of client terminals. Each type of client terminal sub-target code is used to participate in obtaining the feature correlation coefficients of model training data between different types of client terminals in longitudinal federated learning.
[0080] The user transmits the compiled target code to the client terminal so that the client terminal can obtain the compiled target code. For example, the user can copy the compiled target code to the client terminal, or the user can upload the compiled target code to a cloud server, and the client terminals of the participants in the training of the vertical federated learning model can obtain the compiled target code from the server. This embodiment does not limit the acquisition method.
[0081] S202. The client terminal determines the sub-target code belonging to the client terminal from the target code.
[0082] In this step, before obtaining the feature correlation coefficients of model training feature data between different types of client terminals, an identifier for each client terminal, as well as the identifiers of other client terminals interacting with that client terminal for model training feature data, are pre-set, and the client terminal identifiers are stored in the client terminal's configuration file. The client terminal identifier, for example, is related to the computational task performed by the client terminal in calculating the feature correlation coefficients.
[0083] Therefore, when the target code is running on the client terminal, the client terminal's identifier can be obtained through the configuration file.
[0084] When the client terminal runs the target code, it retrieves the client terminal identifier from the configuration file and executes the code sequentially according to the execution order. Upon reaching each sub-target code, it matches the client terminal identifier in the configuration file with the identifier of that sub-target code, determining whether the sub-target code's identifier matches the client terminal identifier recorded in the client terminal's configuration file. If the client terminal identifier in the configuration file matches the identifier of the sub-target code, that sub-target code is identified as belonging to the client terminal.
[0085] S203. The client terminal executes the sub-target code belonging to the client terminal to obtain the feature correlation coefficients of the model training feature data between the client terminal and other client terminals.
[0086] Among them, the feature correlation coefficient is used for longitudinal federated learning.
[0087] In this step, the client terminal executes the sub-target code belonging to that client terminal within the target code to obtain the feature correlation coefficients between the client terminal and other client terminals' model training feature data. Based on these feature correlation coefficients, model training feature data for training the longitudinal federated learning model is obtained.
[0088] The compilation method provided in this embodiment includes sub-target codes for multiple different types of client terminals in the compiled target code. This allows different client terminals to run the compiled target code, determine their own sub-target codes from it, and execute their own sub-target codes to obtain the feature correlation coefficients between the client terminal and other client terminals' model training feature data for vertical federated learning model training. This eliminates the need to develop corresponding code for each type of client terminal, reducing the development complexity of feature correlation code in vertical federated learning and facilitating code management and maintenance.
[0089] Figure 3 A flowchart illustrating a compilation method provided in another embodiment of the present invention. For example... Figure 3 As shown, in Figure 2 Based on the illustrated embodiment, the method of this embodiment includes:
[0090] S301, The client terminal obtains the compiled target code.
[0091] The specific implementation of S301 in this step can be found in S201, and will not be repeated here.
[0092] S302. The client terminal determines whether it is a data application party or a data provider for vertical federated learning. If the client terminal is a data application party for vertical federated learning, then execute S303; if the client terminal is a data provider for vertical federated learning, then execute S304.
[0093] In this step, the target code includes the identifiers of the data users and the data providers used for vertical federated learning.
[0094] Accordingly, one possible manner of the S302 is as follows:
[0095] S3021. The client terminal determines whether its identifier is the identifier of the data application party used for vertical federated learning or the identifier of the data provider used for vertical federated learning.
[0096] Specifically, when writing the source code, for the calculation of the feature correlation coefficient, the calculation task jointly performed by the data user and the data provider is written as a sub-source code, and the calculation tasks performed separately by the data user and the data provider are written as corresponding sub-source code.
[0097] Furthermore, since different types of client terminals have different identifiers when calculating feature correlation coefficients, the identifier of the client terminal executing the sub-source code is included in the first line of each sub-source code. This identifier, contained in the first line of the sub-source code, indicates whether the client terminal is from the data application provider or the data provider.
[0098] In this process, the first line of code in each sub-source code generates a conditional statement after compilation. When the client terminal executes the sub-target code corresponding to the sub-source code, it first executes the conditional statement to determine the identifier of the client terminal executing the sub-target code. Thus, the client terminal is determined to be either the client terminal of the data application party or the client terminal of the data provider through the identifier of the client terminal of the sub-target code.
[0099] Optionally, each sub-source code can also contain multiple nested sub-source code.
[0100] Optionally, when writing the source code for calculating feature correlation coefficients, some calculation tasks need to be executed multiple times. Writing the corresponding statements each time these tasks are needed would be labor-intensive, lead to code redundancy, and slow compilation. Therefore, developers can pre-encapsulate methods that need to be executed multiple times in the sub-source code, or encapsulate methods within the sub-source code. This way, when writing Python-based source code, the encapsulated statements can be used to represent complex statements with simpler ones, thereby reducing the workload of the source code and improving readability and compilation speed.
[0101] S3022. If the identifier of the client terminal is the identifier of the data application party used for vertical federated learning in the target code, then the client terminal is determined to be the data application party used for vertical federated learning.
[0102] Specifically, after determining that the client terminal identifier in the sub-target code is the identifier of the data application party used for vertical federated learning, the client terminal identifier recorded in the client terminal configuration file is obtained. If the client terminal identifier in the sub-target code is consistent with the client terminal identifier recorded in the configuration file, the client terminal is determined to be the data application party used for vertical federated learning.
[0103] S3023. If the identifier of the client terminal is the identifier of the data provider used for vertical federated learning in the target code, then the client terminal is determined to be the data provider used for vertical federated learning.
[0104] Specifically, after determining that the client terminal identifier in the sub-target code is the identifier of the data provider used for vertical federated learning, the client terminal identifier recorded in the client terminal's configuration file is obtained. If the client terminal identifier in the sub-target code is consistent with the client terminal identifier recorded in the configuration file, the client terminal is determined to be the data provider used for vertical federated learning.
[0105] S303. The client terminal determines the sub-target code belonging to the data application party from the target code.
[0106] In this step, when the client terminal executes the sub-target code, it identifies itself as the client terminal of the data application party through the client terminal identifier in the sub-target code, thus determining that the target code belongs to the sub-target code of the data application party.
[0107] S304. The client terminal obtains the locally encrypted model training feature data according to the sub-target code, sends the encrypted model training feature data to the data provider for longitudinal federated learning, and receives the feature correlation coefficients obtained from the data provider based on the encrypted model training feature data.
[0108] In this step, when the client terminal is the client terminal of the data application party and the sub-target code is determined to be the sub-target code of the data application party, its own sub-target code is executed sequentially according to the calculation task.
[0109] For the data application side, when calculating feature correlation coefficients, it first obtains locally encrypted model training feature data and sends this encrypted model training feature data to the data provider used for longitudinal federated learning, treating this computation task as a sub-source code. When the client terminal executes the sub-target code corresponding to this sub-source code, it calls a Python parsing library to parse and obtain... Figure 4 The calculation diagram is shown.
[0110] like Figure 4 As shown, when the client terminal executes the sub-target code, it executes it sequentially starting from the vertex. First, a conditional statement is executed to determine that the client terminal executing the sub-target code is the client terminal of the data application party. Then, it calls down level by level: an encryption statement is executed to encrypt the local model training feature data. After that, an assignment statement is used to assign the locally encrypted model training feature data to x_std, and then a send statement is called to send x_std to the data provider.
[0111] Then, the data application provider receives feature correlation coefficients from the data provider, obtained from feature data trained on an encrypted model, and treats this computational task as a sub-source code. When the client terminal executes the sub-target code corresponding to this sub-source code, it calls a Python parsing library to parse and obtain... Figure 5 The calculation diagram is shown.
[0112] like Figure 5 As shown, when the client terminal executes this sub-target code, it first executes a conditional statement to determine that the client terminal executing this sub-target code is the client terminal of the data application party. Then, it calls down the hierarchy: it calls a receive statement to obtain the encrypted feature correlation coefficients from the data provider, then executes a decryption statement to decrypt the encrypted feature correlation coefficients, obtain the feature correlation coefficients, and assigns them to corr_result through an assignment statement. Finally, it executes an output statement to output the feature correlation coefficients.
[0113] S305. The client terminal determines the sub-target code belonging to the data provider from the target code.
[0114] In this step, when the client terminal executes the sub-target code, it identifies itself as the client terminal of the data provider through the client terminal identifier in the sub-target code, thus determining that the target code belongs to the data provider's sub-target code.
[0115] S306. The client terminal receives encrypted model training feature data from the data provider of longitudinal federated learning according to the sub-target code, obtains feature correlation coefficients based on the encrypted model training feature data and local model training feature data, and sends them to the data application party for federated learning.
[0116] In this step, when the client terminal is the client terminal of the data application party and the sub-target code is determined to be the sub-target code of the data provider, its own sub-target code is executed sequentially according to the calculation task.
[0117] For the data provider, when calculating the feature correlation coefficient, it receives encrypted model training feature data from the data provider for longitudinal federated learning, obtains the feature correlation coefficient based on the encrypted model training feature data and its local model training feature data, and sends it to the data application party for federated learning. This calculation task is treated as a sub-source code. When the client terminal executes the sub-target code corresponding to this sub-source code, it calls a Python parsing library to parse and obtain the relevant information. Figure 6 The calculation diagram is shown.
[0118] like Figure 6As shown, when the client terminal executes this sub-target code, it first executes a judgment statement to determine that the client terminal executing this sub-target code is the client terminal of the data provider. Then, it calls down level by level: it executes a receive statement to receive encrypted model training feature data, then calls a calculation statement to obtain encrypted model training feature data, and assigns it to corr_res through an assignment statement. Finally, it calls a send statement to send the encrypted feature correlation coefficients to the data application party.
[0119] It should be noted that the conditional statements, encryption statements, decryption statements, assignment statements, sending statements, receiving statements, and calculation statements mentioned above are all previously encapsulated methods. When writing the source code, you can directly call the corresponding methods through the above statements.
[0120] Optionally, before executing S304 or S306, it is necessary to standardize the model training feature data of the data user and the data provider.
[0121] The following example illustrates how data users can standardize feature data used for training local models.
[0122] The task of standardizing the feature data trained on the local model is presented as a sub-source code, and the method for standardizing the feature data trained on the local model is encapsulated. Therefore, within this sub-source code, the encapsulated method can be called simply by using the standardization statement.
[0123] One method for standardization is as follows: For each user's feature value used in the data application to calculate the feature correlation coefficient, subtract the average of all user feature values for that feature, and then divide by the standard deviation corresponding to that feature to obtain the model training feature data. The standardization formula is as follows:
[0124]
[0125] Where x_d represents the standardized model training feature data, x i This represents the characteristic value of each user. σ represents the average of the feature values of all users. x It represents the standard deviation.
[0126] The compilation method provided in this embodiment includes sub-target codes for multiple different types of client terminals in the compiled target code. This allows different client terminals to run the compiled target code. When running the target code, each client terminal determines its own sub-target code from the compiled target code based on its own identifier and the identifier of the target code. This sub-target code is then executed to obtain the feature correlation coefficients between the client terminal and other client terminals' model training feature data, enabling model training for vertical federated learning. This eliminates the need to develop corresponding code for each type of client terminal, reducing the development complexity of feature correlation code in vertical federated learning and facilitating code management and maintenance.
[0127] Figure 7 This is a schematic diagram of the structure of a compiler device provided in an embodiment of the present invention. Figure 7 As shown, the compilation apparatus may include: an acquisition module 71 and an execution module 72. Wherein,
[0128] The acquisition module 71 is used for the client terminal to acquire the compiled target code. The target code includes sub-target codes of multiple different types of client terminals. The sub-target codes of each type of client terminal are used to participate in the acquisition of feature correlation coefficients of model training data between different types of client terminals in the longitudinal federated learning.
[0129] The execution module 72 is used by the client terminal to determine the sub-target code belonging to the client terminal from the target code; it is also used by the client terminal to execute the sub-target code belonging to the client terminal to obtain the feature correlation coefficient of the model training feature data between the client terminal and other client terminals. The feature correlation coefficient is used for longitudinal federated learning.
[0130] The compilation apparatus provided in this embodiment can be used to execute the technical solutions provided in any of the foregoing method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0131] In one possible implementation, multiple different types of client terminals include: data users for longitudinal federated learning, and data providers for longitudinal federated learning.
[0132] In one possible implementation, the execution module 72, when the client terminal determines the sub-target code belonging to the client terminal from the target code, specifically performs the following:
[0133] The client terminal determines whether it is a data user or a data provider for vertical federated learning;
[0134] If the client terminal is a data application party used for vertical federated learning, the client terminal determines the sub-target code belonging to the data application party from the target code;
[0135] If the client terminal is a data provider for longitudinal federated learning, then the client terminal determines the sub-target code belonging to the data provider from the target code.
[0136] In one possible implementation, the target code includes an identifier for the data user and an identifier for the data provider used in vertical federated learning.
[0137] Correspondingly, the execution module 72 is used to determine whether the client terminal is a data user or a data provider for vertical federated learning, specifically for:
[0138] The client terminal determines whether its identifier is the identifier of the data user used for vertical federated learning or the identifier of the data provider used for vertical federated learning;
[0139] If the client terminal's identifier is the same as the identifier of the data application party used for vertical federated learning in the target code, then the client terminal is determined to be the data application party used for vertical federated learning.
[0140] If the client terminal's identifier is the same as the identifier of the data provider used for vertical federated learning in the target code, then the client terminal is determined to be the data provider used for vertical federated learning.
[0141] In one possible implementation, the execution module 72, when the client terminal executes sub-target code belonging to the client terminal, is specifically used for:
[0142] If the client terminal is a data application party for vertical federated learning, the client terminal obtains locally encrypted model training feature data according to the sub-target code, sends the encrypted model training feature data to the data provider for vertical federated learning, and receives feature correlation coefficients obtained from the data provider based on the encrypted model training feature data.
[0143] In one possible implementation, the execution module 72, when the client terminal executes sub-target code belonging to the client terminal, is specifically used for:
[0144] If the client terminal is the data provider for vertical federated learning, then the client terminal receives encrypted model training feature data from the data provider for vertical federated learning according to the sub-target code, obtains feature correlation coefficients based on the encrypted model training feature data and local model training feature data, and sends them to the data application party for federated learning.
[0145] In one possible implementation, the acquisition module, used when the client terminal acquires the target compiled file, is specifically used for:
[0146] The client terminal obtains source code based on the Python programming language. The source code includes sub-source code for multiple different types of client terminals, each used to participate in obtaining feature correlation coefficients.
[0147] The client terminal compiles the source code into object code.
[0148] The compilation apparatus provided in any of the foregoing embodiments is used to execute the technical solutions of any of the foregoing method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.
[0149] Figure 8 This is a schematic diagram of a compilation device provided in an embodiment of the present invention. Figure 8 As shown, the device may include: a memory 81, a processor 82, and a compiler stored on the memory 81 and executable on the processor 82. When the compiler is executed by the processor 82, it implements the steps of the compilation method as described in any of the foregoing embodiments.
[0150] Alternatively, the memory 81 can be either standalone or integrated with the processor 82.
[0151] The implementation principle and technical effects of the device provided in this embodiment can be found in the foregoing embodiments, and will not be repeated here.
[0152] This invention also provides a computer-readable storage medium storing a compiler, which, when executed by a processor, implements the steps of the compilation method as described in any of the foregoing embodiments.
[0153] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0154] The integrated modules described above, implemented as software functional modules, can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of the present invention.
[0155] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0156] The integrated modules described above, implemented as software functional modules, can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of the present invention.
[0157] It should be understood that the aforementioned processor can be a CPU, GPU, DSP, Application Specific Integrated Circuit (ASIC), or other general-purpose processor. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0158] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.
[0159] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0160] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.
[0161] 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.
[0162] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0163] 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 the present invention, 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, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0164] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A compilation method, characterized in that, include: The client terminal obtains source code based on the Python programming language. The source code includes multiple sub-source codes for different types of client terminals to participate in obtaining feature correlation coefficients. The source code includes encapsulated statements obtained by encapsulating methods that need to be executed multiple times. The encapsulated statements are used to directly call the corresponding methods. The sub-source code includes standardization statements, which are encapsulated methods used to standardize feature data for training local models. The source code is a single set of code. The client terminal compiles the source code into target code, which includes sub-target codes of multiple different types of client terminals. Each type of client terminal sub-target code is used to participate in obtaining feature correlation coefficients of model training data between different types of client terminals in longitudinal federated learning. The various types of client terminals include: data users for vertical federated learning, and data providers for vertical federated learning; The client terminal determines the sub-target code belonging to the client terminal from the target code; The client terminal executes the sub-target code belonging to the client terminal to obtain the feature correlation coefficient of the model training feature data between the client terminal and other client terminals. The feature correlation coefficient is used for longitudinal federated learning. The client terminal executes the sub-target code belonging to the client terminal, including: if the client terminal is a data application party for vertical federated learning, the client terminal obtains locally encrypted model training feature data according to the sub-target code, sends the encrypted model training feature data to the data provider for vertical federated learning, and receives feature correlation coefficients obtained from the data provider based on the encrypted model training feature data. If the client terminal is a data provider for vertical federated learning, then the client terminal receives encrypted model training feature data from the data provider for vertical federated learning according to the sub-target code, obtains feature correlation coefficients based on the encrypted model training feature data and local model training feature data, and sends them to the data application party for federated learning; wherein, when the client terminal executes the sub-target code corresponding to each sub-source code, it first executes a judgment statement to determine the identifier of the client terminal executing the sub-target code, and determines whether the client terminal is the client terminal of the data application party or the client terminal of the data provider through the identifier of the client terminal of the sub-target code.
2. The method according to claim 1, characterized in that, The client terminal determines the sub-target code belonging to the client terminal from the target code, including: The client terminal determines whether it is a data user or a data provider for vertical federated learning; If the client terminal is a data application party for vertical federated learning, then the client terminal determines the sub-target code belonging to the data application party from the target code; If the client terminal is a data provider for longitudinal federated learning, then the client terminal determines the sub-target code belonging to the data provider from the target code.
3. The method according to claim 2, characterized in that, The target code includes the identifier of the data user for vertical federated learning and the identifier of the data provider for vertical federated learning; The determination of whether the client terminal is a data user or a data provider for vertical federated learning includes: The client terminal determines whether its identifier is an identifier of a data application party for vertical federated learning or an identifier of a data provider for vertical federated learning; If the identifier of the client terminal is the identifier of the data application party used for vertical federated learning in the target code, then the client terminal is determined to be the data application party used for vertical federated learning. If the identifier of the client terminal is the identifier of the data provider used for vertical federated learning in the target code, then the client terminal is determined to be the data provider used for vertical federated learning.
4. A compilation apparatus, characterized in that, include: The acquisition module is used by the client terminal to acquire the compiled target code. The target code includes sub-target codes of multiple different types of client terminals. The sub-target codes of each type of client terminal are used to participate in acquiring the feature correlation coefficients of model training data between different types of client terminals in vertical federated learning. The multiple different types of client terminals include: data application parties for vertical federated learning and data providers for vertical federated learning. The acquisition module is specifically used for: the client terminal acquiring source code based on the Python programming language, the source code including multiple sub-source codes for different types of client terminals to participate in acquiring feature correlation coefficients, the source code including encapsulated statements obtained by encapsulating methods that need to be executed multiple times, the encapsulated statements being used to directly call the corresponding methods; the sub-source code includes standardization statements, the standardization statements being encapsulated methods used to standardize feature data for training local models; the source code is a set of code; the client terminal compiles the source code into target code; The execution module is used for the client terminal to determine the sub-target code belonging to the client terminal from the target code; and is also used for the client terminal to execute the sub-target code belonging to the client terminal to obtain the feature correlation coefficient of the model training feature data between the client terminal and other client terminals, the feature correlation coefficient being used for longitudinal federated learning; The running module is used when the client terminal executes the sub-target code belonging to the client terminal. Specifically, it is used to: if the client terminal is a data application party for vertical federated learning, the client terminal obtains locally encrypted model training feature data according to the sub-target code, sends the encrypted model training feature data to the data provider for vertical federated learning, and receives the feature correlation coefficient obtained from the data provider based on the encrypted model training feature data. The running module is used when the client terminal executes sub-target code belonging to the client terminal. Specifically, it is used as follows: if the client terminal is a data provider for vertical federated learning, the client terminal receives encrypted model training feature data from the data provider for vertical federated learning according to the sub-target code, obtains feature correlation coefficients based on the encrypted model training feature data and local model training feature data, and sends them to the data application party for federated learning; wherein, when the client terminal executes the sub-target code corresponding to each sub-source code, it first executes a judgment statement to determine the identifier of the client terminal executing the sub-target code, and determines whether the client terminal is the client terminal of the data application party or the client terminal of the data provider through the identifier of the client terminal of the sub-target code.
5. A compilation device, characterized in that, The compilation device includes: a memory, a processor, and computer code stored in the memory and executable on the processor, wherein the computer code, when executed by the processor, implements the steps of the compilation method as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer code, which, when executed by a processor, implements the steps of the compilation method as described in any one of claims 1 to 3.