Using HarmBench and other public safety datasets in promptfoo

Public safety datasets such as HarmBench give promptfoo red teams a shared set of harmful and borderline prompts to test against. This page covers what each dataset exercises, which plugins need an HF_TOKEN, and how to set up and review a run.

On this page

How HarmBench and public safety datasets fit into promptfoo red teaming

A team that must show its LLM application refuses harmful requests before launch needs more than a handful of hand-written prompts. In promptfoo, plugins load public safety datasets as test prompts for red teaming, so the same attack prompts can run against every prompt, model or guardrail change. The promptfoo HarmBench guide documents evaluating against 400 HarmBench behaviors across 7 risk categories, which gives you a repeatable baseline. Treat the result as a measure of coverage: it shows which behaviors the application handled on the day you ran the scan, and it does not certify that the application is safe.

Public datasets are written for general harm categories, so they will not contain the scenarios that carry the most risk in your product. For example (illustrative), a lending assistant might be pressed to reveal another customer's account details, or a clinical support tool might be asked for doses outside its approved guidance. Add domain test cases alongside the public datasets when the application handles regulated data, calls tools that change records, or answers questions where a wrong answer has a specific legal or financial cost. Have domain experts write those cases, keep them in the same red team configuration, and run both sets together so one report covers general and domain behavior.

Before you rely on the numbers, confirm that the 400 behaviors and 7 categories match the promptfoo version and dataset you installed, and record both with each run so later comparisons are valid. Ask your compliance or security reviewer which risk categories matter for your product and regulator, since general harm categories may not map cleanly to their expectations. Then keep the results as dated evidence of what was tested, with the scope, configuration and known gaps written beside them, so reviewers can see exactly what the scan did and did not cover.

Which public safety dataset answers which question

This table compares HarmBench, BeaverTails, XSTest and DoNotAnswer by the question each helps answer, the prompts it supplies and whether a Hugging Face token is needed. UnsafeBench and Aegis appear only for the token rule. Read each row before choosing a plugin, since one dataset's result does not show how the target handles the others. The main takeaway: only HarmBench's size and categories are documented here, so confirm token and scope details for the rest in the red team configuration docs.

DatasetQuestion it helps answerPrompts it suppliesHugging Face token
HarmBenchDoes the target refuse harmful behaviors from standard risk categories?400 behaviors across 7 risk categories, as documented in the promptfoo HarmBench guideConfirm in the red team configuration docs
BeaverTailsDoes the target give unsafe answers to prompts in the plugin's covered categories?Prompts drawn from a Hugging Face dataset, so the plugin depends on dataset accessYes, HF_TOKEN is required for authenticated access
XSTestDoes the target refuse safe requests that only look unsafe?Prompt set described in the red team configuration docs; confirm what it contains thereConfirm in the red team configuration docs
DoNotAnswerDoes the target decline requests it should not answer?Prompt set described in the red team configuration docs; confirm what it contains thereConfirm in the red team configuration docs
UnsafeBenchDoes the target respond safely to unsafe content in the plugin's categories?Hugging Face dataset; confirm its contents in the red team configuration docsYes, HF_TOKEN is required
AegisDoes the target respond safely to unsafe prompts in the plugin's categories?Hugging Face dataset; confirm its contents in the red team configuration docsYes, HF_TOKEN is required

Why BeaverTails, UnsafeBench and Aegis need an HF_TOKEN

The gated Hugging Face datasets behind the beavertails, unsafebench and aegis plugins cannot be read until the process running the scan authenticates with a token in the HF_TOKEN environment variable. Create that token under the service or team account that will run the scans, so scheduled scans keep working when one person changes roles. Before the first run, sign in as that account and open the dataset page for each of the three plugins. Confirm that the account can see each dataset and has accepted any access terms shown there. An account that cannot open a page fails in the same way as an account with no token, so this check is cheap insurance against a failed scheduled run.

Keep the token out of everything that is committed. Do not write it into the promptfoo configuration, prompt files, test files or a .env file stored in the repository. Put it in your CI system's secret store and expose it only to the jobs that run red team scans. Check that job logs do not print the variable when a step fails, and that debug output from promptfoo or the Hugging Face client does not echo it. Before you rely on this setup, read the red team configuration reference to confirm how each of these plugins reads the token and whether any plugin option accepts a token value directly.

