Federated Learning using Hugging Face and Flower
Federated fine-tuning of a pre-trained distilBERT model for IMDB sentiment classification uses Flower to coordinate multiple clients and a server, so raw data never leaves the clients. The walkthrough covers loading and tokenizing IMDB with Hugging Face datasets, standard PyTorch train/test loops, a Flower NumPyClient that exchanges model state_dict parameters, and a server running the FedAvg strategy with weighted metric aggregation over three rounds. A Colab notebook variant uses Flower's simulation mode (start_simulation) instead of separate client processes.
Related posts
- The Partnership: Amazon SageMaker and Hugging Face
Hugging Face mediumAdeptHugging Face and AWS partner, making AWS Hugging Face's preferred cloud and introducing Hugging Face Deep Learning Containers plus a HuggingFace Estimator in the SageMaker Python SDK for training Transformers models. An end-to-end walkthrough fine-tunes DistilBERT on IMDB binary sentiment classification: setting up a SageMaker session and IAM role, writing a Trainer-based train.py that reads SageMaker environment variables, tokenizing and uploading datasets to S3, and launching a training job with estimator.fit(). The containers also support SageMaker's data-parallel and model-parallel distributed training libraries through a distribution parameter, along with automatic hyperparameter tuning.
- Applying federated learning to protect data on mobile devices
Meta Engineering easyNoviceMeta is evaluating federated learning with differential privacy (FL-DP), which trains models on mobile devices and adds noise to updates before they reach a global model so user data stays local and is harder to memorize or reconstruct. Because data isn't visible centrally, FL-DP complicates label balancing, feature normalization and metrics, and it brings slower mobile release cycles, slower training and a need for anonymized logging. Meta's architecture combines mobile devices, trusted execution environments and back-end servers so models can use both server-side data and device-only data. In tests with an in-house FL library, it showed minimal accuracy loss versus server-trained models, though model iteration remains orders of magnitude slower than centralized ML.
- Data-Centric Machine Learning: Building Shopify Inbox’s Message Classification Model
Shopify Engineering mediumAdeptShopify Inbox's message classifier improved from ~70% to ~90% accuracy, and from ~35% to ~80% high-confidence coverage, by investing in better training data rather than model tweaks. The v1 prototype used Universal Sentence Encoder embeddings with UMAP/HDBSCAN clustering and semi-supervised labeling on 40,000 examples. For v2, the team fine-tuned DistilBERT on 20,000 human-labeled messages. Those labels came from a 45-topic taxonomy built with support advisors and domain experts, refined through inter-annotator agreement exercises, and scrubbed of personal information with Presidio and Faker. Model predictions were then used to surface underrepresented topics for further annotation.
- My Journey to a serverless transformers pipeline on Google Cloud
Hugging Face mediumAdeptA Hugging Face transformers sentiment-analysis pipeline (DistilBERT fine-tuned on SST-2) was deployed as a low-traffic microservice on Google Cloud Run after AI Platform Prediction (beta instability, checkpoint not a pure TensorFlow model) and App Engine (TensorFlow install failure, PyTorch handling only 2 requests per instance) fell short. The final setup is a Flask app served by gunicorn with one worker and one thread in a Docker image, with Cloud Run memory raised to 4 GB because the model needs most of it. Requests take under five seconds including model loading, plus roughly 10 seconds on cold start; loading the model at startup instead of per request would cut both latency and memory. The image is about 1 GB (PyTorch ~700 MB, model ~250 MB), so storage costs roughly €0.10 per GB per month on top of request costs.
- Opinion Classification with Kili and HuggingFace AutoTrain
Hugging Face mediumAdeptKili's annotation platform and Hugging Face AutoTrain combine into an active-learning pipeline that classifies about 40,000 Google Play reviews of the Medium app into Subscription, Content, Interface and User Experience, then applies sentiment analysis to the classified reviews. The walkthrough covers creating a Kili labeling project through the web UI and the Python API, uploading data in batches of at most 100, and flagging changed samples between dataset versions for re-review. It then exports the labels to CSV and trains a model with AutoTrain and a second one without it.