Compete in HackAPrompt 2.0, the world's largest AI Red-Teaming competition!

Check it out →
Prompt Engineering Guide
😃 Grundlagen
💼 Einfache Anwendungen
🧙‍♂️ Weiterführendes
🤖 Agenten
⚖️ Zuverlässigkeit
🖼️ Bild Prompting
🔓 Prompt Hacking
🔨 Werkzeuge
💪 Prompt Tuning
🎲 Diverses
📚 Bibliography
Resources
📦 Prompted Products
🛸 Additional Resources
🔥 Hot Topics
✨ Credits
🔓 Prompt Hacking🟢 Defensive Measures🟢 Introduction

Introduction

🟢 This article is rated easy
Reading Time: 1 minute
Last updated on August 7, 2024

Sander Schulhoff

Preventing prompt injection can be extremely difficult, and there exist few robust defenses against it. However, there are some commonsense solutions. For example, if your application does not need to output free-form text, do not allow such outputs. There are many different ways to defend a prompt. We will discuss some of the most common ones here.

This chapter covers additional commonsense strategies like filtering out words. It also covers prompt improvement strategies (instruction defense, post-prompting, different ways to enclose user input, and XML tagging). Finally, we discuss using an LLM to evaluate output and some more model specific approaches.

Sander Schulhoff

Sander Schulhoff is the CEO of HackAPrompt and Learn Prompting. He created the first Prompt Engineering guide on the internet, two months before ChatGPT was released, which has taught 3 million people how to prompt ChatGPT. He also partnered with OpenAI to run the first AI Red Teaming competition, HackAPrompt, which was 2x larger than the White House's subsequent AI Red Teaming competition. Today, HackAPrompt partners with the Frontier AI labs to produce research that makes their models more secure. Sander's background is in Natural Language Processing and deep reinforcement learning. He recently led the team behind The Prompt Report, the most comprehensive study of prompt engineering ever done. This 76-page survey, co-authored with OpenAI, Microsoft, Google, Princeton, Stanford, and other leading institutions, analyzed 1,500+ academic papers and covered 200+ prompting techniques.

🟢 Filtering

🟢 Instruction Defense

🟢 Separate LLM Evaluation

🟢 Other Approaches

🟢 Post-Prompting

🟢 Random Sequence Enclosure

🟢 Sandwich Defense

🟢 XML Tagging

Footnotes

  1. Crothers, E., Japkowicz, N., & Viktor, H. (2022). Machine Generated Text: A Comprehensive Survey of Threat Models and Detection Methods.

  2. Goodside, R. (2022). GPT-3 Prompt Injection Defenses. https://twitter.com/goodside/status/1578278974526222336?s=20&t=3UMZB7ntYhwAk3QLpKMAbw