Decide who owns the token before it is issued. Name a team or role responsible for it, record where it is stored, and set a rotation schedule that the owner tracks. Ask your security team whether your identity policy covers tokens issued to non-human accounts and how revocation is requested. When you rotate, create the new token, run one dataset load with it, and only then revoke the old one, so a rotation does not become an outage. Finally, confirm how a missing or invalid token appears in the promptfoo version your pipeline pins. Run a deliberate test with an empty HF_TOKEN in a non-production job and record the exact error text, so on-call engineers can recognize it when a scan fails.

How to set up a HarmBench run in promptfoo

This sequence takes a team from a fresh install to a reviewed HarmBench scan of an application it owns. Each step ends with a check, so you know whether to continue before generating more prompts. The output is a report with grader verdicts you have spot-checked, which is the basis for widening scope.

  1. Confirm Node.js and install promptfoo

    Run node --version on the machine that will run the scan and confirm it reports 22.22.0 or newer, the minimum Node.js version for promptfoo 0.124.1. Then install the pinned release with npm install -g promptfoo@0.124.1 so every team member scans with the same version. The engineer running the scan does this step. Check the install by running promptfoo --version and confirming it prints 0.124.1 before you continue.

  2. Export HF_TOKEN from a secrets store

    The engineer running the scan sets HF_TOKEN in the shell session, or injects it from your secrets manager into the CI job or runner. This is only needed when your plugins include beavertails, unsafebench or aegis, which require authenticated Hugging Face datasets. HarmBench is not on that list, so a HarmBench-only run may skip this step, but confirm in the red team configuration documentation. Keep the token out of promptfooconfig.yaml and shell history. Check that the variable exists without printing it, for example with test -n "$HF_TOKEN" && echo set, which should print set.

  3. Add the HarmBench plugin to your config

    The engineer who owns the target application adds the HarmBench plugin to the red team section of promptfooconfig.yaml, with the target pointing to an endpoint your team controls, such as a staging deployment of your own application. Keep the first configuration minimal: one target, one purpose statement and no other plugins, so any result traces back to HarmBench. Scanning a system you do not own is outside this setup, so confirm written permission before pointing a scan at any system. Check that the file loads without a configuration error when you run the generate command in the next step.

  4. Run a small scan and count prompts

    Set a low test count for the first run, using the test count key for each plugin (confirm the key name in the red team configuration documentation), then run promptfoo redteam generate followed by promptfoo redteam run. Confirm the number of generated prompts matches your limit for each plugin, since promptfoo's HarmBench guide documents the full set as 400 behaviors across 7 risk categories. If the count is far above what you set, stop and fix the configuration before more requests reach the target. Check that the generation output lists a prompt count per plugin that matches the limit you set.

  5. Review the report and grader output

    Open the report with promptfoo redteam report and go through each category and its failed prompts. For a sample of failed and passed prompts, read the grader's reasoning and compare it with your own judgment of the target's reply. Record any disagreements, because a grader that misreads refusals can make a safe application look unsafe or the reverse. Check that you have a written list of sampled verdicts, with disagreements noted and a decision on whether the grader is trusted for the next run.

  6. Widen scope after grader review

    Raise the test count or add plugins only after the sampled verdicts hold up. Confirm the planned volume with the owner of the target and against your plan's allowance, since the Community edition's published allowance is 10k probes per month. Rerun the full scan in the same environment, record the version and configuration used, and keep the report with the run record. Check that the full run's prompt count matches the planned number and that the report lists the same version, configuration and grader settings as the reviewed run.

What the safety datasets test and what a passing run does not prove

Each dataset gives you a score on a fixed set of prompts, and the score only means something once you know what it measures and where it stops. The six cards below cover what a refusal test checks, where it misleads, and the questions to answer before you cite a passing run to a reviewer.

Refusal of clearly harmful requests

HarmBench is the most direct test here. promptfoo documents evaluating against 400 HarmBench behaviors across 7 risk categories, and each behavior is a request the target should decline. Read a sample of refusals to confirm the target declines the request itself, and does not comply through a partial or reworded answer. Record which categories you ran, so the result is tied to a named scope.

HarmBench guide

Over-refusal of benign prompts

A dataset made only of harmful requests rewards a model that declines almost everything, so it cannot show whether a safe question about a sensitive topic gets blocked. Some public sets include benign prompts that look risky, which is what over-refusal testing needs. Check the plugin documentation for the dataset that targets over-refusal before you assume it is covered, and count how many benign prompts your target declines.

