Skip to content

Conversation

omid-jf
Copy link

@omid-jf omid-jf commented Jun 9, 2025

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:

image

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.

@psfoley
Copy link
Contributor

psfoley commented Jun 10, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants