Automated attack generation with garak's atkgen probe

garak's atkgen probe uses a separate model to write attack prompts that respond to the target's replies. This page explains how it works, what its bundled model was trained on, and where it sits relative to TAP and GOAT.

On this page

What garak's atkgen probe does and when a team needs it

garak's atkgen probe uses a separate model to generate attack prompts intended to steer the target toward a failure mode. Unlike a fixed prompt list, each attack is shaped by what the target has just said, so the probe can keep pressing on a model that deflects the first attempt. It is the adaptive side of garak's static, dynamic and adaptive probes, which means it belongs in a scan when a team wants to go beyond prompts that were written in advance. The README describes atkgen as a prototype, and the bundled attacker is a GPT-2 model fine-tuned on hhrlhf attempts that yielded toxic output, so it should be treated as an experiment rather than a complete red-team capability.

garak is an Apache 2.0 licensed command-line tool installed from PyPI with pip install garak, and the PyPI package requires Python 3.11 or newer. Every run writes a JSONL report that records each attempt and its evaluation, which is the file you will use to see what the attacker produced and how the target responded. Before relying on atkgen results, confirm the Python version and dependency set on the hosts you will use, and check the garak user guide for the current configuration keys for the attacker model.

A team should consider atkgen when its current scan relies only on static prompts and it needs evidence that adaptive attacks were tried. Be clear with stakeholders about what it will not show: the bundled attacker is a small, older model, so a clean result does not mean the application resists strong adaptive attacks. For high-stakes applications, plan to compare atkgen output against more capable iterative methods such as TAP and GOAT, and confirm with the garak maintainers how the attacker model and its outputs are documented in the release you deploy.

How the attacker and target exchange turns during a scan

The atkgen loop turns a fixed prompt list into a conversation in which each attack is built from the target's previous reply. Each exchange is scored and logged, so the result shows what the target said at every step for review.

  1. Start the attacker model with its first prompt

    The atkgen probe loads a separate attacker model, distinct from the model under test. The attacker writes the first attack prompt, which is intended to guide the target toward a failure mode. Confirm in probes/atkgen.py how the opening prompt is set and whether it changes between runs. The step is done when a candidate attack prompt is ready to send to the target.

  2. Send the attack through the generator

    The probe passes the attack prompt to the garak generator configured for the target, such as a Hugging Face, OpenAI API or REST endpoint. The generator sends the prompt and collects the reply, which may arrive as plaintext or JSON depending on how the endpoint is described. Check that the full reply was captured before scoring begins. The step is done when the target's response is stored alongside the prompt that produced it.

  3. Score the response with detectors

    The detectors assigned to the probe examine the target's reply and decide whether it shows the undesirable behavior the probe is looking for. Each exchange receives its own pass or fail verdict. Confirm which detectors atkgen uses, since the README describes the probe as a prototype and the detector choice may not be the default one. The step is done when the reply carries a verdict.

  4. Feed the reply back to the attacker

    The attacker model reads the target's reply and produces the next prompt. This is the step that lets the attacks react to the target's wording instead of replaying a fixed list. Verify in the probe source that the reply is passed into the attacker's context, because this mechanism is the core of how atkgen works. The step is done when a new attack prompt exists that builds on the previous answer.

  5. Repeat the exchange until the loop stops

    The attacker, target and detector cycle repeats until the loop ends. The supplied facts do not settle the turn count or the stopping conditions, so check probes/atkgen.py for the maximum number of exchanges, any early stop after a failure, and how errors from the generator are handled. Record those values in your scan notes before comparing runs. The step is done when the loop has ended and every exchange has a verdict.

  6. Log every attempt to the JSONL report

    Each attempt and its evaluation are written to the JSONL report, and garak.log continues across runs for debugging. Each record pairs an attacker prompt, the target's reply and the detector verdict, so you can replay the conversation after the run. Open the report and confirm that the attacker-generated prompts appear in the entries before relying on the results. The step is done when the report holds a full record for every exchange.

  7. Apply the five-generation default per prompt

    garak makes 5 generations per prompt by default, and each generation is scored. The probe is marked FAIL with a failure rate when any attempt produces undesirable output. Confirm in probes/atkgen.py whether the generation count applies to each attacker turn or to the whole conversation, because that choice changes how many exchanges a run contains and how the failure rate should be read. The step is done when the probe shows a FAIL or PASS result with its failure rate.