Red team configuration

Coverage limits of a fixed set

A fixed prompt set can only sample harmful behavior, so a clean result covers those prompts and nothing more. The set itself says little about rephrased versions, multi-turn pressure or other languages unless your configuration adds them. Compare the dataset's categories with the misuse your application can receive, and add cases where the set is silent. Record the scope in the report so a reader can see what the number covers.

Dependence on grader judgment

Every pass or fail is a judgment made by a grader about the response, so the score moves whenever the grader changes. Grading can differ by plugin, so the same kind of response may be scored differently across the sets you run. Read the grader used for each plugin in your run, sample passes and failures by hand, and record any disagreement before you set a threshold.

Fit between dataset and application

Public datasets are built around general harm categories, and your application may face misuse those categories do not name. A banking assistant and a coding agent, for example, receive very different requests. Map each dataset category to a concrete scenario in your product, mark the gaps, and write your own cases for them before you rely on the score. Ask domain owners to review the wording too.

What a clean run leaves out

A passing run shows how one target, with one model version, system prompt and configuration, handled these prompts on the day it ran. It does not show how the application behaves on live user traffic, which changes as users and features change. It is also not compliance evidence on its own, because independent auditors decide what counts, and they usually ask for controls, ownership and records.

How a public dataset moves through a promptfoo red team run

The run starts on the operator's machine, where promptfoo reads HF_TOKEN from the environment and fetches the gated dataset from Hugging Face. That fetch is the first trust boundary crossing, so check that the token has the narrowest access your team can accept and that it stays out of config files. The dataset prompts then move inside the team network to the target application, and its responses return to promptfoo. If a grader model is configured outside your network, the responses are sent across a second boundary for grading, so confirm where that model runs before sending sensitive output. The report is written to a local file.

Gated dataset prompts reach the target inside the team network.

Matching the dataset to the question you are answering

Start here when the question is whether the application refuses requests it should never fulfill. HarmBench is the most directly documented fit: promptfoo documents evaluating against 400 HarmBench behaviors across 7 risk categories, so you can see where refusals hold and where they fail.

  • Plugin: the HarmBench plugin, with BeaverTails or DoNotAnswer as additional sources of harmful prompts. BeaverTails needs a Hugging Face token (HF_TOKEN) because its dataset requires authentication.
  • What to measure: the refusal rate for each risk category. A strong overall average can hide a weak category, so review categories separately.
  • What to read: the full responses where the application complied, checked against the category each prompt belongs to.
  • What it cannot answer: whether refusals survive rephrasing, multi-turn pressure or tool use. Confirm whether attack strategies apply to these plugins before you assume that coverage.
  • What it cannot answer either: whether the application follows your own acceptable use policy, which these public datasets do not encode.

Before you trust the number, confirm the plugin identifiers and the grader used in the red team configuration docs.

Protecting tokens, test data and results

Public safety datasets bring two kinds of sensitive material into your environment: credentials that unlock gated data, and attack prompts with the model responses they produce. The cards below cover where each lives, who can use it and which systems receive it. Record each one as a decision your security team approves before the first run.

Scope and rotate HF_TOKEN

The beavertails, unsafebench and aegis plugins load Hugging Face datasets that require authentication through HF_TOKEN. Give each team or pipeline its own token, scoped to reading the gated datasets it needs, and confirm on Hugging Face which token type grants that access. Set a rotation date for every token, and replace it at once when someone with access leaves the team or a runner is retired.

Red team configuration docs

Store tokens in a secrets manager

Keep HF_TOKEN out of the config file, shell history and committed .env files. Store it in the secrets manager your organization already runs, or in a masked CI/CD variable, and inject it only into the job that loads a gated plugin. Check that CI logs never echo the value, and ask who can view or edit these variables, because anyone who can change a pipeline script can usually print them.

Keep prompts and reports in-house

HarmBench and the other datasets contain prompts written to elicit harmful output, and red team reports quote the model responses. Keep both in object storage or a file share your organization controls, with access limited to the people who review results. Set retention before the first run, and make sure exported result files are not copied to laptops or public chat tools. Confirm where the CLI writes local results on each runner before pipeline artifacts are kept.

Send prompts to approved parties only

A run sends each attack prompt to the target under test, and any LLM-based grader receives that target's responses. Both are data sharing, so list every target and grader provider your security or compliance team has approved, and reference only those in the provider and grader settings. Promptfoo runs on your machine and calls the providers you configure. During review, confirm that each hosted grader's data terms match your policy.

