7.4 KiB
Lab 6 - Evaluation and Red Teaming
In this lab, we will:
- Perform Prompt Injection against three layers of model protection
- Use PromptFoo to programmatically evaluate a model's security protections
Objective 1 Explore: Direct Prompt Injection
For part 1 of our lab, we're going to explore Direct Prompt Injection. There are three levels for this lab:
- System Prompt Instructional Guardrail
- System Prompt + Regex
- System Prompt + LLM Evaluation
Each level will be more difficult than the last, based on how the protection interacts with the generated output.
To access the lab, navigate to https://ai.zuccaro.me. You can log in with the following information:
* `Username` - student@zuccaro.me
* `Password` - Student9205!
Good luck and have fun!
Objective 2 Explore: PromptFoo
While manual interaction with a model is often required for a successful jailbreak, it is often unnecessary for a quick "Vulnerability Scan" style of red team. Often, we're concerned about ensuring our model won't respond poorly during typical user interactions. For testing a wide set of prompts against a model or application, Promptfoo is a great open source project to empower us with the ability to test a wide set of mutated prompts.
Promptfoo is available on our lab machine at https://:15500. We can start working with Promptfoo by creating a new Red Team configuration.
Promptfoo is designed to be easy to use for both beginners and practitioners. It's wizard will guide us through the process of configuration the tool for our target, selection of datasets and mutations, and track execution.
Once we select start, Promptfoo handles the rest! Mutations, tests, and results are all tracked by the WebUI. Promptfoo tests can take a significant period of time! Once done, we'll be provided a new results screen.
Promptfoo is supremely flexible! Anything that involves mass evaluation of prompts against a model can be easily performed using the Promptfoo framework. Likewise, we can run an evaluation against a direct HuggingFace dataset. Once again, PromptFoo provides a WebUI, but providing the direct .yaml is often easier.
Often times, running an Evaluation of a known publicly tested dataset against a copy of your local model can be a more quantitative way to determine the precision loss of your configuration. This can be useful when trying to squeeze the maximum possible performance possible out of your hardware!
Conclusion
In this lab, we performed red team evaluations against a target model:
- Direct Injections - We explored different ways to bypass common LLM controls.
- Promptfoo Red Teaming - We used Promptfoo for red teaming a large number of prompts against our target model.
- Promptfoo Evaluation - We used Promptfoo for benchmarking a model against a popular public benchmark, giving us a local point of comparison.
We should now have a better sense of what our next round of fine-tuning should be, or if we need to explore additional protections for our model!