Attacker, target and evaluator in one atkgen run

The run starts with the attacker model, a separate red-team model that writes an attack prompt for the garak harness to send. The harness passes that prompt to the target generator, which calls the endpoint under test and returns its reply. Detectors score the reply, and the harness writes each attempt and its evaluation to the JSONL report. Check that the attacker and target sit in separate trust boundaries, and that the target's reply goes back to the attacker so the next prompt reacts to it.

Attack prompts flow from the attacker through the harness to the target, then to detectors and the report.

Which atkgen configuration fits which testing goal

A quick check asks whether a bare model responds to attacker-style prompts that a separate model generates. The aim is a fast signal, not a complete assessment, so the setup should stay small and easy to repeat. Keep the target generator simple, with no system prompt, no retrieval and no tools, so any failure can be traced to the model itself. Remember that the attacker model bundled with atkgen is a prototype: the README describes a GPT-2 model fine-tuned on hhrlhf attempts that yielded toxic output. It is not a tuned red-team model, so treat its prompts as an exploratory sample rather than a measure of a model's full resistance.

  • Generator settings: Point garak at the target model with its default generation settings so results are comparable across runs.
  • Generation count: Start with the default number of generations per prompt, which garak sets at 5, and record it in the run configuration.
  • Detectors: Use the detectors that the probe recommends, and confirm in the run output which ones fired.
  • Interpretation: Read a FAIL as a sign that the model produced undesirable output for at least one attempt, not as a ranking of severity.
  • Scope limit: Do not use a clean quick check as evidence that the model is safe for deployment.

Before you rely on the result, confirm which attacker model version your garak release loads and what the atkgen source currently does.

Configuration options that change atkgen results

This table compares the settings that shape an atkgen run, from the attacker model to where reports are stored. Read each row as a decision: what the option changes, when it fits, and what to confirm in the current source before you standardize a configuration.

OptionWhen it fitsTrade-offConfirm before standardizing
Bundled attacker model (GPT-2 prototype)Quick trials that show whether atkgen can produce reactive prompts against your target at allDescribed in the README as a prototype fine-tuned on hhrlhf attempts that yielded toxic output, so it is not tuned for your policy or domainCurrent model identifier and whether the default still ships in the release you install
Substitute attacker model the team configuresRepeatable scans where you need a stronger or better-documented red-team modelYou own model choice, hosting, cost and licensing, and results shift when the attacker changesWhich model classes the probe accepts and how the attacker is loaded and called
Target generator type (REST, hosted API, local model)Matching the generator to the endpoint you will actually expose to usersA REST generator tests the full application path, while a bare model endpoint tests the model aloneThe generator configuration keys and how atkgen passes target replies back to the attacker
Generations per prompt (default of 5)Stable failure rates when you need more than one attempt per attackMore attempts raise run time and target calls, and the FAIL result reflects any single undesirable outputWhether atkgen uses the global default or its own generation setting
Detector setScoring with the detectors the probe recommends, or adding a toxicity or policy detector that matches your riskDetector choice changes what counts as a hit, so scores from different sets are not directly comparableWhich detectors the probe loads by default and how the harness selects them
JSONL report locationKeeping every attempt and evaluation for audit and for comparing runsReports grow with each run and may hold sensitive prompts and target outputs, so storage needs access controlsThe output directory setting and the report file naming used by your release
garak.log locationDebugging failed or odd runs and tracing errors across repeated runsThe log continues across runs, so entries from different configurations mix unless you separate runsLog path configuration and rotation behavior in your environment

How atkgen compares with TAP and GOAT

Iterative attack probes differ on several axes that matter for a scan plan. The cards below cover the differences a team should weigh before choosing atkgen, TAP or GOAT, and what to confirm in each case. Detailed probe behavior lives on the sibling TAP and PAIR and GOAT pages.

Attacker model quality

