hit@k and confidence intervals in garak results

garak's hit@k asks whether any of k attempts broke the target, and confidence intervals show how much a result can move. Here is how to read both and rebuild intervals for old reports.

On this page

Why a pooled garak pass rate understates the risk to your model

A pooled garak failure rate answers the wrong question for most exposure decisions. It tells you what share of all attempts produced undesirable output, but it does not tell you how many prompts broke the target, or whether a single prompt broke it every time. Pooling all attempts across prompts hides the prompts that fail repeatedly and the prompts that fail only once in five tries, and both patterns matter to an attacker who can simply retry. A low pooled rate can sit on top of a handful of reliably breakable prompts, and a moderate rate can come from many prompts that each broke the target once by chance.

garak runs 5 generations per prompt by default, and a probe is marked FAIL when any attempt produces undesirable output. The hit@k view, which follows the pass@k estimator, asks a different question: did at least one of k attempts breach the target? A run with run.generations set to 5 always reports hit@5, so the number matches the attacker's retry budget at that setting. Confirm the generation count in your configuration before you quote any hit@k figure, because a change to that setting changes what the figure means.

Teams need this reading in three places: executive reporting, where a single pooled percentage invites the wrong comparison; release gates, where the threshold should reflect whether an attacker could realistically retry; and comparisons between runs, where a shift in pooled rate may come from a change in generation count rather than in the model. Before you present results, check the generation count, the probe set and the garak version in the report header, and state which metric you are quoting so the reader can judge exposure correctly.

Which reading fits which decision

This table compares pooled attack success rate, hit@k at the configured generations, and per-probe confidence intervals. Each reading answers a different question, so pick the one that matches the decision in front of you and state its limits alongside the number.

ReadingQuestion it answersWhat it hidesWhen to report it
Pooled attack success rateWhat share of all attempts produced undesirable output across the run?Spread across probes and prompts, and whether one prompt was broken in any attemptTrend tracking for one fixed probe set and version, where the same method is applied each time
Hit@k at configured generationsDid at least one of k attempts breach the target for each prompt?How often a single attempt succeeds, so it reads higher than a typical user's experienceRisk framing for a determined attacker who can retry, such as a prompt that has to hold on every try
Per-probe confidence intervalsHow much certainty does the measured rate for one probe carry, given sample size and detector error?Cross-probe comparisons and whether a small difference is meaningful at allBefore claiming a change between runs, or when a probe result is close to a decision threshold
Hit@k with run.generations at 5Under the default setting, is hit@5 always reported, so the k value is fixed by configuration?Any effect of changing generations, which alters k and so the numbersWhen comparing runs, confirm that generations matched across them before reading differences
Intervals from an older reportWhat interval can be placed on a report written before interval support existed?Whether the original file was computed with the same method as current outputWhen a legacy report must be cited, after rebuilding intervals into a new file and keeping the original

How bootstrap confidence intervals account for sample size and detector error

A failure rate built from a small number of prompts can move widely on rerun, even when the target has not changed. If a probe runs against only a handful of prompts, one or two attempts flipping from pass to fail shifts the headline rate sharply. A bootstrap confidence interval addresses this by resampling the per-attempt results with replacement many times, recalculating the rate on each resample, and reporting the spread of those rates as a range. The width of that range reflects how much the observed rate would plausibly change if the same test were repeated on similar prompts. Read the interval as a statement about the sample you ran, not a guarantee about the model.

Two sources of uncertainty sit behind that range, and the interval only covers one of them directly. The first is sampling variation: the number of prompts and the number of attempts per prompt. More attempts narrow the interval, so a probe with a few prompts and the default five generations will usually show a wider range than a larger probe run. The second is detector error. A detector can label a safe response as a breach or miss a real one, and every resample inherits those labels. If the detector is systematically wrong on a class of responses, the interval will look tight while the underlying rate is still off. Before relying on an interval, confirm the detector's accuracy on the probe family you are reviewing, using the guidance in the sibling section on detector accuracy and false positives.

