Skip to main content

PromptBench is a powerful tool designed to scrutinize and analyze the interaction of large language models with various prompts. It provides a convenient infrastructure to simulate **black-box** adversarial **prompt attacks** on the models and evaluate their performances.

Project description

Contributors Forks Stargazers Issues


Logo

PromptBench: A Unified Library for Evaluating and Understanding Large Language Models.
Papers · Docs · Leaderboard

Table of Contents
  1. News and Updates
  2. Introduction
  3. Installation
  4. Usage
  5. Datasets and Models
  6. Benchmark Results
  7. Acknowledgments

News and Updates

  • [05/12/2023] Published promptbench 0.0.1.

Introduction

PromptBench is a Pytorch-based Python package for Evaluation of Large Language Models (LLMs). It provides user-friendly APIs for researchers to conduct evaluation on LLMs.

Code Structure

What does promptbench currently provide?

  1. Quick model performance assessment: We offer a user-friendly interface that allows for quick model building, dataset loading, and evaluation of model performance.
  2. Prompt Engineering: We implemented several prompt engineering methods. For example: Few-shot Chain-of-Thought [1], Emotion Prompt [2], Expert Prompting [3] and so on.
  3. Evaluating adversarial prompts: promptbench integrated prompt attacks [4], enabling researchers to simulate black-box adversarial prompt attacks on models and evaluate their robustness.
  4. Dynamic evaluation to mitigate potential test data contamination: we integrated the dynamic evaluation framework DyVal [5], which generates evaluation samples on-the-fly with controlled complexity.

Installation

Install via pip

We provide a Python package promptbench for users who want to start evaluation quickly. Simply run

pip install promptbench

Install via github

First, clone the repo:

git clone git@github.com:microsoft/promptbench.git

Then,

cd promptbench

To install the required packages, you can create a conda environment:

conda create --name promptbench python=3.9

then use pip to install required packages:

pip install -r requirements.txt

Note that this only installed basic python packages. For Prompt Attacks, it requires to install textattacks.

Usage

promptbench is easy to use and extend. Going through the bellowing examples will help you familiar with promptbench for quick use, evaluate an existing datasets and LLMs, or creating your own datasets and models.

Please see Installation to install promptbench first. We provide ipynb tutorials for:

  1. evaluate models on existing benchmarks: please refer to the examples/basic.ipynb for constructing your evaluation pipeline.
  2. test the effects of different prompting techniques:
  3. examine the robustness for prompt attacks, please refer to examples/prompt_attack.ipynb to construct the attacks.
  4. use DyVal for evaluation: please refer to examples/dyval.ipynb to construct DyVal datasets.

Supported Datasets and Models

Datasets

We support a range of datasets to facilitate comprehensive analysis, including:

  • GLUE: SST-2, CoLA, QQP, MRPC, MNLI, QNLI, RTE, WNLI
  • MMLU
  • SQuAD V2
  • IWSLT 2017
  • UN Multi
  • Math
  • Bool Logic (BigBench)
  • Valid Parentheses (BigBench)
  • Object Tracking (BigBench)
  • Date (BigBench)
  • GSM8K
  • CSQA (CommonSense QA)
  • Numersense
  • QASC
  • Last Letter Concatenate

Models

  • google/flan-t5-large
  • databricks/dolly-v1-6b
  • llama2 (7b, 13b, 7b-chat, 13b-chat)
  • vicuna-13b, vicuna-13b-v1.3
  • cerebras/Cerebras-GPT-13B
  • EleutherAI/gpt-neox-20b
  • google/flan-ul2
  • palm
  • chatgpt, gpt4

Benchmark Results

Please refer to our benchmark website for benchmark results on Prompt Attacks, Prompt Engineering and Dynamic Evaluation DyVal.

TODO

  • [] Add prompt attacks and prompt engineering documents.
  • [] Add detailed instructions for users to add new models and datasets.

Acknowledgements

  • textattacks
  • README Template
  • We thank the volunteers: Hanyuan Zhang, Lingrui Li, Yating Zhou for conducting the semantic preserving experiment in Prompt Attack benchmark.

Reference

[1] Jason Wei, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." arXiv preprint arXiv:2201.11903 (2022).

[2] Cheng Li, et al. "Emotionprompt: Leveraging psychology for large language models enhancement via emotional stimulus." arXiv preprint arXiv:2307.11760 (2023).

[3] BenFeng Xu, et al. "ExpertPrompting: Instructing Large Language Models to be Distinguished Experts" arXiv preprint arXiv:2305.14688 (2023).

[4] Zhu, Kaijie, et al. "PromptBench: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts." arXiv preprint arXiv:2306.04528 (2023).

[5] Zhu, Kaijie, et al. "DyVal: Graph-informed Dynamic Evaluation of Large Language Models." arXiv preprint arXiv:2309.17167 (2023).

Citing promptbench and other research papers

Please cite us if you fine this project helpful for your project/paper:

@article{zhu2023promptbench,
  title={PromptBench: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts},
  author={Zhu, Kaijie and Wang, Jindong and Zhou, Jiaheng and Wang, Zichen and Chen, Hao and Wang, Yidong and Yang, Linyi and Ye, Wei and Gong, Neil Zhenqiang and Zhang, Yue and others},
  journal={arXiv preprint arXiv:2306.04528},
  year={2023}
}

@article{zhu2023dyval,
  title={DyVal: Graph-informed Dynamic Evaluation of Large Language Models},
  author={Zhu, Kaijie and Chen, Jiaao and Wang, Jindong and Gong, Neil Zhenqiang and Yang, Diyi and Xie, Xing},
  journal={arXiv preprint arXiv:2309.17167},
  year={2023}
}

@article{chang2023survey,
  title={A survey on evaluation of large language models},
  author={Chang, Yupeng and Wang, Xu and Wang, Jindong and Wu, Yuan and Zhu, Kaijie and Chen, Hao and Yang, Linyi and Yi, Xiaoyuan and Wang, Cunxiang and Wang, Yidong and others},
  journal={arXiv preprint arXiv:2307.03109},
  year={2023}
}

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

If you have a suggestion that would make promptbench better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the project
  2. Create your branch (git checkout -b your_name/your_branch)
  3. Commit your changes (git commit -m 'Add some features')
  4. Push to the branch (git push origin your_name/your_branch)
  5. Open a Pull Request

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptbench-0.0.1.tar.gz (109.3 kB view details)

Uploaded Source

Built Distribution

promptbench-0.0.1-py3-none-any.whl (118.0 kB view details)

Uploaded Python 3

File details

Details for the file promptbench-0.0.1.tar.gz.

File metadata

  • Download URL: promptbench-0.0.1.tar.gz
  • Upload date:
  • Size: 109.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for promptbench-0.0.1.tar.gz
Algorithm Hash digest
SHA256 003aae7d8894eecfc69a37b1c5655a375be6fbaec56e28f46ed8f664ca07ea36
MD5 ca6afa958c478e48069813d6151d71b1
BLAKE2b-256 f954146c7c5134620d76ed6440bfda70787d88debbcf5693e8609cf5475f363d

See more details on using hashes here.

File details

Details for the file promptbench-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: promptbench-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 118.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for promptbench-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80348fa0828cd21026dd2f2e94ea3c7e4b047646250a74dd28e6599f491c31c9
MD5 358dfb0276bd3e8319db5340390a103a
BLAKE2b-256 66cf3d501049699781a674919f9b59858901014f9f436975e915bf6e3e31c1d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page