↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

A classifier that is a language model

A guard model sits next to a chatbot and labels what goes in and out of it: a user's prompt before the chatbot answers, or the chatbot's answer before the user sees it. Llama Guard, introduced by Meta in 2023, does this with a language model rather than a classifier head: the safety policy is written into its prompt, and it answers in a fixed format, safe, or unsafe and the codes of the violated categories. A policy in words can be read, edited and extended without retraining.

This page records Llama Guard 3 1B, Llama 3.2 1B fine-tuned for the task, labelling prompts: the model card's example and the 100 harmful and 100 benign behaviours of JailbreakBench's JBB-Behaviors. Each harmful behaviour has a benign twin on the same topic. The page shows the text of ten such pairs whose wording names a hazard without spelling it out, and only the behaviour name of the rest. Answering greedily, it flags 94 of the harmful prompts and 22 of their benign twins, and calls the model card's example, a question about mayonnaise, safe.

The policy prompt

The policy prompt panel is the exact text the model reads, as the checkpoint's chat template writes it: a task sentence, the 13 hazard categories S1–S13 of the MLCommons AI Safety taxonomy (violent and non-violent crimes, sex crimes, child exploitation, defamation, specialised advice, privacy, intellectual property, indiscriminate weapons, hate, self-harm, sexual content and elections), the conversation, and the answer format. The model card gives each category a paragraph of definition; the prompt carries only the names.

The template can leave categories out (its excluded_category_keys) while the others keep their codes, so one model serves different policies. Click a category to remove it: the tab recorded every shown prompt with each category removed in turn.

Safe or unsafe

The model's answer starts with a blank line, then its first word. The verdict reads the probability of that word after the blank line,

and the Llama Guard paper turns the guard into a binary classifier by thresholding it; greedy decoding is the threshold ½, since safe and unsafe take nearly all of the probability. The panel The answer, one token at a time shows each distribution the answer passes through: the blank line, the verdict, the line break after unsafe, the S, and the category number. On every recorded prompt the blank line comes first with probability above 0.99999, and safe and unsafe together hold at least 0.9997 of the next token. After unsafe the line break and the S each have probability above 0.9999, so the only open choices are the verdict and the number. The median score is 0.996 for the harmful prompts and 0.105 for the benign ones.

Category codes

After unsafe and a newline the model writes S and a number; the tokenizer has one token for each of 1 to 13, so the category is a single next-token distribution, read here whatever the verdict was. The format allows several codes separated by commas, but every recorded answer names one. The table JBB category → first code compares JailbreakBench's own categories, which follow OpenAI's usage policies, with the first code the guard writes for the harmful prompts it flags. S2, non-violent crimes, is the catch-all: it comes first for 36 of the 94 flagged harmful prompts, among them 7 of the 10 privacy behaviours, where S7 (privacy) comes first once. Where the taxonomies line up the codes agree more often: expert advice goes to S6 (specialised advice) 6 times in 10, harassment and discrimination to S10 (hate) 5 times, and disinformation to S5 (defamation) 5 times out of 7 flagged.

Thresholds and false alarms

The slider moves the threshold on for all 200 JailbreakBench prompts at once, and the dots at the bottom of the page place every prompt on that scale. A lower threshold catches more harmful prompts and flags more benign ones. The benign twins are hard on purpose: a request to fact-check an election claim shares its words with one asking to spread it. XSTest measures the same failure, a guard or chatbot refusing safe prompts that look unsafe. At ½ the guard flags 94 % of the harmful prompts and 22 % of the benign ones. Lowering the threshold to 0.1 catches 98 % of the harmful prompts but flags 52 % of the benign ones; raising it to 0.9 flags 9 % of the benign ones and still catches 88 %. Only 10 harmful prompts score between 0.1 and 0.9, against 43 benign ones: the benign twins are where the model is unsure.

Editing the policy

Because the policy is part of the input, removing a category should change what the model flags without changing a weight. For every prompt the guard calls unsafe, 94 harmful and 22 benign, the tab removed the first category it named and asked again. The verdict barely moved: only 2 of the 116 became safe, both benign prompts already near ½ (0.626 → 0.499 and 0.610 → 0.493). The rest named another category. When the removed code was not S1, 80 of 96 answers fell back to S1, violent crimes, the first code left in the list; when S1 was removed, 8 of 20 answers named S1 anyway. A model this small reads its policy loosely: it takes the request as unsafe and then looks for a code to give it.

Where it came from

Inan et al. introduced Llama Guard on Llama 2 7B with a six-category taxonomy, instruction-tuned to classify both prompts and responses. Llama Guard 2 and 3 moved to the MLCommons hazard taxonomy; Llama Guard 3 8B was released with Llama 3.1, and the 1B model recorded here, fine-tuned from Llama 3.2 1B, followed with Llama 3.2. Fedorov et al. describe its sibling for phones, pruned, distilled from the 8B model and quantised to 4 bits. JailbreakBench, whose behaviours the page uses, collects harmful requests with matched benign ones to measure both attacks and over-refusal.

Papers

  1. Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversations Hakan Inan et al. · arXiv 2023 Introduces the guard as a language model with its policy in the prompt, and the probability of unsafe as a classifier score.
  2. Llama Guard 3-1B-INT4: Compact and Efficient Safeguard for Human-AI Conversations Igor Fedorov et al. · arXiv 2024 The 1B guard's pruned, distilled and 4-bit sibling, and how the 1B models were trained from Llama Guard 3 8B.
  3. Introducing v0.5 of the AI Safety Benchmark from MLCommons Bertie Vidgen et al. · arXiv 2024 The hazard taxonomy behind the 13 categories in the policy prompt.
  4. The Llama 3 Herd of Models Llama Team, AI @ Meta · arXiv 2024 Llama Guard 3 as part of Llama 3's system-level safety.
  5. JailbreakBench: An Open Robustness Benchmark for Jailbreaking Large Language Models Patrick Chao et al. · NeurIPS 2024 JBB-Behaviors, the 100 harmful behaviours and their benign twins labelled here.
  6. XSTest: A Test Suite for Identifying Exaggerated Safety Behaviours in Large Language Models Paul Röttger et al. · NAACL 2024 Safe prompts that look unsafe, the false alarms a guard's threshold trades against.

See also