When you compare two runs, check whether their intervals overlap before treating a difference as a change in the target. Non-overlapping intervals are a useful signal, but overlapping ones do not prove that nothing changed, and a detector update between runs can move the rate without any change in the model. Record the detector version and the attempt count alongside each interval in your results log. If a finding will go to a risk owner, state the interval with the rate and note that the labels came from a detector with a known accuracy profile.

Rebuilding confidence intervals for reports created before CI support

This sequence takes a garak report written before confidence interval support and produces a separate rebuilt file with intervals attached, while leaving the original report untouched. It ends with a comparison against the original summary so you know what changed and whether the rebuilt file is fit to share.

  1. Identify reports that predate CI support

    Start by listing the JSONL reports you plan to compare or share and checking which were produced by garak versions that did not write confidence intervals. The owner of the scan history or the engineer who ran the scans can confirm the run dates and garak versions, and the garak release notes on GitHub show when interval support arrived. Keep a list of the file paths. This step is done when every report you intend to use is marked as either already carrying intervals or needing a rebuild.

  2. Confirm the input file path and environment

    Before running anything, confirm the exact path to the JSONL report and that the garak installation in the active Python environment is the one you expect. Run the tool from a working directory where you have write permission, since the rebuilt file will be created next to your output. Make a copy of the original report in a read-only archive location as an extra safeguard. This step is done when you can name the input path, the working directory and the installed garak version in your run notes.

  3. Run the rebuild_cis module on the report

    Run python -m garak.analyze.rebuild_cis against the JSONL file, passing the path to the report as the module's input as described in the garak reference for Reporting. Keep the console output, since it records which entries were processed and any errors. The engineer running the command should capture the exact command line in the scan log so the rebuild can be repeated later. This step is done when the command exits without errors and the console shows the report was read.

  4. Confirm the output name and location

    The module writes a new rebuilt file by default and does not change the original. Check the working directory for the new file and confirm its name clearly marks it as rebuilt, so no one mistakes it for the source report. If the output name or location differs from what you expected, read the module options in the garak reference before rerunning. This step is done when you can list both files side by side and the rebuilt file has a distinct name.

  5. Verify the original report is unchanged

    Compare the original report against the archived copy you made earlier, using a checksum tool such as sha256sum on Linux or macOS. A matching checksum shows the source file was not modified. Record both checksums in your run notes next to the rebuilt file's checksum. An engineer reviewing the evidence later can then confirm the source was not altered. This step is done when the original file's checksum matches the archived copy.

  6. Compare rebuilt intervals against the original summary

    Open the original summary and the rebuilt file and compare the per-probe and per-detector results. Look for changes in the reported rates, the sample counts and the interval bounds, and note any probe where the interval is wide because the number of attempts is small. Expect the pass and fail counts to match, since the rebuild adds intervals rather than re-running prompts. Differences in the counts mean something went wrong and the rebuild should be investigated before the file is used. This step is done when you have a short written note of the comparison and any unexpected differences are explained.

  7. Check the rebuilt file opens in the digest or viewer

    Generate the HTML digest with garak.analyze.report_digest from the rebuilt file, or load it in the garak report viewer, to confirm the file is readable by the downstream tools your team uses. Check that the intervals appear where expected and that the probe and detector names match the original report. If the digest fails to open the file, record the error and the garak version in use. This step is done when the digest or viewer displays the rebuilt results without errors and the intervals are visible.

  8. Record the rebuild in the scan history

    Add an entry to your scan history that names the original report, the rebuilt file, the command used, the garak version, and the checksums from the earlier step. Mark which file the team should use for comparisons from now on. Keep the original file in its archive, since future audits or reruns may need it. This step is done when the scan history lists both files and states which one is the reference for comparisons.

How attempts become hit@k and intervals

