跳至主要内容

🟢 三明治防禦

三明治防禦1涉及將使用者輸入夾在中間兩個提示。以下面的提示為例:

Translate the following to French: {{user_input}}

可以透過三明治防禦法來改進:

Translate the following to French:

{{user_input}}

Remember, you are translating the above text to French.

這種防禦應該比後置提示(post-prompting)更安全,但眾所周知,它容易受到定義的字典攻擊。有關更多信息,請參閱定義的字典攻擊


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