{"id":13465355,"url":"https://github.com/microsoft/promptbench","last_synced_at":"2025-05-13T19:10:29.640Z","repository":{"id":175009324,"uuid":"653171718","full_name":"microsoft/promptbench","owner":"microsoft","description":"A unified evaluation framework for large language models","archived":false,"fork":false,"pushed_at":"2025-04-29T16:09:47.000Z","size":5833,"stargazers_count":2606,"open_issues_count":5,"forks_count":190,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-07T23:47:33.580Z","etag":null,"topics":["adversarial-attacks","benchmark","chatgpt","evaluation","large-language-models","prompt","prompt-engineering","robustness"],"latest_commit_sha":null,"homepage":"http://aka.ms/promptbench","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-06-13T14:32:34.000Z","updated_at":"2025-05-06T21:51:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"c577a13d-4423-4660-af3c-f7b4782c27c7","html_url":"https://github.com/microsoft/promptbench","commit_stats":{"total_commits":209,"total_committers":17,"mean_commits":"12.294117647058824","dds":0.5358851674641149,"last_synced_commit":"fcda538bd779ad11612818e0645a387a462b5c3b"},"previous_names":["microsoft/promptbench"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpromptbench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpromptbench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpromptbench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpromptbench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/promptbench/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010823,"owners_count":21998993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adversarial-attacks","benchmark","chatgpt","evaluation","large-language-models","prompt","prompt-engineering","robustness"],"created_at":"2024-07-31T15:00:28.162Z","updated_at":"2025-05-13T19:10:29.607Z","avatar_url":"https://github.com/microsoft.png","language":"Python","readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\u003c!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag \"enhancement\".\n*** Don't forget to give the project a star!\n*** Thanks again! Now go create something AMAZING! :D\n--\u003e\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\n\u003c!--\n*** I'm using markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n--\u003e\n\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n\u003c!-- \n***[![MIT License][license-shield]][license-url]\n--\u003e\n\n\u003c!-- PROJECT LOGO --\u003e\n\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/microsoft/promptbench\"\u003e\n    \u003cimg src=\"imgs/promptbench_logo.png\" alt=\"Logo\" width=\"300\"\u003e\n  \u003c/a\u003e\n\n\u003c!-- \u003ch3 align=\"center\"\u003eUSB\u003c/h3\u003e --\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003ePromptBench\u003c/strong\u003e: A Unified Library for Evaluating and Understanding Large Language Models.\n    \u003c!-- \u003cbr /\u003e\n    \u003ca href=\"https://github.com/microsoft/promptbench\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e --\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://arxiv.org/abs/2312.07910\"\u003ePaper\u003c/a\u003e\n    ·\n    \u003ca href=\"https://promptbench.readthedocs.io/en/latest/\"\u003eDocumentation\u003c/a\u003e\n    ·\n    \u003ca href=\"https://llm-eval.github.io/pages/leaderboard.html\"\u003eLeaderboard\u003c/a\u003e\n    ·\n    \u003ca href=\"https://llm-eval.github.io/pages/papers.html\"\u003eMore papers\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#news-and-updates\"\u003eNews and Updates\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#introduction\"\u003eIntroduction\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#supported-datasets-and-models\"\u003eDatasets and Models\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#benchmark-results\"\u003eBenchmark Results\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgments\"\u003eAcknowledgments\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003c!-- News and Updates --\u003e\n\n## News and Updates\n- [19/08/2024] Add [DyVal 2 (ICML 2024)](https://openreview.net/pdf?id=DwTgy1hXXo). \n- [19/08/2024] Merge [PromptEval](https://github.com/felipemaiapolo/prompteval), an efficient multi-prompt evaluation method, into this repository. \n- [26/05/2024] Add support for GPT-4o.\n- [13/03/2024] Add support for multi-modal models and datasets.\n- [05/01/2024] Add support for BigBench Hard, DROP, ARC datasets.\n- [16/12/2023] Add support for Gemini, Mistral, Mixtral, Baichuan, Yi models.\n- [15/12/2023] Add detailed instructions for users to add new modules (models, datasets, etc.) [examples/add_new_modules.md](examples/add_new_modules.md). \n- [05/12/2023] Published promptbench 0.0.1.\n\n\u003c!-- Introduction --\u003e\n\n## Introduction\n\n**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. Check the technical report: https://arxiv.org/abs/2312.07910.\n\n![Code Structure](https://files.catbox.moe/0kw21g.png)\n\n\n\n### What does promptbench currently provide?\n1. **Quick model performance assessment:** We offer a user-friendly interface that allows for quick model building, dataset loading, and evaluation of model performance.\n2. **Prompt Engineering:** We implemented several prompt engineering methods. For example: [Few-shot Chain-of-Thought](https://arxiv.org/abs/2201.11903) [1],  [Emotion Prompt](https://arxiv.org/abs/2307.11760) [2], [Expert Prompting](https://arxiv.org/abs/2305.14688) [3] and so on.\n3. **Evaluating adversarial prompts:** promptbench integrated [prompt attacks](https://arxiv.org/abs/2306.04528) [4], enabling researchers to simulate black-box adversarial prompt attacks on models and evaluate their robustness (see details [here](promptbench/prompt_attack/README.md)).\n4. **Dynamic evaluation to mitigate potential test data contamination:** we integrated the dynamic evaluation framework [DyVal](https://arxiv.org/pdf/2309.17167) [5], which generates evaluation samples on-the-fly with controlled complexity.\n5. **Efficient multi-prompt evaluation**: We integrated the efficient multi-prompt evaluation method [PromptEval](https://arxiv.org/abs/2405.17202) [8]. This method uses the performance of LLMs on a small amount of data to build an IRT-like model. This model is then used to predict the performance of LLMs on unseen data. Tests on MMLU, BBH, and LMentry show that this method requires sampling only 5% of the data to reduce the error between estimated and actual performance to around 2%. \n\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Installation\n\n### Install via `pip`\nWe provide a Python package *promptbench* for users who want to start evaluation quickly. Simply run:\n```sh\npip install promptbench\n```\n\nNote that the pip installation could be behind the recent updates. So, if you want to use the latest features or develop based on our code, you should install via GitHub.\n\n### Install via GitHub\n\nFirst, clone the repo:\n```sh\ngit clone git@github.com:microsoft/promptbench.git\n```\n\nThen, \n\n```sh\ncd promptbench\n```\n\nTo install the required packages, you can create a conda environment:\n\n```sh\nconda create --name promptbench python=3.9\nconda activate promptbench\n```\n\nthen use pip to install required packages:\n\n```sh\npip install -r requirements.txt\n```\n\nNote that this only installed basic python packages. For Prompt Attacks, you will also need to install [TextAttack](https://github.com/QData/TextAttack).\n\n\n## Usage\n\npromptbench is easy to use and extend. Going through the examples below will help you get familiar with promptbench for quick use, evaluate existing datasets and LLMs, or create your own datasets and models.\n\n\nPlease see [Installation](#installation) to install promptbench first. \n\nIf promptbench is installed via `pip`, you can simply do:\n\n```python\nimport promptbench as pb\n```\n\nIf you installed promptbench from `git` and want to use it in other projects:\n\n```python\nimport sys\n\n# Add the directory of promptbench to the Python path\nsys.path.append('/home/xxx/promptbench')\n\n# Now you can import promptbench by name\nimport promptbench as pb\n```\n\n\nWe provide tutorials for:\n\n1. **evaluate models on existing benchmarks:** please refer to the [examples/basic.ipynb](examples/basic.ipynb) for constructing your evaluation pipeline. For a multi-modal evaluation pipeline, please refer to [examples/multimodal.ipynb](examples/multimodal.ipynb)\n2. **test the effects of different prompting techniques:** \n3. **examine the robustness for prompt attacks**, please refer to [examples/prompt_attack.ipynb](examples/prompt_attack.ipynb) to construct the attacks.\n4. **use DyVal for evaluation:** please refer to [examples/dyval.ipynb](examples/dyval.ipynb) to construct DyVal datasets.\n5. **efficient multi-prompt evaluation using PromptEval**: please refer to [examples/efficient_multi_prompt_eval.ipynb](examples/efficient_multi_prompt_eval.ipynb)\n\n## Implemented Components\n\nPromptBench currently supports different datasets, models, prompt engineering methods, adversarial attacks, and more. You are welcome to add more.\n\n### Datasets\n\n- Language datasets:\n  - GLUE: SST-2, CoLA, QQP, MRPC, MNLI, QNLI, RTE, WNLI\n  - MMLU\n  - BIG-Bench Hard (Bool logic, valid parentheses, date...)\n  - Math\n  - GSM8K\n  - SQuAD V2\n  - IWSLT 2017\n  - UN Multi\n  - CSQA (CommonSense QA)\n  - Numersense\n  - QASC\n  - Last Letter Concatenate\n- Multi-modal datasets:\n  - VQAv2\n  - NoCaps\n  - MMMU\n  - MathVista\n  - AI2D\n  - ChartQA\n  - ScienceQA\n\n### Models\n\nLanguage models:\n\n- Open-source models:\n  - google/flan-t5-large\n  - databricks/dolly-v1-6b\n  - Llama2 series\n  - vicuna-13b, vicuna-13b-v1.3\n  - Cerebras/Cerebras-GPT-13B\n  - EleutherAI/gpt-neox-20b\n  - Google/flan-ul2\n  - phi-1.5 and phi-2\n- Proprietary models\n  - PaLM 2\n  - GPT-3.5\n  - GPT-4\n  - Gemini Pro\n\nMulti-modal models:\n\n- Open-source models:\n  - BLIP2\n  - LLaVA\n  - Qwen-VL, Qwen-VL-Chat\n  - InternLM-XComposer2-VL\n- Proprietary models\n  - GPT-4v\n  - Gemini Pro Vision\n  - Qwen-VL-Max, Qwen-VL-Plus\n\n### Prompt Engineering\n\n- Chain-of-thought (COT) [1]\n- EmotionPrompt [2]\n- Expert prompting [3]\n- Zero-shot chain-of-thought\n- Generated knowledge [6]\n- Least to most [7]\n\n### Adversarial Attacks\n\n- Character-level attack\n  - DeepWordBug\n  - TextBugger\n- Word-level attack\n  - TextFooler\n  - BertAttack\n- Sentence-level attack\n  - CheckList\n  - StressTest\n- Semantic-level attack\n  - Human-crafted attack\n\n### Protocols and Analysis\n- Standard evaluation\n- Dynamic evaluation\n- Semantic evaluation\n- Benchmark results\n- Visualization analysis\n- Transferability analysis\n- Word frequency analysis\n\n## Benchmark Results\n\nPlease refer to our [benchmark website](https://llm-eval.github.io/) for benchmark results on Prompt Attacks, Prompt Engineering and Dynamic Evaluation DyVal.\n\n## Acknowledgements\n\n- [TextAttack](https://github.com/QData/TextAttack)\n- [README Template](https://github.com/othneildrew/Best-README-Template)\n- We thank the volunteers: Hanyuan Zhang, Lingrui Li, Yating Zhou for conducting the semantic preserving experiment in Prompt Attack benchmark.\n\n\n## Reference\n[1] Jason Wei, et al. \"Chain-of-Thought Prompting Elicits Reasoning in Large Language Models.\" arXiv preprint arXiv:2201.11903 (2022).\n\n[2] Cheng Li, et al. \"Emotionprompt: Leveraging psychology for large language models enhancement via emotional stimulus.\" arXiv preprint arXiv:2307.11760 (2023).\n\n[3] BenFeng Xu, et al. \"ExpertPrompting: Instructing Large Language Models to be Distinguished Experts\" arXiv preprint arXiv:2305.14688 (2023).\n\n[4] Zhu, Kaijie, et al. \"PromptBench: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts.\" arXiv preprint arXiv:2306.04528 (2023).\n\n[5] Zhu, Kaijie, et al. \"DyVal: Graph-informed Dynamic Evaluation of Large Language Models.\" arXiv preprint arXiv:2309.17167 (2023).\n\n[6] Liu J, Liu A, Lu X, et al. Generated knowledge prompting for commonsense reasoning[J]. arXiv preprint arXiv:2110.08387, 2021.\n\n[7] Zhou D, Schärli N, Hou L, et al. Least-to-most prompting enables complex reasoning in large language models[J]. arXiv preprint arXiv:2205.10625, 2022.\n\n[8] Felipe Maia Polo, et al. \"Prompteval: Efficient Multi-prompt Evaluation of Language Models.\" arXiv preprint arXiv:2405.17202.\n\u003c!-- CITE --\u003e\n\n## Citing promptbench and other research papers\n\nPlease cite us if you find this project helpful for your project/paper:\n\n```\n@article{zhu2023promptbench2,\n  title={PromptBench: A Unified Library for Evaluation of Large Language Models},\n  author={Zhu, Kaijie and Zhao, Qinlin and Chen, Hao and Wang, Jindong and Xie, Xing},\n  journal={arXiv preprint arXiv:2312.07910},\n  year={2023}\n}\n\n@article{zhu2023promptbench,\n  title={PromptBench: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts},\n  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},\n  journal={arXiv preprint arXiv:2306.04528},\n  year={2023}\n}\n\n@article{zhu2023dyval,\n  title={DyVal: Graph-informed Dynamic Evaluation of Large Language Models},\n  author={Zhu, Kaijie and Chen, Jiaao and Wang, Jindong and Gong, Neil Zhenqiang and Yang, Diyi and Xie, Xing},\n  journal={arXiv preprint arXiv:2309.17167},\n  year={2023}\n}\n\n@article{chang2023survey,\n  title={A survey on evaluation of large language models},\n  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},\n  journal={arXiv preprint arXiv:2307.03109},\n  year={2023}\n}\n\n```\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\nIf 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\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the project\n2. Create your branch (`git checkout -b your_name/your_branch`)\n3. Commit your changes (`git commit -m 'Add some features'`)\n4. Push to the branch (`git push origin your_name/your_branch`)\n5. Open a Pull Request\n\n\n\u003c!-- TRADEMARKS --\u003e\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft\u0026#39;s Trademark \u0026amp; Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n\n\n\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n\n[contributors-shield]: https://img.shields.io/github/contributors/microsoft/promptbench.svg?style=for-the-badge\n[contributors-url]: https://github.com/microsoft/promptbench/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/microsoft/promptbench.svg?style=for-the-badge\n[forks-url]: https://github.com/microsoft/promptbench/network/members\n[stars-shield]: https://img.shields.io/github/stars/microsoft/promptbench.svg?style=for-the-badge\n[stars-url]: https://github.com/microsoft/promptbench/stargazers\n[issues-shield]: https://img.shields.io/github/issues/microsoft/promptbench.svg?style=for-the-badge\n[issues-url]: https://github.com/microsoft/promptbench/issues\n[license-shield]: https://img.shields.io/github/license/microsoft/promptbench.svg?style=for-the-badge\n[license-url]: https://github.com/microsoft/promptbench/blob/main/LICENSE.txt\n","funding_links":[],"categories":["**Section 2** : Azure OpenAI and Reference Architecture","Python","chatgpt","A01_文本生成_文本对话","Prompts","Red Teaming \u0026 Testing","Tools and Frameworks","Evaluation and Monitoring","Repositories","🛡️ Prompt Injection","Anthropomorphic-Taxonomy","App","Repos","Prompt Tooling","Tools","SDK, Libraries, Frameworks","GPT Security"],"sub_categories":["**Microsoft Azure OpenAI relevant LLM Framework**","大语言对话模型及数据","Reflection and Meta-Cognition","Hall Of Fame:","Typical Intelligence Quotient (IQ)-General Intelligence evaluation benchmarks","Prompt Evaluation \u0026 Safety","Python library, sdk or frameworks","Bypass Security Policy"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpromptbench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fpromptbench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpromptbench/lists"}