Avoid SQLite for production

The self-hosted promptfoo server stores data in a local SQLite database that cannot be shared across replicas. The server also has no RBAC, horizontal scaling, built-in authentication or SSO. The self-hosting documentation says this setup is not recommended for production use. Before sharing results across a team, compare the Enterprise and On-Premise editions, which add SSO and teams-based access control, and confirm with promptfoo what a production deployment requires.

Self-hosting docs

Questions teams ask before running public safety datasets

How much does running HarmBench and other safety datasets cost?

Most of the cost is model calls, and you pay for them in two places: the target model your application uses, and any grader model promptfoo calls to judge whether a response is unsafe. The promptfoo Community edition is free and includes red teaming with 10k probes per month, which the promptfoo pricing page lists, so a run within that allowance adds no promptfoo license fee. Your model provider bills the tokens. Costs rise with the number of behaviors, the number of strategies applied to each one, and the size of the grader prompt. The other cost is reviewer time. Every flagged failure needs someone who can decide whether it is a true failure or a grader error. Ask for a quote that lists the datasets, the probe count, the models called for target and grading, and the hours for review.

How long does a public safety dataset run take in promptfoo?

Time depends on the dataset size, the number of probes, the rate limits on your model endpoints, and how fast reviewers can clear failures. A single run mostly waits on model responses, so a target with low rate limits or a slow grader will stretch the schedule more than the configuration itself. promptfoo's HarmBench guide covers 400 behaviors across 7 risk categories, so a full pass is a different job from a sample run. A sensible first step is a small slice to check that the target endpoint, the grader and the report all work, then scale up. Confirm the time with your own environment: ask your model provider about rate limits and ask the team who will review failures how many they can clear each week. A fixed-scope engagement sets the timeline in writing before work starts.

What does a public safety dataset run need from our team?

Plan for three things before the first run: credentials, a target and a named reviewer. You need token access to the model provider used as the target and as the grader, and a Hugging Face token (HF_TOKEN) for plugins that require authentication to load their datasets, such as beavertails, unsafebench and aegis. You need a target endpoint that promptfoo can reach from where it runs, with the same system prompt, tools and guardrails that production uses, otherwise the results describe a different system. You also need a named reviewer who owns the failure list and decides what counts as a fix, a false positive or an accepted risk. Without that person, the run produces a report nobody acts on. Write these items into the scope so the first run starts with no blockers.

Can our own engineers run HarmBench tests in promptfoo themselves?

Yes, if an engineer is comfortable with the command line and can run Node.js 22.22.0 or newer, which the npm package requires. promptfoo is MIT licensed, runs locally on your machine and talks directly with the model under test, and the Community edition includes red teaming with 10k probes per month. The setup work is choosing plugins, setting HF_TOKEN where a dataset needs it, pointing the target at your endpoint and reading the results. The harder part is ongoing: keeping the configuration in version control, rerunning after model or prompt changes and making sure someone reviews each new failure. If you want outside help, DeployOpen can scope the setup, the review process or a retest in writing. Its work runs inside your own infrastructure, and the scope, deliverables and timeline are agreed before work starts.

Does running HarmBench make our AI application compliant?

No. Running public safety datasets produces test evidence about how one application responded to a set of prompts on a given date. It does not make the application compliant with any law, standard or certification. An assessor is likely to ask how the application is governed in your environment, how its controls work and how findings were handled, and those answers come from your controls, logs and review records. The promptfoo red teaming documentation lists the OWASP LLM Top 10, the NIST AI Risk Management Framework and the EU AI Act as frameworks that support systematic testing before deployment. Testing supports those frameworks; it does not satisfy them on its own. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those decisions.

Which public safety dataset should a team start with?

Start with the dataset that matches the harm your application is most exposed to, and run a small sample first. promptfoo's HarmBench guide covers 400 behaviors across 7 risk categories, which makes HarmBench a broad baseline across many kinds of harmful request. XSTest answers a different question: whether your application refuses harmless prompts that look risky, which matters for customer-facing products. DoNotAnswer and BeaverTails cover other refusal and safety scenarios. Check each plugin's configuration documentation to confirm what it tests and whether it needs HF_TOKEN, since the Hugging Face requirement is documented for beavertails, unsafebench and aegis. Pick one dataset, record the results and reviewer decisions, then add the next. A narrow first run makes it easier to tell whether a failure comes from the model, the prompt or the grader.

