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

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. We propose two privacy protection strategies: the Exponential Mechanism Strategy and the Adaptive Exponential Mechanism Strategy, which balance user prompt privacy and the usability of rationales. Empirical evaluation on various text generation tasks demonstrates the effectiveness of FedCoT in training task-specific SLMs with enhanced performance while prioritizing data privacy protection.

Introduction

We are currently facing a "size vs. privacy" deadlock in the deployment of artificial intelligence. Giant models like LLaMA-3 70B possess incredible reasoning capabilities, often elicited via Chain-of-Thought (CoT) prompting, but they are too massive to run on edge devices. Conversely, Small Language Models (SLMs) are fast and private but frequently lack the logical depth required for complex tasks.

While knowledge distillation—using a large model to teach a smaller one—is a standard solution, it typically requires sending raw, private user data to a powerful server. FedCoT (Federated Chain-of-Thought) breaks this deadlock. It is a new federated framework that allows resource-constrained devices to "borrow" the reasoning power of server-side LLMs without sacrificing user privacy. By using differential privacy to perturb prompts and a specialized decoder to recover reasoning "rationales," FedCoT trains small, task-specific models that significantly outperform standard fine-tuning.

Methodology: The FedCoT Pipeline

FedCoT operates through a four-step "Perturb-Generate-Decode-Train" pipeline designed to maintain privacy while maximizing knowledge transfer:

  1. Privacy-Preserving Encoding: Instead of sending a raw prompt, the client uses an Exponential Mechanism to perturb tokens. This adds mathematical noise (Differential Privacy) so the server cannot reconstruct the original sensitive input.
  2. Server-Side Generation: The server-side LLM receives the noisy prompt and generates a "perturbed rationale"—a step-by-step reasoning path based on the obfuscated input.
  3. Rationale Decoding: The client receives this noisy reasoning. Utilizing a local Encoder-Decoder SLM, the client "cleans" and aligns the server's reasoning back to the original, private prompt.
  4. Multi-Task Distillation: Finally, the client trains its task-specific SLM using two signals: the actual answer labels and the recovered, high-quality rationales.
The FedCoT framework (left) and a concrete example of the prompt perturbation and rationale decoding process (right).

The framework introduces two protection strategies: FedCoT-E (standard exponential mechanism) and FedCoT-A (an Adaptive version that better balances the trade-off between privacy and the usability of the generated text).

Experimental Evaluation

The framework was evaluated on four popular Question Answering (QA) benchmarks requiring complex reasoning: CommonsenseQA (CQA), OpenBookQA (OBQA), BoolQ, and ArcE (ARC-Easy). The researchers tested two primary settings:

  • Setting 1: LLaMA3-70B (Server) teaching Pythia-1.4B (Client).
  • Setting 2: Qwen1.5-14B (Server) teaching Qwen1.5-0.5B (Client).

Key Results and Insights

Empirical results demonstrate that FedCoT consistently outperforms standalone fine-tuning across all benchmarks. In Setting 1, FedCoT-A improved performance over standalone models by 5.7% on CQA and 6.7% on BoolQ.

Performance comparison showing that FedCoT methods (E and A) consistently outperform standalone fine-tuning across different model settings and datasets.

Several key insights emerged from the study:

  • Rationales as Guidance: SLMs benefit significantly from seeing the "work" (the reasoning steps) rather than just the final answer. Distilling the logic allows the SLM to internalize the underlying task structure.
  • Privacy-Utility Balance: Even with strict privacy budgets, the Adaptive mechanism (FedCoT-A) produced rationales highly similar to the original ones, suggesting LLMs are robust enough to provide useful reasoning even when inputs are slightly obfuscated.
  • Data Efficiency: Remarkably, FedCoT-trained models using only 50% of the training data could match or beat standard models trained on 100% of the data, highlighting the high value of reasoning-based distillation.

Conclusion

FedCoT successfully addresses the challenge of distilling reasoning from massive, private LLMs into local SLMs. While the framework currently depends on the reasoning quality of the server-side teacher and requires local computational overhead for the encoder-decoder step, it represents a significant step toward private, efficient, and high-performing AI on edge devices. Future work will explore expanding this framework to even more diverse text generation tasks beyond question answering.

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