The attack is only as strong as the model generating prompts. atkgen uses a separate model that the README describes as a prototype GPT-2 model fine-tuned on hhrlhf attempts that yielded toxic output. TAP and PAIR use an attacker LLM chosen by the scanner operator. Before comparing results, confirm which attacker model each probe uses in your installed garak version and whether it can be swapped.

atkgen source

Adaptation across turns

Adaptive probes read the target's last reply and change the next prompt. Check in the atkgen source how much of the target's response feeds the attacker, and compare that with how TAP prunes and branches candidate prompts. A probe that does not adapt tests a fixed sequence of ideas, so a clean result says less about how the target handles pressure.

Single-turn or conversational

Some iterative probes return one crafted prompt, while others keep a conversation going. GOAT is built for multi-turn escalation, so its results describe conversational resistance. Confirm whether atkgen sends one prompt per attempt or carries history forward, because this decides whether its findings can stand in for multi-turn testing.

Compute and setup burden

Running a separate attacker model adds its own hardware, memory and install steps on top of the target scan. Ask your team to measure the load of atkgen's bundled model on the hosts you plan to use, and compare it with the cost of calling a hosted attacker LLM for TAP or GOAT, which moves cost to API usage. Record the setup steps so the next person can repeat them.

Reproducibility of results

Attack generation involves sampling, so two runs can produce different prompts. Fixed model versions, seeds where the probe supports them, and saved JSONL reports make a run comparable over time. Check whether each probe exposes a seed or temperature setting, and keep the attacker model version in your scan configuration so that score changes after an upgrade can be traced to the right cause.

Setting up atkgen in a garak environment

This sequence takes a scan host from a clean Python environment to a first atkgen run. Each step ends with a check, so you know the install, the target connection, the probe and the attacker model all work before you rely on the results.

  1. Create a Python 3.11 environment

    On the scan host, create a virtual environment with Python 3.11 or newer, because the garak package on PyPI requires that version or higher. Activate the environment and run the interpreter's version check inside it before installing anything. Choose a host that can reach the target endpoint and the model sources, since every later step depends on those connections. Done when the version check reports 3.11 or higher and the environment activates without errors.

  2. Install garak from PyPI

    Inside the activated environment, install the package with pip install garak. Check the garak README and the PyPI page for the current install instructions before you run the command. Then run garak's help output to confirm the entry point resolves. Record the installed version in your run notes, because later reports can only be compared against the same release. Done when the help output prints without import errors.

  3. Confirm the target answers a plain prompt

    Before adding any attack logic, point garak at the target with a harmless test prompt. Use the generator you plan to test, whether that is a hosted API, a Hugging Face model or a REST endpoint described in a short YAML file. The target must be reachable from this host, so check routes, firewall rules and credentials first. Done when the target returns a normal text reply and that reply appears in the run output.

  4. Confirm the atkgen probe is registered

    List the available probes and filter for atkgen to confirm that garak registers the probe in your installed version. Then run it once against the target generator you verified in the previous step. The atkgen probe is a prototype that relies on a separate attacker model, so the first run also needs that model to be available. Done when the probe name appears in the listing and the run starts without an unknown-probe error.

  5. Run atkgen from a fixed config file

    Move the generator, probe and generation settings into one YAML config file so that the run can be repeated. Store the file under version control and record the garak version and target identifier beside the output. Start the scan with that file. Watch the console and confirm in the log that the attacker model loaded from its source or from local storage. On air-gapped hosts, stage the model before the run, and ask the team that owns the host to confirm where it is stored. Done when the run finishes and each attempt is reported.

  6. Check the JSONL report and garak.log

    Open the JSONL report for the run and confirm it holds one record per attempt, each with the prompt, the target response and an evaluation. garak sends five generations per prompt by default, so expect repeated records for each prompt. Then open garak.log and look for errors from the attacker model, the generator or the detectors. Done when every attempt carries an evaluation and the log shows no unresolved errors. Treat a run with missing evaluations as incomplete, not as a passing result.

Security and operational risks of running an attacker model

Running atkgen means running a second model that produces harmful text, and every attempt it makes is written somewhere. The cards below cover the controls to plan for the attacker's output, the report files, the target's credentials, the network path to model hubs and how long scan artifacts are kept.

