OpenFedLLM: Training Large Language Models on Decentralized Private Data via Federated Learning

Rui Ye, WenHao Wang, Jingyi Chai, Dihan Li, Zexi Li, Yinda Xu, Yaxin Du, Yanfeng Wang, Siheng Chen · DOI

Introduction

As the demand for high-quality training data for Large Language Models (LLMs) continues to surge, researchers warn of an impending "data wall." Projections suggest that high-quality public text data may be exhausted as early as 2026. Paradoxically, vast reserves of high-quality data remain untapped, locked within private silos—such as medical records and financial transactions—due to stringent privacy regulations and proprietary concerns.

Individual organizations often lack the data volume necessary to train state-of-the-art LLMs independently. Federated Learning (FL) offers a promising path forward, enabling multiple entities to collaboratively train a shared model by exchanging model updates (gradients or weights) rather than raw data. However, applying FL to LLMs introduces significant hurdles, including massive computational demands and the complexity of modern training pipelines like instruction tuning and human value alignment.

The OpenFedLLM Framework

To address these challenges, the authors introduce OpenFedLLM, an open-source codebase designed to bridge the gap between the Federated Learning and Natural Language Processing communities. OpenFedLLM provides a flexible and efficient environment for training LLMs on decentralized data.

OpenFedLLM provides a comprehensive framework for federated LLM training, outperforming local training and even GPT-4 in specific domains.

Technical Innovations

OpenFedLLM incorporates several key features to ensure feasibility and performance:

  • Two-Stage Federated Training: The framework supports Federated Instruction Tuning (FedIT) to enhance task-following capabilities and Federated Value Alignment (FedVA) to ensure models remain helpful and harmless.
  • Communication-Efficient Alignment: For value alignment, the framework utilizes Direct Preference Optimization (DPO). Unlike traditional Reinforcement Learning from Human Feedback (RLHF), DPO is a stable, one-step process that is significantly more communication-efficient in distributed settings.
  • Parameter-Efficient Fine-Tuning (PEFT): To accommodate participants with limited hardware, OpenFedLLM leverages LoRA. By training only ~0.06% of the total parameters, a 7B parameter model can be fine-tuned on a single consumer-grade GPU (e.g., NVIDIA 3090).
  • Algorithmic Diversity: The framework integrates seven representative FL algorithms, ranging from the standard FedAvg to advanced methods like SCAFFOLD (addressing client drift) and FedAdam (utilizing server-side momentum).
OpenFedLLM compared to existing federated LLM frameworks across instruction tuning (IT), value alignment (VA), and scale of algorithms/metrics.

Comprehensive Empirical Study

The utility of OpenFedLLM was validated through an extensive empirical study involving 8 training datasets across diverse domains, including general knowledge (Alpaca), finance (FinGPT), medicine (MedAlpaca), code (Code-Alpaca), and mathematics (MathInstruct). Performance was evaluated using over 30 metrics, such as MMLU for knowledge and MT-Bench for conversational ability.

Key Insights and Results

The study yielded several critical findings for the future of decentralized AI:

  1. The Collaborative Advantage: In every experiment, federated learning consistently outperformed "local" training. This demonstrates a clear performance incentive for organizations to participate in federated networks.
  2. Domain-Specific Dominance: In the financial sector, a Llama2-7B model trained via FL significantly outperformed GPT-4 on sentiment analysis tasks. This suggests that collaborative training on niche, high-quality private data is a viable strategy for surpassing general-purpose frontier models in specialized fields.
  3. Algorithm Sensitivity: No single FL algorithm proved superior across all tasks. For instance, SCAFFOLD led in finance, while FedAdagrad was most effective for coding. This underscores the importance of a flexible framework that allows for algorithmic experimentation.
  4. Efficiency and Stability: Utilizing LoRA and 8-bit quantization, training required only 1–2 hours per client for 100 communication rounds. Furthermore, DPO provided the necessary stability for distributed value alignment.

Future Directions

While OpenFedLLM marks a significant step forward, several challenges remain:

  • Data Quality Control: Without visibility into raw data, servers struggle to filter "junk" data or select the most informative samples.
  • Heterogeneous Values: Aligning a global model is difficult when different clients (e.g., hospitals in different countries) hold divergent human values.
  • Security: Detecting "malicious but logically correct" data contributions is significantly harder in a private FL environment than identifying traditional noise-based attacks.

OpenFedLLM provides the foundation for addressing these frontiers, offering a robust toolset for the next generation of private, collaborative AI.

Summary updated

BibTeX
@misc{ye2024openfedllm,
  author = {Rui Ye and WenHao Wang and Jingyi Chai and Dihan Li and Zexi Li and Yinda Xu and Yaxin Du and Yanfeng Wang and Siheng Chen},
  title = {{OpenFedLLM: Training Large Language Models on Decentralized Private Data via Federated Learning}},
  year = {2024},
  eprint = {2402.06954},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.06954},
}
Figure