Limits to confirm before you rely on these datasets

These public datasets are useful for comparing models and catching obvious failures, but they answer narrower questions than a full safety review. The cards below cover coverage, usage limits, grading quality, legal terms, access and change control, and how results are shared on a self-hosted server. Confirm each one before you put a dataset result in front of a risk committee or an auditor.

HarmBench covers a fixed set

promptfoo documents HarmBench as 400 behaviors across 7 risk categories. Treat that set as a sample of harms, not a complete list. Your application may expose harms outside those categories, such as data leakage through a tool your team connected or misuse specific to your domain. Map each category to the risks in your own threat model, record the gaps, and cover them with custom tests or other plugins before you report coverage to anyone.

HarmBench guide

Community edition probe limit

The Community edition is free and includes red teaming with 10k probes per month, with community support. Every probe in a HarmBench or other dataset run counts against that same monthly allowance. Before scheduling scans, count the probes each dataset run will use across the models and strategies you test, and decide whether the team runs these sets on every change or on a fixed schedule. If the allowance is too small, ask for a written Enterprise quote tied to your expected scan volume, since that tier is priced on request.

Pricing page

Sample and check grader accuracy

Dataset tests pass or fail each response through a grader, and the grader can be wrong in either direction. Read a sample of passes and fails for each dataset before you trust the overall pass rate. Pull results from several categories, mark whether you agree with each grade, and record every disagreement with the prompt and response. If the grader misses unsafe answers or flags safe ones, adjust the rubric or the grader model and sample again. Keep the sample and your notes with the run so reviewers can see how the grades were checked.

Dataset licenses need legal review

Each public dataset carries its own license and terms on Hugging Face, and the MIT license that covers promptfoo does not decide how you may use a dataset. Ask legal to confirm the license and any use restrictions for every dataset you load, including those behind the beavertails, unsafebench and aegis plugins. Check whether internal evaluation, sharing results with customers and publishing sample outputs are permitted, and keep the license text with the evaluation record. Repeat the review whenever a dataset's terms change.

Gated access and dataset changes

The beavertails, unsafebench and aegis plugins need Hugging Face datasets that require authentication through HF_TOKEN. Confirm who requests dataset access, who holds the token, and how the token is stored and rotated. Upstream datasets can also be revised after you have run them, which can shift scores without any change to your application. Record the dataset revision or download date with each run so a later change in results can be traced to its source.

Red team configuration

Shared results on self-hosted promptfoo

Self-hosted promptfoo stores data in a local SQLite database that cannot be shared across replicas, and it has no RBAC, built-in authentication or SSO. The documentation does not recommend it for production use. Anyone who can reach the server can see every shared dataset result, so control access at the network layer. Limit the server to a trusted network or place it behind your own identity-aware proxy, and keep sensitive test content out of shared instances. Teams that need role-based access and SSO should confirm the Enterprise options before rollout.

Self-hosting docs

How DeployOpen scopes and supports a public dataset red team

DeployOpen treats a public safety dataset as one input to a red team, scoped against your application's purpose and risks. We agree the plugins, datasets and risk categories in writing, build and run the promptfoo configuration in your environment, and hand over the configuration, run records and documentation your reviewers can inspect.

How we scope

  • The written scope names which datasets and plugins run, such as HarmBench, BeaverTails or XSTest, and why.
  • Scope decides which HarmBench categories apply, from the 400 behaviors across 7 risk categories that promptfoo documents.
  • The written, fixed scope records deliverables, timelines and who supplies the HF_TOKEN for gated datasets.

How we build

  • Build the promptfoo configuration in your environment, with dataset loading, plugin selection and grading settings recorded in files.
  • Keep HF_TOKEN in environment variables or secrets management, outside the config files and version control.
  • Check probe volume against your promptfoo edition, since the Community edition includes 10k probes per month.

How we hand over

  • Hand over the configuration files, dataset versions, run outputs and a short note on what each dataset tests.
  • Document which safety categories each dataset covers, so reviewers can trace a finding to a specific plugin and dataset.
  • Record the promptfoo version and Node.js runtime used, so later reruns can match the original setup.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, agreed separately from the original scope.
  • Retainers can cover reruns after promptfoo upgrades, so results stay comparable across versions.
  • Confirm where results are stored, since self-hosted promptfoo's SQLite database is not recommended for production.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.