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

Tao Fan, Weijing Chen, Yan Kang, Guoqiang Ma, Hanlin Gu, Yuanfeng Song, Lixin Fan, Qiang Yang

TL;DR

FedCoT is a federated learning framework that distills the reasoning capabilities (Chain-of-Thought) of a massive server-side Large Language Model (LLM) into a lightweight client-side Small Language Model (SLM). By using differential privacy to perturb prompts, it allows resource-constrained devices to gain LLM-level performance on complex reasoning tasks without ever exposing raw user data to the server.

What Problem Does This Paper Address?

We are currently in a "size vs. privacy" deadlock in AI. Large Language Models (LLMs) like GPT-4 or LLaMA-3 are brilliant at reasoning but are too massive to run on edge devices like smartphones. Conversely, Small Language Models (SLMs) are fast and efficient but often fail at complex, multi-step reasoning.

The standard solution is Knowledge Distillation (KD)—using the big model to teach the small one. However, traditional KD requires sending raw user data to a central server, creating a massive privacy risk. Existing privacy-preserving methods often rely on a "trusted server" or introduce so much noise that the resulting model becomes useless. The authors of FedCoT ask: How can we give small, local models the "brainpower" of an LLM while keeping user data strictly private?

Methods

The authors introduce FedCoT, a framework that uses Chain-of-Thought (CoT) distillation within a federated setting. The process involves four main stages, as illustrated in the framework overview:

Figure 1: The overview of our proposed FedCoT. The FedCoT comprises four key components: (1) The Prompt Encoder, which perturbs user prompts to ensure privacy; (2) The LLM, generating perturbed rationales based on the perturbed prompts; (3) The Perturbed Rationales Decoder, which decodes the perturbed rationales back into a usable form; (4) The Task-Specific SLM Enhancing via CoT Knowledge Distillation, utilizing both original labeled data and filtered rationales data for multi-task learning.
  1. Privacy-Preserving Encoding: The client doesn't send the raw prompt. Instead, it uses a Prompt Encoder to perturb the text. The paper proposes two strategies:
  2. Exponential Mechanism Strategy (FedCoT-E): Applies a standard token-level differential privacy (DP) mechanism.
  3. Adaptive Exponential Mechanism Strategy (FedCoT-A): Uses a local SLM to adaptively encode prompts, better balancing the trade-off between privacy and the usefulness of the resulting text.
  4. Perturbed Rationale Generation: The server-side LLM receives the noisy prompt and generates a "perturbed rationale"—a step-by-step explanation of how to solve the problem.
  5. Rationale Decoding: The client receives this noisy rationale and uses a local Rationales Decoder to "clean" it, aligning it back to the original, private prompt.
  6. Multi-Task Distillation: Finally, the client trains its task-specific SLM using a multi-task objective: it learns to predict both the correct answer (label) and the step-by-step reasoning (rationale).

Datasets

The framework was evaluated on four popular reasoning and Question Answering (QA) benchmarks:

  • CommonsenseQA (CQA): Testing general knowledge and reasoning.
  • OpenBookQA (OBQA): Requiring multi-step reasoning with external facts.
  • BoolQ: Natural yes/no questions.
  • ArcE (AI2 Reasoning Challenge): Grade-school science questions.

Key Insights and Ideas

  • Rationales are Better Teachers than Labels: Simply teaching an SLM the "right answer" isn't enough. By distilling the reasoning process (the rationales), the SLM learns the logic behind the task, leading to much higher accuracy.
  • Noise is Informative: Surprisingly, even when prompts are heavily perturbed for privacy, the server-side LLM can still generate rationales that contain "distilled wisdom." A local decoder can then recover this logic for the specific private task.
  • Data Efficiency: One of the most striking findings is that FedCoT is highly data-efficient. A model trained with FedCoT on only 50% of a dataset can match or beat a standard local model trained on 100% of the data.
  • Adaptive Privacy Matters: The Adaptive strategy (FedCoT-A) consistently outperformed the standard version, suggesting that treating all words in a prompt as equally sensitive is suboptimal.

Key Results

The authors tested two main settings: distilling LLaMA3-70B into Pythia-1.4B, and Qwen1.5-14B into Qwen1.5-0.5B.

Main results comparing FedCoT against standalone and non-private baselines.
  • Performance Boost: In Setting 1, FedCoT-A outperformed the "Standalone" (local-only training) method by 5.7% on CQA, 4.6% on OBQA, 6.7% on BoolQ, and 6% on ArcE.
  • Privacy vs. Utility: Even with a strict privacy budget ($\epsilon = 3$), FedCoT significantly outperformed few-shot LLM and SLM baselines. As the privacy budget increases (allowing less noise), performance approaches that of "Non-Private" distillation.
  • Versatility: The method proved effective across various SLM architectures, including LLaMA2-1.3B and OPT-1.3B.

Limitations and Future Work

  • LLM Reasoning Ceiling: The performance of the client's SLM is fundamentally capped by the reasoning quality of the server's LLM. If the LLM generates a hallucinated or incorrect rationale, the SLM will learn that error.
  • Architecture Diversity: While the authors tested several models, they acknowledge that extending this to a wider variety of state-of-the-art architectures would further prove the framework's generalizability.
  • Local Compute: Although designed for resource-constrained environments, the multi-task training and local decoding still require more local compute than simple inference, which might be a hurdle for very low-power devices.

Summary updated

BibTeX
@misc{fan2024fedcot,
  author = {Tao Fan and Weijing Chen and Yan Kang and Guoqiang Ma and Hanlin Gu and Yuanfeng Song and Lixin Fan 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