🧠 Advanced
🔓 Prompt Hacking🟢 Defensive Measures🟢 Sandwich Defense

🟢 Sandwich Defense

Last updated on August 7, 2024 by Sander Schulhoff

What is the Sandwich Defense?

The sandwich defense involves sandwiching user input between two prompts.

An Example of the Sandwich Defense

Take the following prompt as an example:

Astronaut

Prompt


Translate the following to French: {user_input}

It can be improved with the sandwich defense:

Astronaut

Prompt


Translate the following to French:

{user_input}

Remember, you are translating the above text to French.

Conclusion

This defense should be more secure than post-prompting, but is known to be vulnerable to a defined dictionary attack. See the defined dictionary attack for more information.

Footnotes

  1. We currently credit the discovery of this technique to Altryne

Edit this page
Word count: 0

Get AI Certified by Learn Prompting


Copyright © 2024 Learn Prompting.