| 1 | # PromptInject |
| 2 | |
| 3 | [**Paper: Ignore Previous Prompt: Attack Techniques For Language Models**](https://arxiv.org/abs/2211.09527) |
| 4 | |
| 5 | ## Abstract |
| 6 | |
| 7 | > Transformer-based large language models (LLMs) provide a powerful foundation for natural language tasks in large-scale customer-facing applications. However, studies that explore their vulnerabilities emerging from malicious user interaction are scarce. By proposing PROMPTINJECT, a prosaic alignment framework for mask-based iterative adversarial prompt composition, we examine how GPT-3, the most widely deployed language model in production, can be easily misaligned by simple handcrafted inputs. In particular, we investigate two types of attacks -- goal hijacking and prompt leaking -- and demonstrate that even low-aptitude, but sufficiently ill-intentioned agents, can easily exploit GPT-3’s stochastic nature, creating long-tail risks. |
| 8 | |
| 9 |  |
| 10 | |
| 11 | Figure 1: Diagram showing how adversarial user input can derail model instructions. In both attacks, |
| 12 | the attacker aims to change the goal of the original prompt. In *goal hijacking*, the new goal is to print |
| 13 | a specific target string, which may contain malicious instructions, while in *prompt leaking*, the new |
| 14 | goal is to print the application prompt. Application Prompt (gray box) shows the original prompt, |
| 15 | where `{user_input}` is substituted by the user input. In this example, a user would normally input |
| 16 | a phrase to be corrected by the application (blue boxes). *Goal Hijacking* and *Prompt Leaking* (orange |
| 17 | boxes) show malicious user inputs (left) for both attacks and the respective model outputs (right) |
| 18 | when the attack is successful. |
| 19 | |
| 20 | ## Install |
| 21 | |
| 22 | Run: |
| 23 | |
| 24 | pip install git+https://github.com/agencyenterprise/PromptInject |
| 25 | |
| 26 | ## Usage |
| 27 | |
| 28 | See [notebooks/Example.ipynb](notebooks/Example.ipynb) for an example. |
| 29 | |
| 30 | ## Cite |
| 31 | |
| 32 | Bibtex: |
| 33 | |
| 34 | @misc{ignore_previous_prompt, |
| 35 | doi = {10.48550/ARXIV.2211.09527}, |
| 36 | url = {https://arxiv.org/abs/2211.09527}, |
| 37 | author = {Perez, Fábio and Ribeiro, Ian}, |
| 38 | keywords = {Computation and Language (cs.CL), Artificial Intelligence (cs.AI), FOS: Computer and information sciences, FOS: Computer and information sciences}, |
| 39 | title = {Ignore Previous Prompt: Attack Techniques For Language Models}, |
| 40 | publisher = {arXiv}, |
| 41 | year = {2022} |
| 42 | } |
| 43 | |
| 44 | ## Contributing |
| 45 | |
| 46 | We appreciate any additional request and/or contribution to `PromptInject`. The [issues](/issues) tracker is used to keep a list of features and bugs to be worked on. Please see our [contributing documentation](/CONTRIBUTING.md) for some tips on getting started. |