Add tutorial for federated fine-tuning of language models with Huggin…
Summary
Add a tutorial for fine-tuning a HuggingFace text-classification model (IMDb dataset) using Federated Learning with OpenFL.
Type of Change (Mandatory)
Specify the type of change being made.
- Adding a new tutorial
Description (Mandatory)
This PR introduces a tutorial for performing federated learning on a text classification task using HuggingFace library and the experimental workflow API of OpenFL. It uses the IMDb dataset for binary classification.
The tutorial walks through:
- Installing required dependencies
- Implementing the Federated Averaging (
fed_avg) function - Building the federated workflow (
FLSpec) - Running a local simulation using
LocalRuntime - Setting up a production-ready federated infrastructure
- Deploying and running the same workflow via
FederatedRuntime
Testing
- Executed the full tutorial on a clean environment (Python 3.11)
- Verified local simulation workflow completes successfully
- Verified FederatedRuntime deployment works as intended
- Achieves the metrics below for simulation and deployment modes:
It is shown in the screenshot above that after 2 rounds of federated learning, the aggregated model achieves similar F1 score (~0.6) to the local models.
Thanks for the contribution, @omid-jf! We will take some time to review this and get back to you in the next day or two