The diagram starts with probe prompts sent to the target through a generator, which produces attempts. Detectors score each attempt, and garak writes every attempt and its evaluation to the JSONL report, the source for everything after it. Per-prompt hit@k then asks whether any attempt for a prompt broke the target. Bootstrap resampling of those results produces the confidence intervals. For reports made before CI support, the rebuild path reads the same JSONL file and writes a new file, leaving the original in place. Check the detector outcomes in the JSONL before trusting either the hit rate or the interval.

Attempts flow from prompts to hit@k and intervals, with a rebuild branch.

How executives, engineers and auditors should read these numbers

A single failure rate invites a yes or no decision, but garak's output is a sample of attempts against a model or application, not a measurement of every way it can fail. Leadership needs the headline risk stated with its uncertainty, so the question becomes how confident the team is in the number and what the number does not cover. Ask for the hit@k figure for each probe family that matters to the business, and ask whether the interval around it is wide enough to change the decision.

  • Read hit@k as exposure, not frequency: A probe marked as failing means at least one of the attempts produced undesirable output, so the figure describes how easily the target can be broken, not how often users will hit the problem.
  • Check the interval before the headline: A wide confidence interval means the sample is too small or the detector is uncertain, so a single point estimate should not be presented as settled.
  • Ask which probes were run: A clean result only covers the probe families that were actually selected, so the scope of the scan matters as much as the score.
  • Separate the security aggregate from the detail: A single summary number hides which weaknesses drove it, so keep the per-probe view available when leadership asks why.

Before accepting a headline, confirm the scan scope, the number of generations per prompt and whether the interval is shown beside the figure.

Where hit@k and intervals can mislead a reader

A garak hit@k figure or confidence interval looks precise, and that precision is easy to over-read. The cards below cover the most common ways a reader draws the wrong conclusion from these numbers, and the check that catches each one before a finding reaches leadership or a ticket.

Narrow interval read as certainty

A tight bootstrap interval shows how much the result moves when the sampled prompts are resampled. It does not show that the model is safe or that the attack rate is known. Intervals also fail to reflect probe coverage, so a narrow band around a small, unrepresentative probe set can still mislead. Before quoting an interval, ask which probes produced it and how many attempts sit behind each one.

Clean hit@k at low generations

hit@k asks whether any of k attempts breached the target, so a higher k makes a breach more likely to appear. A run with few generations can show a low hit@k that simply reflects too few tries. Check the generations setting in the run configuration before treating a low figure as evidence of resistance, and compare runs only at the same k.

Detector error carried silently

Each hit depends on a detector labelling an output as undesirable. If that detector has false positives or misses real failures, the interval measures sampling noise around a flawed label, and the flaw does not appear in the bounds. Review a sample of hits by hand and consult the detector accuracy results before raising findings, since a tight interval can rest on a weak detector.

Mixing probe sets or versions

Two reports can carry the same model name yet differ in probe selection, detectors, or garak release. Their hit@k and interval values are then not measuring the same thing, and a difference between them may come from the setup rather than the model. Confirm that the probe set and garak version match before drawing a trend, and record both in every report you archive.

Aggregate without the per-probe view

A pooled attack success rate averages very different weaknesses into one number. A model can look acceptable overall while failing badly on a single probe family that matters for your application, such as data leakage or prompt injection. Read the per-probe and per-detector breakdown first, then use the aggregate only as a summary of those results.

Rebuilt intervals treated as original

Reports created before interval support can be recalculated with the rebuild_cis module. That command writes a new file and leaves the original untouched, but the rebuilt numbers are a recalculation from the saved attempts, not a result the run itself produced. Label rebuilt figures as rebuilt in any document, and keep the original report alongside the new file for audit.

garak reporting reference

Questions teams ask about hit@k and garak confidence intervals

How much effort does reading and rebuilding garak confidence intervals take?

The effort depends mostly on how many reports need work and how consistent their configurations are, not on the statistics themselves. Reading a single report and explaining hit@k to stakeholders is a short exercise for an engineer who knows garak. Effort grows when the team must reconcile several runs with different generation counts, probe sets or garak versions, check that each report's attempts and detector outputs are complete, and decide how intervals will be presented in leadership or audit material. A fixed-scope engagement lets you agree the number of reports, the output format and the review steps in writing before work starts, which makes the effort visible before you commit to it.