Toxic attacker output in logs

The atkgen README describes the bundled attacker as a prototype built on a GPT-2 model fine-tuned on hhrlhf attempts that yielded toxic output, so the attacker itself can emit offensive text. That text can reach the console, the garak.log debugging file and the JSONL report. Plan who can read those files, and confirm in your environment that the attacker's output is handled like any other harmful content before a scan starts.

atkgen source

Harmful prompts inside report files

Each garak run writes a JSONL report of every attempt and its evaluation, so the generated attack prompts are stored alongside the target's replies. Those prompts may contain harmful requests that were never meant to be kept. Restrict read access to report directories, decide whether reports leave the scanning host, and label them as sensitive test artifacts in your file inventory.

Keeping target credentials out of the attacker

The attacker model only needs the target's replies to react, not the endpoint address, API keys or session tokens. Configure the target generator with its own secrets and make sure the attacker's prompt template never includes configuration values or system prompts you consider confidential. Review the generated prompts in a sample run to confirm no secrets appear in them.

Egress when models come from hubs

When the attacker or target model is fetched from a Hugging Face Hub or similar source, the scanning host makes outbound network calls and downloads weights. In a restricted network this is a control decision, not a default. Plan an approved model source, pin the model version you tested, and decide whether the host may reach the internet at all during scans.

Retention rules for scan artifacts

garak.log is continued across runs, and reports accumulate in the output location, so artifacts from atkgen scans can outlive the test that produced them. Set a retention period with your data governance owner, confirm where garak writes files so deletion covers all of them, and apply the same rule to any copies sent to ticketing or evidence systems.

garak user guide

Isolating the attacker runtime

Because the attacker runs as a model with its own dependencies, treat its host as an untrusted component. Run it under a dedicated account with no access to production secrets, limit its filesystem and network access to what the scan needs, and keep the Python environment separate from the one that holds other tooling. These are controls to plan and verify, not guarantees the tool provides.

Required Python version
3.11+

Questions teams ask before running atkgen

Is atkgen enough on its own to test an LLM application?

No. atkgen is one probe among many in garak, and it generates attack prompts that react to the target rather than running a fixed list. A fixed-suite scan covers known attack families consistently from run to run, and iterative probes explore how a model responds to pressure over several attempts. Using atkgen alongside both gives broader coverage than any one of them. The bundled attacker is a prototype, so treat its results as one signal in a wider test plan, not a complete assessment of the application.

What drives the effort of an atkgen run?

Effort is driven by four factors. The first is target complexity, since an application with tools, retrieval or multiple roles needs more scoping and more result review than a bare model. The second is generation count, because garak makes 5 generations per prompt by default and every extra attempt adds calls to the target. The third is endpoint rate limits, which set how long a run takes against a hosted service. The fourth is whether a substitute attacker model must be hosted, which adds infrastructure, GPU or hosting work and its own maintenance. Ask any partner to show how each factor applies to your endpoint before agreeing a plan.

Can our own team run atkgen without outside help?

Yes, if garak is installed on a machine that can reach the target and the team is comfortable with the command line. garak is a free, Apache 2.0 licensed tool, installed from PyPI with Python 3.11 or newer, and each run writes a JSONL report and a garak.log file. The harder part is interpreting results against your own policy. Deciding whether a generated response is a genuine failure for your use case, and which findings matter, usually needs security staff who know the application's data and permissions. Plan for that review time before you start.

What would a partner do for an atkgen engagement?

A partner typically covers scoping, configuration, evidence and retest. Scoping agrees which application surfaces, data and failure definitions are in and out. Configuration sets up the garak generator for your endpoint, the probe selection, generation counts and detectors so the run is repeatable. Evidence turns the JSONL output into a findings record with reproduction steps and an explanation of what each failure means for your policy. Retest confirms whether fixes changed the result. Costs come from a written quote tied to that scope, and the quote should separate one-time setup from any recurring scans.

What do we need to provide before an atkgen scan?

