Authored by Ivan Kaštelan, Miroslav Popović (University of Novi Sad, Faculty of Technical Sciences)

Within the vast number of federated learning frameworks, developers for embedded systems may have a hard time finding a framework that will work for their target device since many frameworks require specific OSs, hardware requirements, and numerous dependencies. This is where PTB-FLA (Python Test Bed for Federated Learning Algorithms), developed within the TaRDIS project, comes to the rescue, as it provides a development and test environment for the development of federated learning algorithms that is lightweight and easy to install.

Thanks to its simple API, PTB-FLA is easy to use even by nonprofessional programmers. To guide the development, we have proposed a 4-step development paradigm consisting of the following steps: 1) write the referent sequential code, 2) refactor the code into the federated sequential code, 3) write the callback functions for the federated sequential code, 4) transform the federated sequential code with callback functions into the PTB-FLA code.

ChatGPT Helps Humans Creating Federated Learning Apps on PTB-FLA
ChatGPT Helps Humans Creating Federated Learning Apps on PTB-FLA

To further facilitate easier development, developers can use ChatGPT to efficiently develop code for PTB-FLA and shift the focus to the actual algorithm design and making more intelligent neural networks, without spending a lot of time on implementing their solution for PTB-FLA. This is done in three steps: 1) specify the context, 2) ask ChatGPT to complete the server and clients’ callback functions, and 3) verify the generated code.

As an example, taken from [1], let’s look at a classic federated learning example of Federated Map. After several attempts, researchers constructed a minimal context for ChatGPT, which consisted of a short introduction to PTB-FLA and the sequential federated learning code with some comments. From ChatGPT answers, researchers realised that having a lot of redundant information in the introduction and a lot of unnecessary comments is not useful, although some comments, such as “This is the code executed by the server” turned out to be crucial for ChatGPT to solve this problem.

Researchers asked the ChatGPT to rate this assignment and received the difficulty rating of 7 (out of 10). The most important part of the context was the API documentation, understanding how the callback functions work and their purpose, as ChatGPT responded: “The most important part of the context was the PTB-FLA API documentation. It provided the necessary information about the functions and their parameters, as well as the expected return values. Understanding how the fl_centralized function works, and the purpose of the callback functions was crucial to completing the assignment.

ChatGPT can help developers reduce development time for PTB-FLA implementation of their federated learning algorithm solutions. To learn more about PTB-FLA, you may refer to the published papers [2] and [3]. More details about the examples of using ChatGPT can be found in the paper [1].

Take a look at PTB-FLA GitHub repository at [4].


[1] M. Popovic, M. Popovic, I. Kastelan, M. Djukic and I. Basicevic, “Developing Elementary Federated Learning Algorithms Leveraging the ChatGPT,” 2023 31st Telecommunications Forum (TELFOR), Belgrade, Serbia, 2023, pp. 1-4, doi: 10.1109/TELFOR59449.2023.10372714

[2] M. Popovic, M. Popovic, I. Kastelan, M. Djukic and S. Ghilezan, “A Simple Python Testbed for Federated Learning Algorithms,” 2023 Zooming Innovation in Consumer Technologies Conference (ZINC), Novi Sad, Serbia, 2023, pp. 148-153, doi: 10.1109/ZINC58345.2023.10173859

[3] Popovic, M., Popovic, M., Kastelan, I., Djukic, M., Basicevic, I. (2024). A Federated Learning Algorithms Development Paradigm. In: Kofroň, J., Margaria, T., Seceleanu, C. (eds) Engineering of Computer-Based Systems. ECBS 2023. Lecture Notes in Computer Science, vol 14390. Springer, Cham. https://doi.org/10.1007/978-3-031-49252-5_4

[4] PTB-FLA GitHub repository, https://github.com/miroslav-popovic/ptbfla