Model Generation Method, Apparatus, Device, and Storage Medium
By determining the participants and task codes corresponding to the calculation tasks in federated learning and generating model codes, the large-scale workload of model development caused by different processing logics of different participants is solved, and the sharing of model codes and the unity of model training is achieved.
Patent Information
- Application Number
- CN202011273312.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-13
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2040-11-13
AI Technical Summary
In federated learning, since the processing logic of different participants is different, different codes need to be written for each participant, resulting in a large amount of workload in model development.
By determining at least one participant corresponding to each computing task in a plurality of computing tasks, obtaining the task code corresponding to each computing task, determining the model code based on the participant and task code, and finally performing model training based on the model code to generate the first model of federated learning modeling.
There is no need to write different codes for different participants, which greatly reduces the workload of federated learning model development and realizes the unity of model code sharing and model training.
Smart Images

Figure CN114489626B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a model generation method, device, equipment and storage medium. Background Art
[0002] The widespread application of artificial intelligence technology can greatly improve the level of intelligence in production and life. Since the application of artificial intelligence technology is inseparable from a large amount of data, and as the compliance requirements for data acquisition become increasingly stringent, the data between various institutions or enterprises cannot be interoperable, which has brought obstacles to the application of artificial intelligence technology.
[0003] Federated learning enables data use and machine learning modeling through parameter exchange under an encrypted mechanism, without leaving the local data of each institution or enterprise, while ensuring data security and compliance.
[0004] Current federated learning involves multiple participants. Since different participants have different processing logics, when training the model, different codes need to be written for different participants to implement their respective processing logics, which results in a large workload for model development. Summary of the invention
[0005] The main purpose of the present invention is to provide a model generation method, device, equipment and storage medium, aiming to reduce the workload of developing a federated model.
[0006] To achieve the above object, the present invention provides a model generation method, which comprises:
[0007] Determine at least one participant corresponding to each of a plurality of computing tasks, wherein the plurality of computing tasks are computing tasks in federated learning modeling;
[0008] Obtaining a task code corresponding to each of the computing tasks;
[0009] Determining a model code according to at least one participant corresponding to each of the computing tasks and a task code corresponding to each of the computing tasks;
[0010] Model training is performed according to the model code to generate a first model corresponding to the federated learning modeling.
[0011] In a possible implementation manner, determining the model code according to at least one participant corresponding to each of the computing tasks and a task code corresponding to each of the computing tasks includes:
[0012] Determine the participant corresponding to each task code according to at least one participant corresponding to each computing task and the task code;
[0013] Determine the model code according to each task code and the corresponding party of each task code.
[0014] In a possible implementation manner, the determining the model code according to each task code and the corresponding party of each task code includes:
[0015] Add the identifier of the corresponding party to each task code according to the party corresponding to each task code to obtain the updated task code;
[0016] Determine the model code according to the updated task code.
[0017] In a possible implementation manner, the determining the model code according to the updated task code includes:
[0018] Obtain the execution order of the multiple computing tasks;
[0019] Determine the execution order between the updated task codes according to the execution order of the multiple computing tasks;
[0020] Determine the model code according to the updated task code and the execution order between the updated task codes.
[0021] In a possible implementation manner, the performing model training according to the model code to generate the first model corresponding to the federated learning modeling includes:
[0022] Determine multiple parties corresponding to the federated learning modeling, where the multiple parties include the at least one party;
[0023] Control the multiple parties to perform model training according to the model code respectively to generate the first model corresponding to the federated learning modeling.
[0024] In a possible implementation manner, the controlling the multiple parties to perform model training according to the model code respectively to generate the first model corresponding to the federated learning modeling includes:
[0025] Send the model code to the clients corresponding to the multiple parties, so that the clients corresponding to the multiple parties perform model training according to the model code to generate the first model;
[0026] Wherein, during the model training, the client corresponding to the party executes the task code corresponding to the party in the model code, and the task code corresponding to the party includes the identifier of the party.
[0027] In a possible implementation, obtaining the task codes corresponding to the respective computing tasks includes:
[0028] Obtaining the types of the respective computing tasks, where the types of the computing tasks are public types or non - public types;
[0029] According to the types of the respective computing tasks, obtaining the task codes corresponding to the respective computing tasks.
[0030] In a possible implementation, according to the types of the respective computing tasks, obtaining the task codes corresponding to the respective computing tasks includes:
[0031] If the type of the computing task is a public type, obtaining the task code corresponding to the computing task in a preset code library according to the identifier of the computing task; or,
[0032] If the type of the computing task is a non - public type, receiving the task code corresponding to the computing task through a preset interface.
[0033] In a possible implementation, determining at least one participant corresponding to each of the multiple computing tasks includes:
[0034] Obtaining the function corresponding to each participant;
[0035] According to the function corresponding to each participant, determining at least one participant corresponding to each of the multiple computing tasks.
[0036] In a possible implementation, at least one first computing task is included in the multiple computing tasks, and the first computing task corresponds to multiple participants;
[0037] Among them, the at least one first computing task includes at least one of the following computing tasks: encoding computing task, encryption computing task, decryption computing task, or communication computing task.
[0038] The present invention further provides a model generation device, and the device includes:
[0039] A determination module, configured to determine at least one participant corresponding to each of the multiple computing tasks, where the multiple computing tasks are computing tasks in federated learning modeling;
[0040] An acquisition module, configured to acquire the task codes corresponding to the respective computing tasks;
[0041] A processing module, configured to determine a model code according to at least one participant corresponding to each of the computing tasks and the task codes corresponding to the respective computing tasks;
[0042] A generation module, configured to perform model training according to the model code and generate a first model corresponding to the federated learning modeling.
[0043] In a possible implementation manner, the processing module is specifically configured to:
[0044] Determine the parties corresponding to each task code according to at least one party and the task code corresponding to each computing task;
[0045] Determine the model code according to each task code and the parties corresponding to each task code.
[0046] In a possible implementation manner, the processing module is specifically configured to:
[0047] Add the identifier of the corresponding party to each task code according to the parties corresponding to each task code to obtain the updated task code;
[0048] Determine the model code according to the updated task code.
[0049] In a possible implementation manner, the processing module is specifically configured to:
[0050] Obtain the execution order of the multiple computing tasks;
[0051] Determine the execution order between the updated task codes according to the execution order of the multiple computing tasks;
[0052] Determine the model code according to the updated task code and the execution order between the updated task codes.
[0053] In a possible implementation manner, the generation module is specifically configured to:
[0054] Determine multiple parties corresponding to the federated learning modeling, where the multiple parties include the at least one party;
[0055] Control the multiple parties to perform model training according to the model code respectively to generate a first model corresponding to the federated learning modeling.
[0056] In a possible implementation manner, the generation module is specifically configured to:
[0057] Send the model code to the clients corresponding to the multiple parties, so that the clients corresponding to the multiple parties perform model training according to the model code to generate the first model;
[0058] Among them, during the process of training the model, the client corresponding to the participating party executes the task code corresponding to the participating party in the model code, and the task code corresponding to the participating party includes the identifier of the participating party.
[0059] In a possible implementation manner, the obtaining module is specifically configured to:
[0060] Obtain the types of each of the computing tasks, where the types of the computing tasks are public types or non-public types;
[0061] According to the types of each of the computing tasks, obtain the task code corresponding to each of the computing tasks.
[0062] In a possible implementation manner, the obtaining module is specifically configured to:
[0063] If the type of the computing task is a public type, obtain the task code corresponding to the computing task in a preset code library according to the identifier of the computing task; or,
[0064] If the type of the computing task is a non-public type, receive the task code corresponding to the computing task through a preset interface.
[0065] In a possible implementation manner, the determining module is specifically configured to:
[0066] Obtain the function corresponding to each participating party;
[0067] According to the function corresponding to each participating party, determine at least one participating party corresponding to each of the multiple computing tasks.
[0068] In a possible implementation manner, at least one first computing task is included in the multiple computing tasks, and the first computing task corresponds to multiple participating parties;
[0069] Among them, the at least one first computing task includes at least one of the following computing tasks: an encoding computing task, an encryption computing task, a decryption computing task, or a communication computing task.
[0070] The present invention also provides a model generation device, where the model generation device includes: a memory, a processor, and a model generation program stored on the memory and executable on the processor, and when the model generation program is executed by the processor, the steps of the model generation method as described in any one of the foregoing are implemented.
[0071] The present invention also provides a computer-readable storage medium, where a model generation program is stored on the computer-readable storage medium, and when the model generation program is executed by a processor, the steps of the model generation method as described in any one of the foregoing are implemented.
[0072] In the present invention, first, at least one participant corresponding to each computing task among multiple computing tasks is determined. These multiple computing tasks are computing tasks in federated learning modeling. Then, the task code corresponding to each computing task is obtained, and a model code is determined based on at least one participant corresponding to each computing task and the task code corresponding to each computing task. Finally, model training is performed according to the model code to generate a first model corresponding to the federated learning modeling. The solution provided in the embodiments of the present invention, in view of the situation where the computing tasks of multiple participants in federated learning modeling may not be exactly the same, assigns corresponding computing tasks to different participants in federated learning modeling, and generates a complete model code for each participant to share the model code to complete the training and development of the federated learning model, generating the first model, without writing different codes for different participants to implement their respective processing logics, greatly reducing the workload of developing the federated learning model. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 FIG. is a schematic diagram of an application scenario provided by an embodiment of the present invention;
[0074] Figure 2 FIG. is a schematic diagram of the development of a federated learning model task;
[0075] Figure 3 FIG. is a schematic flowchart of a model generation method provided by an embodiment of the present invention;
[0076] Figure 4 FIG. is a schematic diagram of a development framework of a federated model provided by an embodiment of the present invention;
[0077] Figure 5 FIG. is a schematic flowchart of generating a model code provided by an embodiment of the present invention;
[0078] Figure 6 FIG. is a schematic diagram of the code of a federated learning model provided by an embodiment of the present invention;
[0079] Figure 7 FIG. is a schematic diagram after disassembling the code provided by an embodiment of the present invention;
[0080] Figure 8 FIG. is a schematic diagram of the development of a new federated learning model provided by an embodiment of the present invention;
[0081] Figure 9 FIG. is a schematic structural diagram of a model generation device provided by an embodiment of the present invention;
[0082] Figure 10 FIG. is a schematic structural diagram of a model generation device provided by an embodiment of the present invention.
[0083] The realization, functional characteristics, and advantages of the objectives of the present invention will be further described with reference to the embodiments and the accompanying drawings. Detailed Implementation Modes
[0084] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be completely conveyed to those skilled in the art.
[0085] guest: A role in the federated learning environment, usually the data application party, used to provide labeled data. The guest party is also used to initiate the model establishment process.
[0086] host: A role in the federated learning environment, usually the data provider, used to provide data.
[0087] arbiter: A role in the federated learning environment, usually the arbitration party, used to assist multiple parties in completing joint modeling, which can be used to aggregate gradients or models, and can also participate in distributing public keys and providing encryption and decryption services, etc.
[0088] In the following embodiments, the data application party is represented by guest, the data provider is represented by host, and the arbitration party is represented by arbiter.
[0089] FATE Script: A programming language designed, defined, and developed independently.
[0090] Figure 1 FIG. is a schematic diagram of an application scenario provided for an embodiment of the present invention. As Figure 1 shown, the server and n client terminals can participate in the federated learning process. Among them, Figure 1 Exemplarily, it can be a process in which the server and n client terminals jointly perform modeling and train to obtain a common model, or a process of using the common model for business processing after the common model training is completed.
[0091] During the federated learning process, since it includes multiple participating parties, different participating parties may have different roles in the federated learning environment, and the tasks or logical operations they need to perform may also be different. For example, during the process of jointly establishing a common model through federated learning, the roles that each participating party may involve include guest, host, and arbiter, etc. Different roles have different calculation processes during the modeling training. Therefore, in the development of federated model tasks, it is generally necessary to write different codes for the participating parties with different roles for implementation.
[0092] The following will be combined with Figure 2Describe the development of federated learning model tasks for different roles of participants.
[0093] Figure 2 It is a schematic diagram for the development of a federated learning model task. As Figure 2 shown, the participants of the federated model include guest, host, and arbiter. Each participant has its own model or task, such as guest model / task, host model / task, and arbiter model / task.
[0094] Currently, due to the different role definitions among the participants and the different computational tasks to be executed, it is necessary to write program codes separately for each role or participant according to different role definitions to implement their respective computational logics.
[0095] For example, assume that the computational tasks to be executed by the participant guest include addition of data matrices, convolution operations, and multiplication of data matrices, while the computational tasks to be executed by the participant host include subtraction of data matrices and convolution operations. Then, the developer needs to write program codes for the participant guest to implement operations such as addition of data matrices, convolution operations, and multiplication of data matrices to obtain the guest program, and write program codes for the participant host to implement subtraction of data matrices and convolution operations to obtain the host program. After obtaining the guest program and the host program, perform encoding / encryption and other processing respectively, and then implement communication between the guest participant and the host participant, etc.
[0096] In the above process, since the computational tasks of each participant are different, and there are also data encryption and communication processing between the respective participants, and there are differences in the data objects to be encrypted and the communication data objects of each participant, the workload of developing the federated model is relatively large.
[0097] Based on this, the embodiments of the present invention provide a model generation method to solve the problem of relatively large workload in the development of the federated model.
[0098] Figure 3 It is a schematic flowchart of a model generation method provided by an embodiment of the present invention. As Figure 3 shown, the method may include:
[0099] S31, determine at least one participant corresponding to each of the multiple computational tasks in the multiple computational tasks, where the multiple computational tasks are computational tasks in federated learning modeling.
[0100] In an embodiment of the present invention, the execution subject of the model generation method provided can be a server, which is used to generate a first model corresponding to federated learning modeling. In federated learning modeling, multiple participants jointly perform model training, and the computational tasks that different participants need to execute may vary.
[0101] In federated learning modeling, there are multiple computational tasks. Among them, each computational task corresponds to at least one of the multiple participants. When a certain participant needs to execute a certain computational task, then that participant is the participant corresponding to that computational task. For any one computational task, the corresponding participants are one or more.
[0102] S32. Obtain the task codes corresponding to each of the computational tasks.
[0103] After determining at least one participant corresponding to each computational task, the task codes corresponding to each computational task can be obtained. Among them, the task codes of different computational tasks are different. The programming languages used for the task codes can be common programming languages such as C / C++, Java, etc., or can also use self-developed FATE Script, etc.
[0104] S33. Determine the model code according to at least one participant corresponding to each of the computational tasks and the task codes corresponding to each of the computational tasks.
[0105] After determining at least one participant corresponding to each computational task and the task codes corresponding to each computational task, the model code can be determined. This model code is used for federated learning modeling. For any one computational task, after determining the task code corresponding to that computational task, since there are multiple computational tasks in federated learning modeling and the computational tasks and the corresponding task codes are in one-to-one correspondence, the model code for federated learning modeling can be obtained according to the task codes corresponding to each computational task.
[0106] S34. Perform model training according to the model code to generate the first model corresponding to the federated learning modeling.
[0107] In an embodiment of the present invention, for one federated learning modeling, only one set of model code is generated. In the model code, for the task code corresponding to each computational task, there is a corresponding participant. Then, this set of model code can be distributed to the clients corresponding to each participant. The clients corresponding to each participant perform model training according to this model code. Among them, each participant only executes the task code corresponding to its computational task. Finally, after performing federated model training according to this model code, the first model corresponding to the federated learning modeling can be generated.
[0108] The model generation method provided by the embodiments of the present invention first determines at least one participant corresponding to each computing task among multiple computing tasks, where these multiple computing tasks are computing tasks in federated learning modeling. Then, it obtains the task code corresponding to each computing task, and determines the model code based on at least one participant corresponding to each computing task and the task code corresponding to each computing task. Finally, it performs model training according to the model code to generate a first model corresponding to the federated learning modeling. The solution provided by the embodiments of the present invention, in view of the situation that the computing tasks of multiple participants in federated learning modeling may not be exactly the same, assigns corresponding computing tasks to different participants in federated learning modeling, and generates a complete model code for each participant to share the model code to complete the training and development of the federated learning model, generating the first model, without writing different codes for different participants to implement their respective processing logics, greatly reducing the workload of federated learning model development.
[0109] The solution of the present invention will be introduced in detail below in combination with specific embodiments.
[0110] In federated learning, although there are multiple participants with different roles, each participant is for the purpose of completing the final common model. Therefore, in many cases, the data processing flow of each participant is the same, except that the data processed by each is the data owned by each participant.
[0111] Among the multiple computing tasks in federated learning modeling, there are usually computing tasks corresponding to multiple participants. These computing tasks are the first computing tasks, and the first computing tasks are common types of computing tasks. During the process of federated learning modeling, at least two participants need to execute the first computing tasks. Among them, the first computing tasks include at least one of the following: encoding computing tasks, encryption computing tasks, decryption computing tasks, or communication computing tasks.
[0112] Furthermore, the encryption and communication of data under federated learning have relatively fixed patterns. For example, for data X and data Y distributed under two roles, guest and host, they can be vertically split on different roles. After splitting, data X is represented as X g and X h , and data Y is split into Y g and Y h (X = vertical stack(X g , X h ), Y = vertical stack(Y g , Y h ), where vertical stack is an operation for splicing two tables). There is a fixed encryption and communication pattern for calculating X@Y. Generally, it is to calculate X g @Yg and X h @Y h Then, encrypt the calculation result of one of the roles and send it to the other party for summation to obtain the encrypted X@Y.
[0113] In summary, it can be learned that there are many identical processing procedures during the modeling and development of federated learning. Each of these processing procedures can be regarded as a computing task, and the computing tasks included by different participating parties may be different. Based on this, the embodiments of the present invention provide a concise programming paradigm to implement the modeling and development of federated models.
[0114] Figure 4 The figure is a schematic diagram of a development framework for a federated model provided by an embodiment of the present invention. As Figure 4 shown, it generally includes 4 main parts, namely Compiler / Application, Operator, Runtime, and Contract.
[0115] In the compiler part, it includes multiple different programming languages, such as FATE Script, Python, C / C++, Java, and other programming languages not listed. Under this development framework, developers can use any one of these programming languages to implement the solution of the embodiments of the present invention.
[0116] In the operator part, multiple operations are listed, including tensor operations, federated operations, symbolic operations, Eager operations, and other types of operations, etc. When the modeling or application of the federated model involves the above operations, they can be directly called.
[0117] In the runtime part, it includes Local Tensor (framework), Distributed Tensor (framework), TensorFlow runtime (framework), Pytorch runtime (framework), and other runtimes (frameworks), etc.
[0118] In the contract part, it involves the encryption and communication of each participating party in the federated learning model, including Homomorphic Encryption, Secret Sharing, RSA encryption algorithm (RSA), and Encoding, etc.
[0119] The code written by the developer in any of the above programming languages will be converted by the compiler into code based on the Operator for operation. The Operator will ultimately call the Runtime for execution at the interpreter level, and encoding, encryption / decryption, and communication are built into the Operator and the Runtime.
[0120] The following describes the development of the federated model task in combination with Figure 4 the development framework of the example.
[0121] Before performing federated learning modeling, it is first necessary to determine at least one participant corresponding to each computing task among multiple computing tasks. Specifically, the participants in the federated learning modeling can be determined first, and then according to the functions corresponding to each participant, at least one participant corresponding to each computing task can be determined among the multiple computing tasks.
[0122] For example, in federated learning modeling, there are participant guest, participant host, and participant arbiter. The functions that these three participants need to implement are different, so the computing tasks that these three participants need to execute are also different. Among them, participant guest can be used to initiate the establishment process of the federated model and can be used to provide labeled data. Participant host is used to provide data. Participant arbiter can be used to aggregate gradients or models and can be used to participate in the distribution of public keys, etc. Since the functions that each participant needs to implement are different, the computing tasks that each participant needs to execute are also different. Therefore, according to the function corresponding to each participant, at least one participant corresponding to each computing task can be determined.
[0123] After determining at least one participant corresponding to each computing task, it is necessary to obtain the task code corresponding to each computing task. Among them, according to the different types of computing tasks, the methods for obtaining the task code corresponding to the computing task are also different. Therefore, it is necessary to first obtain the types of each computing task. The types of computing tasks include public types or non-public types, and then according to the type of the computing task, obtain the task code corresponding to each computing task.
[0124] A computing task of the public type refers to a computing task for which the corresponding participants are two or more participants, and these two or more participants need to execute this computing task during federated learning modeling; a computing task of the non-public type refers to a computing task for which the corresponding participant is one participant, and only this one participant needs to execute this non-public type of computing task during federated learning modeling.
[0125] For common types of computing tasks, since multiple parties need to execute such common types of computing tasks, the task code corresponding to the common type of computing task can be pre-written and encapsulated, and stored in a preset code library. Then, when the task code of the common type of computing task needs to be obtained, according to the identifier of the computing task, the task code of the computing task can be directly called and obtained from the preset code library.
[0126] In this way, for common types of computing tasks, two or more parties corresponding to the common type of computing task can share the corresponding task code in the preset code library, and there is no need for programmers to write the task code corresponding to each computing task for each party, thus reducing the workload of federated model development.
[0127] For non-common types of computing tasks, since there is only one corresponding party, the corresponding task code needs to be written for it, and the task code corresponding to the computing task is received through a preset interface.
[0128] After obtaining the task code corresponding to each computing task, a set of model code needs to be generated for each party to perform federated learning modeling. Figure 5 The flowchart of generating model code provided by the embodiment of the present invention is as Figure 5 shown, including:
[0129] S51, determining the party corresponding to each task code according to at least one party and the task code corresponding to each computing task.
[0130] Since each computing task corresponds to at least one party, and each computing task has its own corresponding task code, therefore, the party corresponding to each task code can be determined, and the party corresponding to each task code will execute the corresponding task code subsequently. For example, if the parties corresponding to a certain computing task include Party A and Party B, then the party corresponding to the task code corresponding to this computing task is also Party A and Party B.
[0131] S52, determining the model code according to each task code and the party corresponding to each task code.
[0132] After determining the parties corresponding to each task code, the identifier of the corresponding party can be added to each task code to obtain the updated task code. The difference between the updated task code and the task code before the update is that the updated task code includes the identifier of the corresponding party. According to the identifier of the party, each client of the parties can know which client corresponding to the party should execute the updated task code, that is, according to the identifier of the party in each updated task code, the party corresponding to the task code can be known. Then, according to the updated task code, the model code can be determined.
[0133] Specifically, since the federated learning modeling includes not only multiple computing tasks but also the execution order of multiple computing tasks, the federated learning modeling process can be completed only by executing according to the execution order of multiple computing tasks. And the computing tasks need to execute the corresponding task code to implement. Therefore, the execution order of multiple computing tasks can be obtained first, and according to the execution order of multiple computing tasks, the execution order between the updated task codes can be determined. After determining the execution order between the updated task codes, the model code can be determined according to the updated task code.
[0134] In the embodiments of the present invention, for any number of parties, there is only one set of model codes obtained, and all parties perform the training of the federated model according to the model codes.
[0135] After determining the multiple parties corresponding to the federated learning modeling, these multiple parties can be controlled to perform model training according to the model codes respectively to generate the first model corresponding to the federated learning modeling.
[0136] Specifically, after determining the model code, the model code can be sent to the client corresponding to each party respectively. After receiving the model code, the client corresponding to each party performs model training according to the model code.
[0137] The operation of the model code is from top to bottom, and the model codes received by the clients corresponding to each party are the same. For the client corresponding to any party, the client only needs to execute the task code corresponding to the party in the model code. Among them, the client corresponding to each party can determine the task code that the party needs to execute according to the identifier of the party in the task code.
[0138] Taking the participants including participant guest, participant host, and participant arbiter as an example, for participant guest, the task code that the client corresponding to participant guest needs to execute may include: task code with the corresponding participant being only participant guest, task code with the corresponding participants being participant guest and participant host, task code with the corresponding participants being participant guest, participant host, and participant arbiter, and so on.
[0139] Figure 6 This is a schematic diagram of the code of the federated learning model provided by the embodiments of the present invention. As Figure 6 shown, under multiple participants with a guest|host|arbiter mix, it may include guest|host|arbiter programs (i.e., task codes that may be executed by all of guest, host, and arbiter), guest programs (i.e., task codes only executed by guest), host programs (i.e., task codes only executed by host), arbiter programs (i.e., task codes only executed by arbiter), and guest|host programs (i.e., task codes that may be executed by both guest and host).
[0140] Under multiple participants with a guest|host mix, it may include guest|host programs (i.e., task codes that may be executed by both guest and host), guest programs (i.e., task codes only executed by guest), and host programs (i.e., task codes only executed by host).
[0141] Under participant arbiter, it includes arbiter programs (i.e., task codes only executed by arbiter); under participant guest, it includes guest programs (i.e., task codes only executed by guest); under participant host, it includes host programs (i.e., task codes only executed by host); under other mixed participants, it includes other programs, and so on.
[0142] Similarly, the calculation logic that a calculation task needs to implement can be pre-written in a certain programming language, obtaining the corresponding task code and encapsulating it. When a participant needs to implement this calculation logic, it can be directly called. The encapsulated task code is an ordinary program, and the ordinary program can be called by any participant. If there are some programs in the first model that can only be called and executed by some participants, then the corresponding executing participants can be determined during the call. When different participants call the same task code, the input and output data may be different, but the implemented calculation logic is the same.
[0143] The ordinary program segment contains ordinary functional program codes, encoding and decoding codes, encryption and decryption codes, communication codes, etc. These codes can be represented in Python, C / C++, Java, etc. That is, the implementation of the solution of the embodiment of the present invention can use languages such as Python, C / C++, Java, etc., and finally be compiled into an ordinary program segment that mixes multiple roles.
[0144] In the above embodiment, the parties involved in the code that need to execute the code in the code of mixed roles are described. For different parties, the task codes they need to execute are different.
[0145] Figure 7 The schematic diagram after disassembling the code provided by the embodiment of the present invention is as Figure 7 shown. Taking the three parties of guest, host, and arbiter as an example.
[0146] For the party guest, the computing tasks it needs to execute may include guest|host|arbiter computing tasks (that is, the corresponding parties include the computing tasks of guest, host, and arbiter), guest|host computing tasks (that is, the corresponding parties include the computing tasks of guest and host), guest computing tasks (that is, the corresponding party is the guest's computing task), and other computing tasks that include the guest.
[0147] As Figure 7 shown, for the guest|host|arbiter computing task, the task codes that the involved party guest may execute include guest|host|arbiter programs, guest|host programs, and guest programs; for the guest|host computing task, the task codes that the involved party guest may execute include guest|host programs and guest programs; for the guest computing task, the task codes that the involved party guest may execute include guest programs; for other computing tasks that include the guest, the programs that other involved parties guest may execute are involved.
[0148] For the party host, the computing tasks it needs to execute may include guest|host|arbiter computing tasks (that is, the corresponding parties include the computing tasks of guest, host, and arbiter), guest|host computing tasks (that is, the corresponding parties include the computing tasks of guest and host), host computing tasks (that is, the corresponding party is the host's computing task), and other computing tasks that include the host.
[0149] AsFigure 7 As shown, for the guest|host|arbiter computing task, the task codes that the involved party host may execute include the guest|host|arbiter program, the guest|host program, and the host program; for the guest|host computing task, the task codes that the involved party host may execute include the guest|host program and the host program; for the host computing task, the task codes that the involved party host may execute include the host program; for other computing tasks including the host, there are programs that other involved parties host may execute.
[0150] For the involved party arbiter, the computing tasks it needs to execute may include the guest|host|arbiter computing task (i.e., the computing task with the corresponding involved parties including guest, host, and arbiter), the arbiter computing task (i.e., the computing task with the corresponding involved party being arbiter), and other computing tasks including the arbiter.
[0151] As Figure 7 shown, for the guest|host|arbiter computing task, the task codes that the involved party arbiter may execute include the guest|host|arbiter program and the arbiter program; for the arbiter computing task, the task codes that the involved party arbiter may execute include the arbiter program; for other computing tasks including the arbiter, there are programs that other involved parties arbiter may execute.
[0152] Figure 7 Based on the Figure 6 example, for different involved parties, the task codes to be executed are distinguished, and the example with the involved parties including guest, host, and arbiter is used for illustration. Among them, the model code sent by the server to the client corresponding to each involved party is the same, that is, multiple involved parties share the same set of model codes. This model code includes the task codes corresponding to each computing task and the involved party corresponding to each task code.
[0153] For any involved party, the client corresponding to the involved party only needs to execute the task code corresponding to this involved party in the model code for model training. For example, the client corresponding to the involved party guest only needs to execute Figure 7 the program executed by the guest party in the left example; the client corresponding to the involved party host only needs to execute Figure 7The program executed by the host party of the middle example; for the client corresponding to the participant arbiter, only need to execute Figure 7 The program executed by the arbiter party of the right example in
[0154] Through the solution of the above embodiments, a new development process of the federated learning model is provided. Figure 8 It is a schematic diagram of the development of the new federated learning model provided by the embodiments of the present invention. As Figure 8 shown, through the solution of the embodiments of the present invention, the developer only needs to define the operation logic of the federated model task, such as the guest model / task, the host model / task, and the arbiter model / task, so as to determine at least one participant corresponding to each computing task. Then, obtain the model code according to the participants corresponding to each computing task and the task code corresponding to each computing task, and send the model code to the clients corresponding to each participant. The clients corresponding to each participant execute the corresponding task code in the model code, that is Figure 8 the FATE Script program in
[0155] From the above code definition and execution process, it can be known that the solution of the embodiments of the present invention integrates the federated learning modeling / task in a model code. By allocating different participants to different task codes in the model code or sharing the same task code among multiple participants, the purpose of greatly streamlining the modeling / task code is achieved. At the same time, details such as encoding, encryption, and communication are encapsulated or hidden, greatly reducing the user's development and operation and maintenance burden.
[0156] The model generation method provided by the embodiments of the present invention first determines at least one participant corresponding to each computing task among multiple computing tasks, and these multiple computing tasks are the computing tasks in the federated learning modeling. Then, obtain the task code corresponding to each computing task, and determine the model code according to at least one participant corresponding to each computing task and the task code corresponding to each computing task. Finally, perform model training according to the model code to generate the first model corresponding to the federated learning modeling. The solution provided by the embodiments of the present invention aims at the situation where the computing tasks of multiple participants in the federated learning modeling may not be exactly the same. By allocating corresponding computing tasks to different participants in the federated learning modeling and generating a complete model code for each participant to share the model code to complete the training and development of the federated learning model and generate the first model, there is no need to write different codes for different participants to implement their respective processing logics, greatly reducing the workload of developing the federated learning model.
[0157] Figure 9 The following is a schematic structural diagram of a model generation device provided by an embodiment of the present invention. As Figure 9 shown, it includes:
[0158] A determination module 91, configured to determine at least one participant corresponding to each of the multiple computing tasks, where the multiple computing tasks are computing tasks in federated learning modeling;
[0159] An acquisition module 92, configured to acquire the task code corresponding to each of the computing tasks;
[0160] A processing module 93, configured to determine a model code according to at least one participant corresponding to each of the computing tasks and the task code corresponding to each of the computing tasks;
[0161] A generation module 94, configured to perform model training according to the model code and generate a first model corresponding to the federated learning modeling.
[0162] In a possible implementation manner, the processing module 93 is specifically configured to:
[0163] Determine the participant corresponding to each task code according to at least one participant corresponding to each of the computing tasks and the task code;
[0164] Determine the model code according to each task code and the participant corresponding to each task code.
[0165] In a possible implementation manner, the processing module 93 is specifically configured to:
[0166] Add the identifier of the corresponding participant to each task code according to the participant corresponding to each task code to obtain an updated task code;
[0167] Determine the model code according to the updated task code.
[0168] In a possible implementation manner, the processing module 93 is specifically configured to:
[0169] Obtain the execution order of the multiple computing tasks;
[0170] Determine the execution order between the updated task codes according to the execution order of the multiple computing tasks;
[0171] Determine the model code according to the updated task code and the execution order between the updated task codes.
[0172] In a possible implementation manner, the generation module 94 is specifically configured to:
[0173] Determine multiple parties corresponding to the federated learning modeling, where the multiple parties include the at least one party;
[0174] Control the multiple parties to respectively perform model training according to the model code to generate a first model corresponding to the federated learning modeling.
[0175] In a possible implementation manner, the generating module 94 is specifically configured to:
[0176] Send the model code to the clients corresponding to the multiple parties, so that the clients corresponding to the multiple parties perform model training according to the model code to generate the first model;
[0177] Wherein, during the model training process, the client corresponding to the party executes the task code corresponding to the party in the model code, and the task code corresponding to the party includes the identifier of the party.
[0178] In a possible implementation manner, the obtaining module 92 is specifically configured to:
[0179] Obtain the types of each of the computing tasks, where the types of the computing tasks are public types or non - public types;
[0180] According to the types of each of the computing tasks, obtain the task code corresponding to each of the computing tasks.
[0181] In a possible implementation manner, the obtaining module 92 is specifically configured to:
[0182] If the type of the computing task is a public type, obtain the task code corresponding to the computing task in a preset code library according to the identifier of the computing task; or,
[0183] If the type of the computing task is a non - public type, receive the task code corresponding to the computing task through a preset interface.
[0184] In a possible implementation manner, the determining module 91 is specifically configured to:
[0185] Obtain the function corresponding to each party;
[0186] According to the function corresponding to each party, determine at least one party corresponding to each of the computing tasks among the multiple computing tasks.
[0187] In a possible implementation manner, at least one first computing task is included in the multiple computing tasks, and the first computing task corresponds to multiple parties;
[0188] Among them, the at least one first computing task includes at least one of the following computing tasks: an encoding computing task, an encryption computing task, a decryption computing task, or a communication computing task.
[0189] The model generation device provided in any of the foregoing embodiments is used to execute the technical solutions of any of the foregoing method embodiments. The implementation principles and technical effects are similar and will not be elaborated here.
[0190] Figure 10 This is a schematic structural diagram of a model generation device provided by an embodiment of the present invention. As Figure 10 shown, the model generation device may include: a memory 101, a processor 102, and a model generation program stored on the memory 101 and executable on the processor 102. When the model generation program is executed by the processor 102, the steps of the model generation method described in any of the foregoing embodiments are implemented.
[0191] Optionally, the memory 101 can be either independent or integrated with the processor 102.
[0192] For the implementation principles and technical effects of the model generation device provided in this embodiment, reference can be made to the foregoing embodiments, which will not be elaborated here.
[0193] An embodiment of the present invention further provides a computer-readable storage medium, on which a model generation program is stored. When the model generation program is executed by a processor, the steps of the model generation method described in any of the foregoing embodiments are implemented.
[0194] In several embodiments provided by the present 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 example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed.
[0195] The integrated modules implemented in the form of software function modules can be stored in a computer-readable storage medium. The above-mentioned software function modules are stored in a storage medium and include several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute some steps of the methods described in various embodiments of the present invention.
[0196] It should be understood that the above-mentioned processor may be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor.
[0197] The memory may include high-speed RAM memory, and may also include non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk, or an optical disc, etc.
[0198] The above storage medium may be implemented by 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 memory, flash memory, a magnetic disk, or an optical disc. The storage medium may be any available medium accessible by a general-purpose or special-purpose computer.
[0199] An exemplary storage medium is coupled to the processor, enabling the processor to read information from the storage medium and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in an Application Specific Integrated Circuit (ASIC). Of course, the processor and the storage medium may also exist as discrete components in an electronic device or a master control device.
[0200] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. Without further limitations, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0201] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0202] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an 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 for causing a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0203] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.
Claims
1. A model generation method, characterized in that, The method includes: Determining at least one participant corresponding to each of the multiple computing tasks, where the multiple computing tasks are computing tasks in federated learning modeling; Obtaining the task code corresponding to each of the computing tasks; Determining the participant corresponding to each task code according to the at least one participant and the task code corresponding to each of the computing tasks; Adding the identifier of the corresponding participant to each task code according to the participant corresponding to each task code, to obtain the updated task code; Determining the model code according to the updated task code; Determining the multiple participants corresponding to the federated learning modeling, where the multiple participants include the at least one participant; Sending the model code to the clients corresponding to the multiple participants, so that the clients corresponding to the multiple participants perform model training according to the model code to generate a first model; Wherein, during the model training, the client corresponding to the participant determines the task code that the participant needs to execute according to the identifier of the participant in the task code, and executes the task code corresponding to the participant in the model code, and the task code corresponding to the participant includes the identifier of the participant.
2. The method according to claim 1, characterized in that The determining the model code according to the updated task code includes: Obtaining the execution order of the multiple computing tasks; Determining the execution order between the updated task codes according to the execution order of the multiple computing tasks; Determining the model code according to the updated task code and the execution order between the updated task codes.
3. The method according to any one of claims 1-2, characterized in that, The obtaining the task code corresponding to each of the computing tasks includes: Obtaining the type of each of the computing tasks, where the type of the computing task is a public type or a non-public type; Obtaining the task code corresponding to each of the computing tasks according to the type of each of the computing tasks.
4. The method according to claim 3, wherein The obtaining the task code corresponding to each of the computing tasks according to the type of each of the computing tasks includes: If the type of the computing task is a public type, obtaining the task code corresponding to the computing task in a preset code library according to the identifier of the computing task; or, If the type of the computing task is a non-public type, receiving the task code corresponding to the computing task through a preset interface.
5. The method according to any one of claims 1-2, characterized in that, The determining at least one participant corresponding to each of the multiple computing tasks includes: Obtaining the function corresponding to each participant; Determining at least one participant corresponding to each of the multiple computing tasks according to the function corresponding to each participant.
6. The method according to any one of claims 1-2, characterized in that, The multiple computing tasks include at least one first computing task, and the first computing task corresponds to multiple participants; Wherein, the at least one first computing task includes at least one of the following computing tasks: encoding computing task, encryption computing task, decryption computing task or communication computing task.
7. A model generation device, characterized in that, The apparatus includes: A determining module, configured to determine at least one participant corresponding to each of the multiple computing tasks, where the multiple computing tasks are computing tasks in federated learning modeling; An obtaining module, configured to obtain the task code corresponding to each of the computing tasks; A processing module, configured to determine a model code according to at least one participant corresponding to each of the computing tasks and the task codes corresponding to each of the computing tasks; A generating module, configured to perform model training according to the model code to generate a first model corresponding to the federated learning modeling; The processing module is specifically configured to: determine the participant corresponding to each task code according to at least one participant and the task code corresponding to each of the computing tasks; add the identifier of the corresponding participant to each task code according to the participant corresponding to each task code to obtain an updated task code; determine the model code according to the updated task code; The generating module is specifically configured to: determine a plurality of participants corresponding to the federated learning modeling, the plurality of participants including the at least one participant; send the model code to the clients corresponding to the plurality of participants, so that the clients corresponding to the plurality of participants perform model training according to the model code to generate a first model; wherein, during the model training, the client corresponding to the participant determines the task code that the participant needs to execute according to the identifier of the participant in the task code, and executes the task code corresponding to the participant in the model code, and the task code corresponding to the participant includes the identifier of the participant.
8. A model generation device, characterized in that, The model generation device includes: a memory, a processor, and a model generation program stored on the memory and executable on the processor, and when the model generation program is executed by the processor, the steps of the model generation method according to any one of claims 1-6 are implemented.
9. A computer-readable storage medium, characterized in that, A model generation program is stored on the computer-readable storage medium, and when the model generation program is executed by a processor, the steps of the model generation method according to any one of claims 1-6 are implemented.
Citation Information
Patent Citations
Method for enhancing defense capability of neural network based on federated learning
CN111860832A
Code reusability
US20190391792A1