Abstract
Amid the ongoing advancements in Federated Learning (FL), a machine learning paradigm that allows collaborative learning with data privacy protection, personalized FL (pFL) has gained significant prominence as a research direction within the FL domain. Whereas traditional FL (tFL) focuses on jointly learning a global model, pFL aims to achieve a balance between the global and personalized objectives of each client in FL settings. To foster the pFL research community, we propose PFLlib, a comprehensive pFL algorithm library with an integrated evaluation platform. In PFLlib, We implement 34 state-of-the-art FL algorithms (including 7 classic tFL algorithms and 27 pFL algorithms) and provide various evaluation environments with three statistically heterogeneous scenarios and 14 datasets. At present, PFLlib has already gained 850 stars and 199 forks on GitHub.
Introduction
Traditional Federated Learning (tFL) aims to train a single global model across multiple decentralized devices while keeping data private. However, real-world data is rarely "Independent and Identically Distributed" (IID). When different users have vastly different data distributions—such as varying languages, photo styles, or health metrics—a one-size-fits-all global model often performs poorly for the entire population.
Personalized Federated Learning (pFL) addresses this by allowing clients to maintain customized local models. Despite the rapid growth of pFL research, the community faces a "reproducibility crisis" characterized by the steep learning curves of industrial platforms, fragmented research scripts, and inconsistent evaluation setups. PFLlib is designed to bridge this gap by providing a unified, beginner-friendly framework for benchmarking.
Methods and Taxonomy
PFLlib is built as a modular framework designed for ease of use and extensibility. It utilizes a "three-file" structure for every algorithm: serverX.py for central aggregation logic, clientX.py for local training, and main.py for hyperparameter management. This architecture allows researchers to implement new algorithms by inheriting from base classes and modifying only the unique logic.
The library categorizes 37 implemented algorithms (8 traditional and 29 personalized) based on their underlying techniques, as shown in the taxonomy below.
Key categories include:
- Meta-learning: Treating personalization as a fast-adaptation problem (e.g., Per-FedAvg).
- Regularization: Adding penalties to keep local models close to the global one (e.g., pFedMe, Ditto).
- Model-splitting: Sharing parts of the model (like feature extractors) while keeping others private (e.g., FedRep, FedBABU).
- Knowledge Distillation: Using teacher-student frameworks to transfer knowledge without sharing weights (e.g., FedProto).
- Personalized Aggregation: Dynamically weighting client contributions (e.g., APFL, FedALA).
Datasets and Heterogeneity
PFLlib incorporates 24 datasets across Computer Vision (MNIST, Cifar100), Natural Language Processing (AG News), and Sensor Signal Processing (HAR, PAMAP2). It supports three critical heterogeneity scenarios:
- Label Skew: Clients possess different classes (e.g., one user only has photos of cats).
- Feature Shift: Clients have the same classes but different visual styles.
- Real-world Scenarios: Naturally distributed datasets like medical images (Camelyon17) and wildlife camera traps (iWildCam).
Beyond accuracy, PFLlib includes a Privacy Evaluation module. It implements the Deep Leakage from Gradients (DLG) attack, allowing researchers to assess whether personalized updates inadvertently leak raw user data.
Key Results
Extensive benchmarking reveals that personalization is essential in non-IID settings. In "Pathological" label skew scenarios, pFL methods significantly outperform traditional approaches.
As seen in the results table, on the Cifar100 dataset under pathological skew, traditional FedAvg achieves only ~26% accuracy, while pFL methods like GPFL and FedDBE reach over 71%. Algorithms such as GPFL, FedCP, and FedALA consistently emerge as top performers across both CV and NLP tasks, demonstrating robustness for general-purpose personalization.
Conclusion
PFLlib lowers the barrier to entry for pFL research through a "one-line command" workflow. While it currently focuses on algorithmic performance, future work will address system-level constraints like battery consumption and network latency. With over 1,600 stars on GitHub, PFLlib has become a foundational resource for the Federated Learning research community.
Summary updated