FedCoT: Federated Chain-of-Thought Distillation for Large Language Models

Tao Fan, Yan Kang, Weijing Chen, Hanlin Gu, Yuanfeng Song, Lixin Fan, Kai Chen, Qiang Yang · DOI

Abstract

Large Language Models (LLMs) have emerged as a transformative force in artificial intelligence, demonstrating exceptional proficiency across various tasks. However, their deployment in resource-constrained environments and concerns over user data privacy pose significant challenges. In contrast, Small Language Models (SLMs) offer computational efficiency but often lag in performance. To address these issues, we propose FedCoT, a federated framework designed for the Chain-of-Thought (CoT) distillation of knowledge from LLMs to SLMs, while ensuring the preservation of clients' data privacy. FedCoT ensures secure and efficient knowledge transfer from an LLM on a high-powered server to an SLM on a resource-constrained client, while adhering to privacy requirements. Leveraging perturbed prompts and rationales generated through the CoT approach, the framework enhances the performance of the client's SLM without compromising user data privacy within a multi-task learning framework.

Introduction: The Size and Privacy Paradox

We are currently witnessing a "size paradox" in artificial intelligence. Large Language Models (LLMs) like LLaMA3-70B exhibit remarkable reasoning capabilities but are prohibitively expensive to deploy on edge devices. Conversely, Small Language Models (SLMs) are efficient and can run locally, but they often lack the complex "Chain-of-Thought" (CoT) reasoning that makes their larger counterparts so powerful.

Knowledge Distillation—using a large model to teach a smaller one—is a logical solution. However, standard distillation methods require users to send raw, private data to a central server to generate high-quality rationales. In sensitive domains like healthcare or finance, this exposure is unacceptable. FedCoT addresses this by asking: How can we transfer reasoning prowess from LLMs to SLMs without ever exposing raw user data?

The FedCoT Framework

FedCoT operates through a four-step cycle designed to bridge the gap between server-side intelligence and client-side privacy:

  1. Privacy-Preserving Encoding: The client uses a Prompt Encoder to perturb raw text (e.g., "A person broke up with me"). By swapping tokens using Differential Privacy (DP) principles, it creates a "noisy" version that obscures the original meaning from humans while retaining structural utility for the LLM.
  2. Rationale Generation: The server-side LLM receives this noisy prompt and generates a "perturbed rationale" using CoT prompting.
  3. Rationale Decoding: The client receives the noisy rationale and uses a local Rationales Decoder to reconstruct it into a clean explanation aligned with the original private prompt.
  4. Task-Specific Enhancement: The client trains its local SLM using both original labels and these reconstructed rationales in a multi-task learning setup.
The FedCoT framework architecture and an example of the prompt perturbation and decoding process.

The framework supports two privacy strategies: the Exponential Mechanism Strategy (EMS), a standard DP approach, and the Adaptive Exponential Mechanism Strategy (AEMS), which uses an SLM to identify and protect the most sensitive tokens more effectively.

Experimental Setup

The framework was evaluated across four reasoning and Question-Answering (QA) benchmarks: CommonsenseQA (CQA), OpenBookQA (OBQA), BoolQ, and ArcE. The experiments utilized LLaMA3-70B and Qwen1.5-14B as teacher models, with Pythia-1.4B and Qwen1.5-0.5B as student models.

Results and Discussion

Empirical results demonstrate that FedCoT consistently outperforms "Standalone" models—SLMs trained only on local data without LLM assistance.

Performance comparison of FedCoT against various baselines across two experimental settings and four datasets.

Key Insights

  • LLM Robustness to Noise: A critical discovery is that LLMs can generate useful reasoning even from garbled inputs. Even when a prompt is perturbed for privacy, the LLM provides a rationale that can be successfully decoded to aid SLM learning.
  • Performance and Efficiency: In Setting 1, the adaptive version (FedCoT-A) improved performance by 4.6% to 6.7% over standalone models. Furthermore, FedCoT-trained SLMs using only 50% of the data often outperformed standalone models trained on 100% of the data.
  • Privacy-Utility Balance: Even under strict privacy budgets ($\epsilon=1$), the framework provided significant gains, proving that data protection does not necessitate a total loss of model intelligence.

Conclusion and Future Work

FedCoT successfully distills reasoning capabilities into small models while maintaining strict privacy boundaries. While the framework is currently dependent on the quality of the teacher LLM and introduces some communication overhead, it represents a significant step toward private, intelligent edge AI. Future research will explore generalizability across more diverse model architectures and further optimize communication efficiency.

Summary updated

BibTeX
@misc{fan2024fedcot,
  author = {Tao Fan and Yan Kang and Weijing Chen and Hanlin Gu and Yuanfeng Song and Lixin Fan and Kai Chen and Qiang Yang},
  title = {{FedCoT: Federated Chain-of-Thought Distillation for Large Language Models}},
  year = {2024},
  eprint = {2406.12403},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.12403},
}
Figure