The core inputs are endpoint access, test accounts and a scan window. Endpoint access means a reachable URL or API that accepts the prompts garak sends, with a description of its request and response format so the REST generator can be configured. Test accounts should have the same roles and permissions as real users, so results reflect actual exposure. Policy definitions state what counts as an undesirable output for your organization. A scan window agrees when testing can load the target and generate traffic without disrupting users or breaching provider terms. Confirm any rate limits and logging rules with the system owner first.

How does atkgen compare with TAP and GOAT?

atkgen uses a separate model to generate prompts aimed at a failure mode, and the bundled attacker is a prototype trained on GPT-2 fine-tuned with Anthropic's hhrlhf attempts that yielded toxic output. TAP and GOAT are iterative attacks that use an attacker model to refine prompts over several rounds, with GOAT escalating across conversational turns. Their coverage depends on the attacker model and the compute spent per attack. Confirm the current attacker and probe behavior in the garak source and user guide before relying on any comparison, since probes change between releases.

What should we confirm about atkgen's attacker model before using it?

Confirm three things. First, which attacker model the probe loads in your installed version, since the bundled model is a prototype and its training data is specific to toxic-output generation. Second, whether your policy cares about the kind of output it targets, because a probe built around toxicity may not reflect data leakage, unauthorized tool use or prompt injection risks in your application. Third, whether a substitute attacker must run in your infrastructure, which affects data handling and approval. Record the garak version used, because results can shift between releases.

When atkgen belongs in a garak scan plan

Use atkgen as an exploratory, adaptive check that sits alongside garak's static and template-based probes, not as the measure of whether an application resists attack. Its value is that it produces follow-up prompts that react to what the target said, so it can reach failure modes a fixed prompt list will never contain. Its limits are equally important: the bundled attacker is a prototype, so a clean atkgen run is a weak signal of safety, and a failing run tells you something real about the target that a team should reproduce and fix. Treat its results as a complement to the static suite, reported separately so they do not inflate or mask the fixed-probe pass rates.

A guarded application benefits from reactive prompts when its defenses were tuned against known phrasings. A system that refuses a list of published jailbreaks may still give way when a follow-up responds to its refusal wording, its persona or its partial answers. A fixed suite is usually enough when the application is a narrow tool with a short, controlled input surface, when the question is regression testing after a model or prompt change, or when the team needs repeatable results for an audit trail. In those cases, a stable set of probes run with the same configuration every time is easier to compare across releases than a generator whose output changes between runs.

Choosing among atkgen, TAP and GOAT depends on three things: the attacker model you can justify, how the target handles conversation, and the evidence you must produce. Confirm with the garak documentation which attacker model each probe uses and whether it is bundled or must be supplied, since that determines cost, reproducibility and what you can explain to a reviewer. Multi-turn designs such as GOAT suit chat products with memory, while single-exchange APIs may not need that depth. Record which probe produced each finding so the report shows the method behind every result. Start with the garak user guide to confirm current probe options before fixing the plan.

How DeployOpen scopes and delivers garak atkgen testing

DeployOpen treats atkgen as one probe inside a wider garak testing plan for your application, not as a standalone test. We agree in writing which target, attack goals, and evidence the atkgen work covers, then build and run it in infrastructure you control.

How we scope

  • Written scope names the target endpoint, the failure modes to test, and the attacker model used for atkgen runs.
  • Scope states whether atkgen runs alongside other garak probes, and which detectors judge the attempts.
  • Engagements are fixed-scope, so deliverables and timelines are agreed in writing before any testing starts.

How we build

  • We install garak on Python 3.11 or newer and configure a REST generator for your application endpoint.
  • We set up the atkgen attacker model and confirm it runs in your environment before any target testing begins.
  • We run atkgen with agreed generation counts, then review failures against the detectors and your policy.

How we hand over

  • You receive the JSONL report of every attempt and evaluation, plus the garak.log file from each run.
  • A findings document explains each failure, the conditions that produced it, and suggested fixes for your team.
  • We walk your security and engineering staff through the runs so they can repeat the configuration themselves.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers for teams rescanning after model changes.
  • Retainers can cover garak version upgrades, so comparisons across runs stay meaningful to your reviewers.
  • Confirm with us which garak release and atkgen configuration each retained rescan will use before it runs.

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.