Can an internal engineer rebuild garak intervals without outside help?

Yes, a capable internal engineer can do this, provided they understand the report format and can verify their own output. The garak reference documents a rebuild command, python -m garak.analyze.rebuild_cis, which recalculates confidence intervals for reports created before CI support and writes a new file by default without changing the original. The harder work is judging whether the inputs are sound: that the run used the generation count you think it did, that detector behavior is understood, and that the numbers are explained correctly to non-specialists. Teams often keep ownership of routine rebuilds and bring in a partner for the first pass, the method review or a one-off backlog of historical reports.

What inputs does a partner need to rebuild garak results?

The core input is the JSONL report from each run, since it holds every attempt and its evaluation. Alongside it, the work needs the run configuration, including the probes and detectors selected, the number of generations per prompt and the target model or endpoint details. Detector details matter because intervals account for detector error, so the detector names and versions used in each run must be known. You should also provide the garak version used for each scan, the original output files if you want comparisons, and a note of any system prompts, buffs or harness settings. Missing configuration is the most common reason a rebuild cannot be trusted.

Can old garak reports get confidence intervals without rerunning scans?

In many cases yes, because the rebuild command recalculates intervals from existing report data rather than sending prompts to the model again. The garak reference states that the tool handles reports created before CI support and writes a new rebuilt file by default, leaving the original untouched. Rerunning a scan is only needed when the original report lacks the attempt data required for recalculation, when the target has changed since the scan, or when you want results under a different probe set or generation count. Confirm whether each historical file contains complete attempt records before you plan the work, and keep the original report as the record of what was run.

What drives the cost of an interval review or rebuild?

Cost follows the amount of judgment and verification needed, which is shaped by several factors. The main ones are the number of reports and models in scope, how varied their configurations are, whether the detector setup is documented, and whether results must be explained to auditors or executives. A one-time backlog of historical reports costs differently from a recurring check on each new scan. Ask any provider for a quote that separates the initial method review, the rebuild itself, the written explanation of results and any retesting, and state who keeps the rebuilt files and how they will be reproduced later.

Do confidence intervals make a garak result a formal compliance finding?

No. Confidence intervals describe how much uncertainty surrounds an observed attack success estimate given the sample size and detector error. They are useful evidence of how carefully a result was measured, but they do not certify that a system is secure or compliant. Independent auditors and certification bodies issue audit reports and certifications. DeployOpen prepares systems, controls and evidence for compliance assessments, so a rebuilt interval can be part of the evidence package, with its method, inputs and limitations documented so that an assessor can review it.

Which garak documentation should I read before starting this work?

Start with the garak reference page on reporting, which covers hit@k, the pass@k-style estimator behind it and the rebuild command for older reports. It explains that a run with generations set to 5 always reports hit@5, which is a useful check when you read your own results. Then review the garak README for the default behavior of five generations per prompt and the contents of the JSONL report and garak.log. Reading these together lets an internal team decide what it can handle itself and what it should hand to a partner. Confirm details against the version you actually ran, since reporting behavior can differ between releases.

Setting up a run that reports hit@k with usable intervals

