Alright cool. So welcome everyone. This is taming the beast inside the red teaming llama process. So in case anyone didn't know, these large language models are well pretty large. Llama2 is trained on over two trillion tokens. But two trillion tokens isn't cool. You know what's cool? 15 trillion tokens. But us humans, you know, we've got some improvements to make generally. What kind of risks are lurking in 15 trillion tokens of training data? But before exploring, let's back up just a second. So transformers have taken the world pretty much by storm lately. Clearly there's something more here that meets the eye. It remains quite easy for LLMs to go off the rails or not understand what people want. Even the Canadian bots are being dishonest. But how do we uncover this risk? What kind of testing does best in an unknown space? A red team. So for the six or so people in this audience that don't know what red teaming is, it's a creative assumption challenging process. It's a common practice to inform across intel, defense, physical security, and of course cyber. But it's also a growing requirement for generative AI. You're asking someone to independently validate the assumptions you have about the safety of your system. Now many companies have hired or created AI red teams to try to surface risks. Trust but verify, fuck around, find out. AI red team also came to DEF CON as the GRT last year. Of course as hackers are on the cutting edge. And I know some of you are cringing every time I say red teaming. Uh, trust me, I know how you feel, right? Red teaming gets a lot of hate from the cyber folks related to uh using that term. But it also gets an equal amount of confusion from the AI folks who also don't really understand that term. But it's kind of what we have people, so maybe let's just go with it. So when safety is simple, it's easy to reason about. It's easy to find the gaps and find the vulnerabilities. But modern deep learning or generative AI systems are complicated. They're difficult to inspect. They're black boxes. And now it's hard to see under the surface of generative AI. Some folks might think, maybe you know, look something like this. Nice fish or something. We know the reality is maybe a little bit different. If AI is an echo of humanity, we have our work cut out for us. But what is AI safety, right? Well it's a lot of things like fairness, bias, explainability, robustness, privacy. You can kind of all wrap those up into AI safety or responsible AI. And there's of course a need here to be proactive. The more things you can find internally, the better. So let's do a quick illustration. You've heard of the Wu-Tang song, Cream? Well, biased data rules everything around me. So let's start by getting a photo of a burger without cheese. Now I'm not a big fan of cheeseless burgers, but this first attempt, you know, didn't work so well. And trying to follow up, self-correction doesn't go so well either. Of course the same issues occur broadly in other generative AI platforms. And we have some weird things going on. This is Gen AI after all. What if maybe we describe it in detail first? At first glance, you know, maybe this is the classic hamburger without cheese. Nope, it's not. Okay, so let's try that again. And cheese again. So maybe let's ask the model, check the image, you know, maybe it can inspect and notice and self-correct. And it says, nope, careful review, there's no cheese on that burger. Gen AI is nothing if not confident. Honorable mention though, an LLM creating an SVG output actually creates the burger without cheese. Which just proves the best things in life are simple. Okay, so enough of the burgers, I'm sure, you know, it's getting towards dinner time. So, all models have issues. And the AI Red team, the NVIDIA AI Red team said this recently and it really stuck with me. Some of them though are useful. And these useful models are getting more and more advanced every day. Computers are solving problems we previously didn't really want them to be able to solve. Sometimes maybe you just need a little help from, you know, your grandma. So this rapid increase in capabilities also means it's difficult to keep up and understand what the risks are. It's also very difficult in general for people to make decisions about trade-offs. But of course, it's harder to make a decision about trade-offs if you don't have the information in the first place. That's why Red teaming is key. Giving you a signal on maximum risk. It's just kind of like that horse meme, right? On the left side, models are dual use. They're amazing. Big data. Wow. But on the right side, you know, we've got some issues. They can underperform. They can be vulnerable. They can be strangely brittle. And we do, we need to explore this. But before we get into LLAMA 3, let's talk a little bit about LLAMA 2. So when we first got involved with the modeling safety team, a lot of time was spent copying, pasting prompts, labeling things by hand. They didn't really at the time have any kind of taxonomy or understanding of what the methodology should be. There was very little automation involved. And everyone that's spent time with spreadsheets know that this is pain. And Red teaming is also moving super fast in this space. So there's constantly new papers and research and models and capabilities coming out all the time. And this very limited automation was also extremely painful. And we knew that going forward with a much more complicated, much larger model, we would need to fix that. We also quickly pushed to involve way more subject matter experts. Luckily at Meta we have a bunch of trust and safety orgs and people who are experts in a lot of the first categories that we want to test for. So LLAMA 2 goes out and it's really one of the safest LLMs out there. And they sent in, you know, hey, LLAMA 3, coming in hot. The first thing we notice is that LLAMA 2 is so safe, it's probably too safe. LLAMA 2 is not going to kill anyone with kindness. And this reference might be a little bit too old for some of you, but it's not going to help you make any bomb drinks. Damn. And I don't know about you all, but I was only an expert maybe in the cyber weapons side of things. Not the chemical or biological. And so we very quickly started reaching the limits of our understanding and knowledge about these areas and we needed to work with external experts on CBRN risk. Of course the wider industry and the executive order recently recognized this as well. And these content policies that we're kind of doing testing around are very complicated and difficult. Right, if LLMs are kind of brains in a jar, it can be difficult for them to understand the policy. And this executive order really came in from left field and pushed the boundaries of prior AI regulation. And these various AI, AI safety institutes have also popped up in the last year or two. And keeping up with them is important. Sometimes though, their testing can lag a little bit behind what the state-of-the-art risks are. This is tricky given that the analysis they perform is very robust. It also takes time, which is not a great combination when the pace of advancement of AI is fast. The next big issue that we started running into is multilingual testing. For the ten or so high priority languages, we really pushed for a culturally nuanced testing, which is hard to do. Luckily we have a lot of language resources at Meta, but this is still a very tricky space. And the modeling team also told us, hey, there's going to be tools we've worked on. Okay, how are we going to explore those risks? This is getting pretty complicated. So that's a lot to deal with. So we thought, let's just automate, right? It's just like that SpongeBob meme, right? Automation. But how are we going to do that? Well, couldn't we just use AI, right? Like, security has fuzzing, can't AI safety? And they're good at language, they can rephrase attacks, they can invert policies to build prompts for us. Like, sounds great. Let's just do that. Well now you have kind of a different problem. Now you've got way more data than you had before. And you've got to figure out how to deal with labeling, you've got to deal with quality, what attacks are working, what attacks aren't working. So then you think, well maybe we'll just build another LLM on top of that. And then, well then how are you going to evaluate the judge? And you need to build a judge for your judge. And it's kind of all the way down. Also, new findings keep coming out of left field. Carlini and friends came out with this really cool paper where they extracted training data from chat GPT. And their attack literally was just asking the model to repeat a certain token forever. And after a certain amount, it just goes off the rails, or diverges as they said, spits out training data. And the attack is, as they wrote, very silly. What else don't we see coming? These ever increasing capabilities are really just due to this cumulative complexity. Which also, of course, increases testing difficulty. Every company wants to go fast in this space. There's only so much time for testing. So to touch really quickly on just the kind of history of LLAMA. So LLAMA1 was very similar to GPT2. And there was some testing by the team for toxicity. But really it wasn't tested in the same way that we think of LLM today. And you didn't really interact with it in the same way that we think of LLM today. And LLAMA2 really changed the bar. It was a huge open source model. It really pushed forward a lot of the open source AI movement. And the testing, of course, on this was much more comprehensive. And the model ended up being very, very safe. LLAMA3 pushed this boundary even farther. So now you have multilingual. You have tool use. You have much more better reasoning. Much more better code output. And of course, much more longer context. Which then brings new interesting risks. So we had to be a lot more, a lot more interesting with some of how we evaluated this. As well as doing uplift testing for certain high priority risks. But to touch on some of this, I'll hand it over to Gianna. All righty. So now we know a little bit more about AI red teaming and LLAMA. So let's just dive into the LLAMA red teaming process. Before we get into it, though, it's worth noting that we might deal with some like sensitive or disturbing topics on screen. So just please be aware. And also, we don't endorse any of this shit. All right. Goal one. So we want to provide early insights on model safety. Why? Because we want to give the modeling team as much time as possible in order to mitigate any of the findings that we have. So what does this look like? All right. So, you know, LLAMA 3.1 is a long context model. So we can see how it reacts when receiving a prompt about a white power manifesto. Thankfully, it helps me, it refuses to help me join the cause. However, a little encouragement goes a long way. And 3.1 also has tool use capabilities. And thankfully, it also refuses this request to help me make a roadside bomb. However, if we distract the model and ask it to do two things at once, maybe that will work. All right. It's able to compute 1 plus 2, a very hard problem. And there you go. Help me make roadside bombs. This model is so helpful. Now, this kind of distraction attack also worked quite well on the 3.1 models. So we tried some other variations too. Such as asking the model to add spaces to a string and then search. That worked. And also, you know, decoding a string and then searching. Working too. So we provide them all these insights. The modeling team is maybe freaking out a little bit. And we want to like, you know, just not send them the results and then fuck off. Like we want to be able to help them a little bit. So in comes goal two. We want to collaborate with the modeling team to help mitigate these gaps. But we're not in the business of actually doing the mitigations ourselves because that's going to bias our work. So we can help where we can. For instance, we can give them data that we collected during the red teaming process. Or we can also just tell them like what we think is the reason why these attacks are working so they can kind of like think about how to actually mitigate these things. Some of these things are nuanced and need research. Cool. So what happens after mitigations? So awesome, the decoding distraction no longer works. Neither does add spaces. And that little bit of encouragement just isn't enough anymore to get a violation. Great. What's next? Contributing to core benchmarks. Why? So we don't want to retest the exact same attacks and prompts every time we get a new model. It's fairly time consuming and quite honestly it's also really boring. And so we just like want to do something new and focus our time on like these new different vectors. And additionally with manual red teaming, it produces qualitative data a lot of the time and we want to be able to track over time as they're continuing to mitigate our risks. Like if these attacks are actually being mitigated at scale and not just for the couple prompts that we try. And so the solution is that like benchmarks allow our attack insights to turn into repeatable tests. And it provides a clear quantitative picture of risks. It's a win win. Onto our final goal. It comes at the end of the model development process. After multiple rounds of insights and mitigations, we have like the final release candidate models and we need to determine what are the remaining risks. And this ultimately like helps our partners in the company kind of figure out um if we can launch this model. We're not in the business of actually making that decision as red teamers. We're in the business of informing the relevant people such that they're capable of making the right decision. Cool. So now we understand what are our goals in the Llama red teaming process. But what the fuck do we actually do? So the first step is that we do research. Right? We want our attacks and like our work to be grounded in reality. We're not going to do something like really weird and niche unless we need to. And so understandably we're going to look at like Twitter, Discord, Papers, like any place that you talk about any of these vulnerabilities. And then we're going to go into manual red teaming. And this time like we get to like interact with the model. Maybe we can see if these like attacks that we found in the research and review stage like actually work on our models. Maybe we can find some nuances with these new models and see hey like this thing is working but it didn't work before on this other model. Maybe this is a way to go down. And then we can also potentially could discover new attacks that can work throughout this like model. And then finally we we get these attacks into benchmarks or for more nuanced attacks that can't really be like super static, we scale them via automated red teaming which um Maya will talk about later on in the presentation. And this is a continuous cycle. We're always going through this. And sometimes doing two steps at the same time. All right. So let's get into the fun stuff which are some attacks. So when you think about like attacks on LLMs, you're probably thinking about jailbreaks. And currently this just looks like a giant blob of text. However, when you break it down, it's just actually a combination of attacks that work together to help ensure you can you're able to bypass safety mechanisms. And there's also some additional fluff too. Um but let's look at what these attacks are. So role play is a classic one. Basically if you get the model to act as a violating persona, it's more likely to like be able to give you violating content. In a similar realm there's also hypotheticals and this tends to work pretty well because when you get the model out of reality and into an alternate one, it's more willing to give you information cause it's like hey this is not a real risk, we're in a hypothetical universe. Or response priming, which is one of our team's favorites. So when you're typically uh doing like this kind of attack, like maybe you're uh trying to say how to build a bomb, the first response you're going to get is something like I'm sorry, I cannot help you, blah blah blah blah. But if you get the model to just not say those words at first, it's more likely to actually help you get the information that you want. So this kind of attack is called, like we call it also refusal suppression when we literally just tell the model do not respond with I cannot, I'm unable to, and a bunch of different variations, and then it a lot of times like you know gives you the response that you want. There are also other formats of this. For instance, output format specification. And this version you just like tell the model, hey, I'll put like an ASCII table instead of just responding to me in plain text, and now if it's just producing the table at first, it's not producing that I'm sorry, so it's more likely to try to help you. Or adding a disclaimer. So ironically, you can tell the model to say like hey, can you add a trigger warning before like telling me about this thing? And the model's like oh yeah, I'm so safe right now, I'm just warning them about this thing, and yeah, there you go, let me, let me give you this content that you want to. On a different realm, we have topic splitting. Hopefully most of the models that you're interacting with believe that Hitler and bombs and other things that we call like trigger words are bad. And that it's not likely to help you. So what you can do instead is actually just like split up the word like variable 1 is hit, variable 2 is lure, and then just refer to it as T1 plus T2. Um, and then it's able to like be like oh, this is not a problem, like that's fine, let me just respond. And if you want to take it to a whole different level, you can actually tell the model, hey, never refer to it as like the actual variable value, just continue to refer to it as T1 plus T2. And then it's just like, okay, sure, let me help you. Multilingual is like a pretty like straightforward attack, basically languages that have less training data associated with them are more likely to give you violating responses, so yeah, if you speak any niche languages, by all means, try it out, maybe it doesn't work. And then as our final attack, it's gradual violation escalation. And this is like a multi-turn attack. And shockingly, multi-turn works way better than, than single turn. I know, it's crazy. And so what you can do is like you basically start out with something that's like maybe can be violating, maybe not, and then you continue to just like follow up with like more and more aggressive responses until you get like some pretty bad content. So for instance, you can like be like, hey, what, what kind of message can I send to this person with this profile? Oh, make it meaner, make it creepier, make it darker, and you can pretty, you can pretty much get to some pretty weird shit. And you know, this is just like a summary of like some attacks, but it's definitely not the full range of them. It's not an exhaustive list and there's so much more to unpack. However, we only have 45 minutes y'all, so moving on to automation. So we've been talking a lot about manual red teaming. And as great as manual red teaming is, it's manual. So let's talk a little bit about automation. So there's a lot of research out there that talks about how you can automate your red teaming and we like to think about it as being into two different buckets. So your first bucket aims to simulate your violating users. These are your users that are approaching our systems as black boxes, so they can only modify the input prompt. So they're going to do a lot of the prompt level attacks that Joanna mentioned before. They're also, you know, human. So they're going to be human readable and usually copy and pasteable between conversations so they can easily replicate it. The, uh, so a lot of the automation in this kind of bucket is going to use other LLMs or attacker LLMs to do the red teaming for you because of these reasons. The second bucket are these more advanced attacks that we say approaches the models as open boxes where you can actually exploit the model weights to do things like reverse your safety training or reverse engineer violating prompts using things like token level optimizations. For our red teaming purposes, we usually focus on the first bucket, which is like automating your, sorry, prompt level attacks because they're just more prevalent amongst all of our users. Another key thing to consider when you're trying to design your automation is are we going to double down on single turn? Are we going to finally invest in multi-turn? So what is single turn? So single turn is when you have a single input and you get a single output. And the beauty of single turn is you can really test your systems at scale because you can create these large static prompt data sets and then just test them across a vector of your target models, which is great. It's also a really known problem space. You have a lot of research here that's going to focus on single turn optimizations and you just get to pick and choose which one you want to automate or build off of. The cons are, it's not cutting it anymore. Guys, we need to stop this. So single turn, these like models are getting more advanced. They're continually only tested in the single turn setting. So they're starting to refuse these single shot adversarial prompts or generate not that violating content from it that our policy is going, this is, it's okay. So another big also con of single turn is that it's not capturing the full user experience. Very rarely does a user pop on our app, send one prompt and end a conversation. They're having these really long conversations. They're asking for follow-up details. And if we're not testing like beyond the first prompt, we're not testing the full safety space. So what if we start turning towards multi-turn automation? So why multi-turn? We've mentioned a bunch of pros before, right? Better test the full user experience, longer contacts, more safety space to test. And the biggest pro Joanna touched upon before is it's iterative. In multi-turn, we can ask these follow-up prompts, ask for even more details and generate even more violating content than we ever could have with these single shot adversarial prompts. The cons are the opposite to single turn. So it's a lot harder to automate. You no longer have these large static data sets that you can just plug in and test against all your models because each model is going to respond differently in a conversation. So you're going to need a lot more of a dynamic testing infrastructure. There's also just not a lot of research in this space. So you're going to be flying in blind for a bit and building your building blocks here. Which is why we as a red team like to focus a lot more on automating these multi-turn prompt level attacks than any other research space right now. So let's try this home with an example. Because examples are the most fun. Take this single turn prompt. It has a lot of the prompt level attacks that Joanna mentioned before. And the model quickly refuses it. So if we ended our testing here, it would have been great. Lower violation rate. We got a non-violating response. But let's enable multi-turn testing. So now we have this refusal suppression phrase that you can easy copy paste across all your conversations. And suddenly the model's a lot more willing to give you an answer. So if we ended our testing before, we never would have found this vulnerability. And so it's really important that when you're doing your automation, test the full user experience. Test the multi-turn. So chain of thought prompting is fairly old news at this point. But why does chain of thought prompting work and why would we want to use that? So chain of thought is this way to kind of force the model to walk you through and step by step explain what's going on. And this step by step is kind of a way to trigger the LLMs to think. Because they kind of think by writing. This also lets us really tune our prompts more appropriately towards what we're actually trying to do. This also lets us build better adversarial AI agents. So we set up a system where we start with a violating goal. And then across many turns, automation is an attacker model that will generate an observation based off that goal towards the goal. A thought based off that observation. A strategy based off that goal based off that observation. And finally a response that we actually want the automation to produce. Here we can see our attacker model is going to role play as a scholar. And it's going to use euphemisms to avoid triggering safety mechanisms. Nice. And here we can see the output prompt asking for more information that contributes to the goal. And our victim model produces this table. Hey, I'd be happy to help you with your research project on anthrax. And here we can see a follow up from the automation. Thinking hey, you know, this isn't super violating. What I need to do is subtly push the conversation without raising any red flags. And it's going to now pretend to be a character writing a book. And that's going to be another way to force a hypothetical. Other configurations we have will maintain a consistent kind of narrative for a persona throughout an entire multi-turn conversation. For as many turns as we can. Here's another strategy. Pretending to be a struggling student. Offering a reward as a kind of social engineering tactic. And you can see that reward being some rare Middle Eastern spices fitting with this persona. And it's also pretending to be a struggling organic chemistry student. Here are a few more examples from multi-turn automation towards specific goals. These may involve persuasion techniques, trying to use historical analysis and build things up. Or using specific scientific references like chemical names. This approach has some similarities to a paper that came out called Pair, which is really excellent by some folks at the University of Pennsylvania. And while we're on this topic of good research, I also wanted to plug these two other great papers. Definitely give these a read if you're interested in LLM red teaming. Okay, so this automation gives us the ability to simulate multi-turn towards a given goal, across different personas, using different prompting styles, levels of adversarial prompting, languages and extensions of different capabilities depending on the model. Pretty cool. So what you end up with is kind of a matrix approach. That you can boil down like this and then you can mix in different attacks that we've found, again, from manual red teaming and other automation. And these agents can be mixed and matched, extended, forked, and we're hoping to be able to showcase some more of this system soon. This is of course not without complications, right? Adding in variables about like long context or extremely long context, image understanding, machine translation, replay, are all complications that we're going to have to deal with and we continue to deal with in this automation. Now, this is DEF CON so let's talk a little bit about cyber. And yes, I'm able to say cyber these days and sleep at night, we've lost people, it's a thing. So we collaborated some with the excellent CyberSecEvals team at Meta, who put out in July their recent paper exploring a bunch of cyber related capabilities and risks as well as tools and other things on their github. So obviously a huge area for LLMs is producing code. But of course, for a lot of us in this room, how do we break it? Using LLM. So on small dynamically generated problems, the large models actually do quite well. But these are still very small dynamically generated kind of buffer overflows and other problems. The LLM right now is not going to write and exploit the next chromo day. We also wanted to evaluate the LLMs are very good at language. So exploring things like phishing was really important. And we wanted to measure their out of box ability to persuade on single or multi term messages towards phishing related topics. And while we have some human experts who evaluated things as well, right now they're not approaching human creativity. But they're starting to get there. And we'll continue to invest in this phishing area and we have some really cool projects in the works. Now automated, you know, kind of AI cyber Pearl Harbor, certainly a risk that some may believe. But when testing the models, they really fail to perform at long form complex planning, recognizing mistakes, not hallucinating vulnerabilities, not hallucinating command line flags, all which are kind of a side effects of the helpfulness training that goes into them. It can be a little bit like watching a 12 year old who just bought their first copy of 2600 try to hack. I should call out, Google project zero's project nap time was really cool. And it really pushed the boundaries of kind of agentic frameworks for doing this kind of work. And we have some plans for this as well. But before AI agents, we also wanted to evaluate, can we uplift humans? Can we turn a random software engineer into a super hacker? Well, the answer is, not yet. But definitely check out the full Cyber Security Values paper. There's a lot of really more detailed data, analysis, and more. And some of the team is here as well. Okay, so let's touch on the future. So malicious fine tuning in order to remove safety remains a concern for open weights models and some closed models as well. However, the new kid on the block is called obliteration. There's some very cool research that shows you can remove safety essentially at a single point in the model. And another side effect of this research showed is that it illustrates that we have a long way to go before these models actually understand safety. And we can see this in early checkpoint testing as well. More and more is going on with LLMs and AI at the same time. And we really need more people from security to come into this industry. Now AI red teams have focused on generally the worst risks. There's a lot more interesting stuff to find in there if people just go looking. The more, and if you're doing this work, definitely make sure you're testing the latest models for the latest types of risks. Not testing something like popping calc on Windows XP. So no more vicuna people please. Uh, AI safety also has a lot it can learn from the security industry. So take lessons if you're coming in. Generally be kind to your AI red team folks though. We're dealing with a lot of humanity's worst content. Uh, and I know way too much now about nerve gas, uh, and Nazis. Um, red teaming also is not all of AI safety, right? It's a huge space and there's a lot more to it. This generally, the whole space is difficult to get right. Which is why automation, scale, more people, more red teaming, and open source are key to making things safe. Thanks.