FedDTPT: Federated Discrete and Transferable Prompt Tuning for Black-Box Large Language Models

Jiaqi Wu, Simin Chen, Yuzhe Yang, Yijiang Li, Shiyue Hou, Rui Jing, Zehua Wang, Wei Chen, Zijian Tian

Abstract

In recent years, large language models (LLMs) have significantly advanced the field of natural language processing (NLP). By fine-tuning LLMs with data from specific scenarios, these foundation models can better adapt to various downstream tasks. However, the fine-tuning process poses privacy leakage risks, particularly in centralized data processing scenarios. To address user privacy concerns, federated learning (FL) has been introduced to mitigate the risks associated with centralized data collection from multiple sources. Nevertheless, the privacy of LLMs themselves is equally critical, as potential malicious attacks challenge their security, an issue that has received limited attention in current research. Consequently, establishing a trusted multi-party model fine-tuning environment is essential. Additionally, the local deployment of large LLMs incurs significant storage costs and high computational demands. To address these challenges, we propose for the first time a federated discrete and transferable prompt tuning, namely FedDTPT, for black-box large language models. In the client optimization phase, we adopt a token-level discrete prompt optimization method that leverages a feedback loop based on prediction accuracy to drive gradient-free prompt optimization through the MLM API. For server optimization, we employ an attention mechanism based on semantic similarity to filter all local prompt tokens, along with an embedding distance elbow detection and DBSCAN clustering strategy to enhance the filtering process. Experimental results demonstrate that, compared to state-of-the-art methods, our approach achieves higher accuracy, reduced communication overhead, and robustness to non-iid data in a black-box setting. Moreover, the optimized prompts are transferable.

Introduction

Fine-tuning Large Language Models (LLMs) for specific downstream tasks usually requires centralized data, which poses significant privacy risks. While Federated Learning (FL) allows models to be trained on decentralized data, applying it to state-of-the-art LLMs introduces three major hurdles. First is the Black-Box Problem: many models are only accessible via APIs, preventing access to gradients or internal parameters. Second is Resource Constraints: local devices often lack the compute power to host massive models. Finally, there is the issue of Interpretability and Transferability: standard "soft prompt" tuning uses continuous vectors that are model-specific and unreadable to humans.

To address these challenges, we introduce FedDTPT (Federated Discrete and Transferable Prompt Tuning). This framework enables privacy-preserving tuning that produces human-readable prompts usable across different LLM architectures without requiring access to model weights.

Methodology

FedDTPT operates in two distinct phases: client-side discrete optimization and server-side semantic aggregation.

Overview of the FedDTPT framework, illustrating the local client-side discrete prompt optimization and the centralized server-side semantic aggregation.

Client-Side: Discrete Prompt Instruction Tuning

Since clients cannot use gradients in a black-box setting, they treat prompt tuning as a discrete optimization problem. A feedback loop is established where the client sends a prompt to the LLM API and receives a textual prediction. By comparing this to the local label, accuracy is calculated. This accuracy and the current prompt are then fed into a Masked Language Model (MLM) API (e.g., BERT), which acts as a generator to suggest token-level modifications to the prompt. This creates a closed-loop system where the prompt evolves based on direct performance feedback.

Server-Side: Semantic Instruction Aggregation

Aggregating discrete tokens is more complex than averaging numerical weights. The server must merge different word suggestions from multiple clients into a single "global" prompt. The server maps suggested tokens into a high-dimensional latent space using an MLM and employs an attention mechanism based on semantic similarity to identify representative tokens. To filter noise, the server uses DBSCAN clustering and an "elbow detection" strategy to determine the optimal number of clusters, ensuring the final global prompt is semantically coherent.

Experimental Results

We evaluated FedDTPT using two backbone models—DeepSeek-V2-Lite (15B) and Llama-3.1-8B-Instruct—across seven datasets from the GLUE benchmark, including SST-2, RTE, and QNLI.

Performance comparison of FedDTPT against state-of-the-art white-box and black-box methods across GLUE benchmark tasks.

Key Findings

  • Superior Accuracy: In black-box settings, FedDTPT outperformed baselines significantly. On the DeepSeek model, it achieved an average accuracy of 95.33%, compared to 88.81% for manual prompting and 53.82% for FedAvg-BBT.
  • Cross-Model Transferability: Because the output is a sequence of words, the prompts are transferable. Prompts trained on DeepSeek and transferred to Llama-3 (and vice versa) maintained high accuracy, often outperforming manual prompts designed specifically for the target model.
  • Efficiency through Sparsity: FedDTPT requires tuning only 150 parameters (discrete tokens), compared to hundreds of thousands in "white-box" federated methods. This drastically reduces communication overhead, making it viable for low-bandwidth environments.

Conclusion

FedDTPT demonstrates that discrete prompt tuning is a powerful path forward for federated learning with black-box LLMs. By focusing on human-readable tokens rather than continuous vectors, the method bypasses gradient requirements and ensures high transferability across different model architectures. Future work will explore scaling this discrete optimization to complex generative tasks and reducing the dependency on auxiliary public data for local tuning.

Summary updated

BibTeX
@misc{wu2024feddtpt,
  author = {Jiaqi Wu and Simin Chen and Yuzhe Yang and Yijiang Li and Shiyue Hou and Rui Jing and Zehua Wang and Wei Chen and Zijian Tian},
  title = {{FedDTPT: Federated Discrete and Transferable Prompt Tuning for Black-Box Large Language Models}},
  year = {2024},
  eprint = {2411.00985},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.00985},
}
Figure