This sequence produces a garak run whose hit@k figures and confidence intervals can be read and compared later. Each step fixes one input, from the install and Python version through the probe set and generation count, so the results describe what you intended to test.

  1. Confirm the Python version and environment

    The engineer running the scan checks that the host runs Python 3.11 or newer, since the PyPI package requires it, and creates a dedicated virtual environment for garak. The check is done when the interpreter version prints as 3.11 or higher inside the environment that will run the scan. garak is developed on Linux and macOS, so confirm that your host operating system matches one of those before you proceed.

  2. Install garak from PyPI

    Install the tool with pip inside the virtual environment, then record the exact installed version with the version command or pip show. Installing from PyPI keeps the version pinned to a release you can name in later comparisons. The step is complete when garak imports and reports a version number you have written down in the run notes.

  3. Fix the generations value and probe set

    Before any attempt is sent, decide the number of generations per prompt and the probes to run, then write both into a configuration file rather than typing them as one-off flags. garak defaults to 5 generations per prompt, and a run with run.generations set to 5 always reports hit@5, so this value determines which k the report uses. Commit the file to version control so the same settings can be reproduced.

  4. Point the generator at the target

    Configure the generator for your model or application, such as a supported hosted API or the REST generator with a short YAML file describing your endpoint. Send a single test prompt first and confirm that a plaintext or JSON response comes back in the expected shape. The step is done when the test response is captured and the endpoint answers without errors, since a misconfigured generator produces a report that looks valid but measures nothing useful.

  5. Run the scan with the fixed configuration

    Start the scan using the configuration file, and keep the probe set and generations unchanged for the whole run. Note the start time, the target identifier and the configuration file hash so the run can be matched to its report later. The run is complete when garak exits and prints its summary, and any interruption or changed setting should be treated as a new run with its own record.

  6. Confirm the JSONL report and garak.log

    Locate the JSONL report that garak writes for the run, along with the garak.log debugging file, which continues across runs. Open the JSONL file and confirm it contains attempt and evaluation entries for the probes you selected. The check is done when both files exist at the paths garak printed, and the log shows no fatal errors that would mean some probes were skipped.

  7. Check hit@k at the configured generations

    Inspect the report output and confirm that hit@k appears at the k value that matches your configured generations, for example hit@5 when run.generations is 5. If the expected k is missing, do not interpret the pooled rates until you have found out why, because the interval and hit@k figures depend on that setting. The step is complete when the k value in the report matches the configuration file you committed.

  8. Record the version and settings for comparison

    Write the garak version, the Python version, the configuration file, the probe set, the generator details and the report paths into a run record kept with the results. This record is what makes a later comparison valid, because scores can shift after a version change and runs with different probe sets are not directly comparable. The step is done when someone else could repeat the run from the record alone.

How DeployOpen scopes garak reporting work

A DeployOpen engagement starts with a written scope that covers how the garak run is designed, how its results are interpreted, and what is delivered. The cards below cover the parts that most affect how hit@k and confidence intervals are read, so the scope is agreed before any scan runs.

Run design and generation count

The scope records the target, probe selection, and the number of generations per prompt, since hit@k depends directly on how many attempts each prompt receives. A run with run.generations set to 5 always reports hit@5, so the scope states why that value was chosen and whether it matches how the application is used in production. Confirm the target endpoint, rate limits and cost of repeated attempts before the run is approved.

garak reporting reference

Interval method and sample size

The scope states which confidence interval method is applied, how the bootstrap is configured, and how small sample sizes are flagged. Narrow intervals can give false confidence when only a few prompts were tested, so the write-up reports the number of prompts beside every rate. Ask for the exact sample counts for each probe before accepting a headline percentage.

Detector error in the numbers

Interval width reflects sampling noise, not whether the detector labelled each attempt correctly. The scope includes a review of detector behaviour on the probes in use, including a hand check of a sample of hits. Confirm that the findings separate confirmed breaches from detector-flagged outputs that a reviewer has not yet examined.

Rebuilding intervals for old reports

Reports created before confidence interval support need recalculation before they can be compared with new runs. The scope covers running the rebuild step against copies of the original files, keeping the source reports unchanged, and recording the garak version used for each rebuild. Ask which version produced each historical file so that shifts from upgrades are not mistaken for changes in the model.

garak reporting reference

Findings write-up and retest

The findings write-up translates hit@k and interval results into statements a security owner can act on, with each finding tied to the probe, prompt set and detector that produced it. The scope defines the report format, who reviews the draft, and whether a retest is included after fixes. Confirm that the write-up states what the scan does not cover, so that a clean result is not read as a guarantee.

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.