VITA-Group/DP-OPT

★ 48⑂ 10

[ICLR'24 Spotlight] DP-OPT: Make Large Language Model Your Privacy-Preserving Prompt Engineer

About VITA-Group/DP-OPT

VITA-Group/DP-OPT is an open-source project on GitHub, mainly written in Python. [ICLR'24 Spotlight] DP-OPT: Make Large Language Model Your Privacy-Preserving Prompt Engineer It currently holds 48 stars and 10 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Prompt Engineering board.

GitHub Repository Details

Repository VITA-Group/DP-OPT · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

DP-OPT: Make Large Language Model Your Privacy-Preserving Prompt Engineer ====================================================

License: MIT

Official PyTorch Code for Paper: "DP-OPT: Make Large Language Model Your Privacy-Preserving Prompt Engineer" Junyuan Hong, Jiachen T. Wang, Chenhui Zhang, Zhangheng Li, Bo Li, Zhangyang Wang, ICLR (Spotlight, top-5%) 2024.

paper / code / blog

TL;DR: We proposed the first end-to-end privacy-preserving automatic prompt engineering method.

Overview

featured

Large Language Models (LLMs) have emerged as dominant tools for various tasks, particularly when tailored for a specific target by prompt tuning. Nevertheless, concerns surrounding data privacy present obstacles due to the tuned prompts' dependency on sensitive private information. A practical solution is to host a local LLM and optimize a soft prompt privately using data. Yet, hosting a local model becomes problematic when model ownership is protected. Alternative methods, like sending data to the model’s provider for training, intensify these privacy issues facing an untrusted provider. In this paper, we present a novel solution called Differentially-Private Offsite Prompt Tuning (DP-OPT) to address this challenge. Our approach involves tuning a discrete prompt on the client side and then applying it to the desired cloud models. We demonstrate that prompts suggested by LLMs themselves can be transferred without compromising performance significantly. To ensure that the prompts do not leak private information, we introduce the first private prompt generation mechanism, by a differentially-private (DP) ensemble of in-context learning with private demonstrations. With DP-OPT, generating privacy-preserving prompts by Vicuna-7b can yield competitive performance compared to non-private in-context learning on GPT3.5 or local private prompt tuning.

Get Started

Prepare conda env.

conda create --name dp-opt python=3.8 -y
conda activate dp-opt
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install transformers datasets accelerate sentencepiece scikit-learn wandb autodp

transformers==4.28.1

Prepare DLN datasets

bash setup_data.sh

To use openai models, create openai_config.py in the root folder. This will be only used for evaluation.

import openai

openai.api_key = ""

openai.organization = ""

openai.api_base = "https://api.openai.com/v1" openai_model_types = ['text-davinci-003']
:warning: Warning: Setting echo and logprobs simultaneously is no longer supported for certain OpenAI models.
However, classification inference with openai models requires both settings. Consider to host your own models, e.g., thru vLLM, instead.

Example: Do prompt engineer on website:

pip install gradio
python web_demo.py

open http://127.0.0.1:7860

| Train | Test | | :---- | :--- | | | |

Example: Use local model (lmsys/vicuna-7b-v1.3) to generate a instruction and test the instruction by OpenAI model (text-davinci-003).

# generate a instruction
python train_opt.py --ape_mode=iid_ibwd --ensemble_gen=True --gen_temp=1.1 --num_prompt=40 --max_new_tokens=50 \
--data=sst2 --holdout_ratio=0.01

evaluate the instruction

python eval_opt.py --ape_mode=iid_ibwd --ensemble_gen=True --gen_temp=1.1 --num_prompt=40 --max_new_tokens=50 \ --data=sst2 \ --test_model=text-davinci-003
# generate a instruction
python train_opt.py --ape_mode=iid_ibwd --ensemble_gen=True --gen_temp=1.1 --num_prompt=40 --max_new_tokens=50 \
--data=sst2 --holdout_ratio=0.01 \
--target_eps=8. --dp_eps=1.8 --dp_delta=5e-7 --tokenwise_gen=True

evaluate the instruction

python eval_opt.py --ape_mode=iid_ibwd --ensemble_gen=True --gen_temp=1.1 --num_prompt=40 --max_new_tokens=50 \ --data=sst2 \ --target_eps=8. --dp_eps=1.8 --dp_delta=5e-7 --tokenwise_gen=True \ --test_model=text-davinci-003

Experiments

Wandb sweeps files are under sweeps/<data_name>/.yml. sweeps/<data_name>/.yml is used for tuning prompts. We use sweeps/<data_name>/_test.yml to test prompts on different models.

Supported datasets: sst2, trec, mpqa, disaster.

image

Methods (exmaplified on sst2):

wandb sweep sweeps/sst2/icl.yml
wandb sweep sweeps/sst2/dln1.yml
wandb sweep sweeps/sst2/dln1_test.yml
wandb sweep sweeps/sst2/opt.yml
wandb sweep sweeps/sst2/opt_test.yml
wandb sweep sweeps/sst2/dp-opt.yml
wandb sweep sweeps/sst2/dp-opt_test.yml
----- Part of the codes are based on deep-language-networks.

GitHub Stars & Activity

48Stars
10Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars48
Forks10
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

microsoft / promptflow

Python★ 11,244⑂ 1,123
2

promptslab / Promptify

Python★ 4,635⑂ 364
3
4

hegelai / prompttools

Python★ 3,055⑂ 256
5

Eladlev / AutoPrompt

Python★ 3,019⑂ 264
6

microsoftarchive / promptbench

Python★ 2,821⑂ 222
7

yaojingang / yao-open-prompts

Python★ 2,817⑂ 461
8

YiVal / YiVal

Python★ 2,134⑂ 328

More AI Rankings