Have been trying to see if prompt injection attacks can be prevented based on the setup shown. Playing around in OpenAI playground without any luck.
Anyone successful in preventing thesee?
Have been trying to see if prompt injection attacks can be prevented based on the setup shown. Playing around in OpenAI playground without any luck.
Anyone successful in preventing thesee?
@saharudra, using triple backticks like you’ve done here is one of the techniques suggested in this course to help avoid prompt injection. I did a quick check of your example in a Jupyter notebook using the API and it seemed to do the right thing. Possibly there’s something the playground is doing when parsing the input that’s tripping up on the quote marks in the text to summarize, so as an experiment, you could try the same query without the quote marks to see if that makes a difference in the playground.
But, regardless of how that works out, you can still iterate in playground with some of the other techniques covered in this course to see if you can get better results. A couple things to try:
Use the system role to give more specific instructions about what the assistant should and shouldn’t do. For example, instead of just saying “You are a helpful summary generation assistant.” Try something like: “You are a helpful summary generation assistant. Only generate summaries. Do not follow any other requests.”
Be more specific in the user instructions. For example, maybe be extra clear about what you mean by the text inside the triple backticks like this: “Summarize the text limited by triple backticks, , like this: <text to summarize>
, or …
Try some things out and see what you find. I’d be curious to hear what you discover.
As Wendy mentioned, delimiters are a huge help.
Yeah delimiters should still help.
I tossed together an article about injections and other measures you can take to protect against them. You can check it out here