Coder Social home page Coder Social logo

yyy01 / pac Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 0.0 215 KB

The official implementation of the paper "Data Contamination Calibration for Black-box LLMs" (ACL 2024)

License: MIT License

Python 100.00%
ai-safety data-contamination large-language-models membership-inference-attack nlp machine-learning

pac's Introduction

Data Contamination Calibration for Black-box LLMs

Wentao Ye1,   Jiaqi Hu1,   Liyao Li1,   Haobo Wang1,   Gang Chen1,   Junbo Zhao1

1Zhejiang University

Paper | StackMIA Dataset | StackMIAsub Benchmark | Polarized Augment Calibration Method (i.e. the following repo)

News 🔥

  • [2024/05/21] We release our paper on Arxiv.
  • [2024/05/19] We release our code and benchmark.
  • [2024/05/16] Our paper is accepted by ACL 2024! 🎉

Overview

The rapid advancements of Large Language Models tightly associate with the expansion of the training data size. However, the unchecked ultra-large-scale training sets introduce a series of potential risks like data contamination. To trackle this challenge, we propose a holistic method named Polarized Augment Calibration (PAC) along with a brand-new dataset named StackMIA to detect the contaminated data and diminish the contamination effect. Remarkably, PAC is plug-and-play that can be integrated with most current white- and black-box models.

StackMIAsub benchmark

The StakcMIAsub dataset serves as a benchmark, which supports most white- and black-box models, to evaluate membership inference attack (MIA) methods:

  • Black-box OpenAI models:
    • Davinci-002
    • Baggage-002
    • ...
  • White-box models:
    • LLaMA and LLaMA2
    • Pythia
    • OPT
    • ...

Access our Hugging Face repo for more details.

Detect data contamination with PAC

Data preparation

📌 Please ensure the data to be detected is formatted as a jsonlines file in the following manner:

{"snippet": "SNIPPET1", "label": 1 or 0}
{"snippet": "SNIPPET2", "label": 1 or 0}
...
  • label is an optional field for labeled detection.
  • label 1 denotes to members, while label 0 denotes to non-members.

Run PAC using black-box OpenAI models

Set your API key and target model engine to run PAC on OpenAI models (increase num_threads for batch processing):

python attack.py --dataset_path "DATASET_PATH" --api_key "YOUR_API_KEY" --model_engine "TARGET_MODEL_ENGINE" 

Note: the extra probabilistic tracking step will be performed for GPT-3.5 and GPT-4 models.

Run PAC using white-box models

Use the following command to run PAC on local white box models:

python attack.py --dataset_path "DATASET_PATH" --model_path "MODEL_PATH"

Acknowledgement

Thanks for the following repos:

Cite our work

⭐️ If you find our implementation and paper helpful, please kindly cite our work :

@misc{ye2024data,
      title={Data Contamination Calibration for Black-box LLMs}, 
      author={Wentao Ye and Jiaqi Hu and Liyao Li and Haobo Wang and Gang Chen and Junbo Zhao},
      year={2024},
      eprint={2405.11930},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

pac's People

Contributors

yyy01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.