Scanning gguf models with llama.cpp in garak

Scanning gguf models with llama.cpp in garak lets teams test quantised models on hardware with no route to hosted APIs. This page explains the ggml generator setup, its checks, and where scans usually fail.

On this page

Scanning gguf models with llama.cpp in garak: what the integration does

If you must scan a model on hardware with no network path to hosted APIs, garak's ggml generator is the integration built for that job. It drives a local llama.cpp executable against a gguf model file on the same host, so each prompt garak sends and each response it scores stays inside your machine. garak is a command-line tool that probes language models for weaknesses such as prompt injection, jailbreaks and data leakage, and this generator simply gives it a local model to test in place of a remote service.

The wiring is deliberately small. The path to the llama.cpp main executable goes in the GGML_MAIN_PATH environment variable, and the path to the gguf model file goes in --target_name on the garak command line. garak then launches the executable for its attempts, so the scan has no hosted API calls to make and no API key to manage. The garak source for the generator, generators/ggml.py, is the place to confirm exactly how it invokes the executable in the version you install. The README lists gguf models served by llama.cpp version 1046 or later as supported, so check that your build meets that line before you plan a scan.

Running locally does not remove garak's own requirements. You still install garak from PyPI with pip, and the PyPI package requires Python 3.11 or newer, so the scan host needs that interpreter plus a virtual environment in which garak and its dependencies can be installed ahead of time. Confirm these steps on a connected staging machine first, because an air-gapped host needs every package and the llama.cpp build available from your own internal sources. Verify that the model file and executable match the versions you intend to assess, since a different quantisation or build can change the answers you get.

What you need before the first offline scan

An offline garak scan depends on four things working together: a llama.cpp executable, a garak install, a gguf model file and a host sized to hold the model. The last card covers the network check that makes the scan genuinely offline, which is the reason most teams take this route.

llama.cpp executable and version

garak's ggml generator calls the llama.cpp main executable directly, so that binary must exist on the scan host and be reachable by path. The garak README lists gguf support for llama.cpp version 1046 or later. Build or install a release at or above that number, record the exact build, and confirm the binary runs a test prompt before you point garak at it.

ggml generator source

garak install on Python 3.11+

garak is installed from PyPI with pip, and the PyPI package requires Python 3.11 or newer. On an air-gapped host, plan how the package and its dependencies arrive, either from an internal mirror or a vetted wheel bundle. Confirm the interpreter version first, because an older system Python is a common cause of a failed install.

garak on PyPI

The gguf model file and its licence

Confirm you hold the quantised gguf file you intend to test, its exact filename and checksum, and the licence terms that govern its use. Licence terms for model weights vary by publisher and may restrict internal evaluation or redistribution, so have legal review them before the file enters a restricted network. Record the model's provenance so the scan report can identify the exact artefact tested.

Host memory and disk for the quantised model

The host must hold the quantised model in memory while the scan runs, and it needs free disk for the model file, the llama.cpp build, garak's report output and the garak.log file that continues across runs. Memory needs depend on the quantisation level, context length and thread settings, so measure on the target hardware with a trial load. Ask your hardware and model owners for a sizing figure and treat any figure from a secondary source as unverified until you confirm it.

Confirm the host has no outbound route

An offline scan only stays offline if the host truly cannot reach hosted APIs or package mirrors during the run. Check the default route, DNS resolution and proxy settings, then test outbound connections to the endpoints you must block. Note that garak may fetch resources on first use, so run the install and any setup on a staging host first, then confirm the scan host has no outbound route before the test begins.

How to configure the ggml generator step by step

This sequence takes a team from an empty host to a verified garak run against a local gguf model through llama.cpp, with a checked executable, a configured environment and a readable report at each stage. It confirms the local path works before any full scan is committed.

  1. Build or obtain the llama.cpp main executable

    Your engineers either build llama.cpp from source on the scan host or copy a pre-built main executable that your change process has approved. Use a build version of llama.cpp that is at or after build 1046, which the garak README lists as supported for gguf models. Record the exact build so later reports can be traced back to it. The step is done when the executable starts and prints its help text without reaching the network, which you can confirm by running it with the --help flag on the scan host.

  2. Set the GGML_MAIN_PATH variable

    Set the GGML_MAIN_PATH environment variable to the full path of the llama.cpp main executable, so garak's ggml generator can find it without a network lookup. Put the export line in the shell profile or the job runner's environment file so every scan on that host uses the same binary. The step is done when echo of the variable prints the expected path and the file at that path is executable by the account that will run garak.

  3. Install garak in a virtual environment

    Create a Python virtual environment on a host with Python 3.11 or newer, then install garak from PyPI with pip inside that environment. Keeping garak in its own environment makes the version reproducible, which matters later when you compare reports across releases. Your team owns the choice of host and the mirror or artifact repository used for installation, so confirm that the package source is approved for the air-gapped or restricted network. The step is done when garak reports its version from the command line.

  4. Point the ggml generator at the gguf model

    Run garak with the ggml generator and pass the path to your gguf model file in the --target_name argument. The model file must already be on the scan host, because the generator does not download it. Use an absolute path and confirm the file name and quantisation match the model your team has approved. The step is done when a short prompt run returns generated text, which shows that garak launched the llama.cpp executable and read the model.

  5. Run a small probe set first

    Start with a narrow probe selection, such as a single probe family, and keep the default generation count so the run stays short. A small first run separates configuration faults from genuine model findings and shows how long one probe takes on your hardware. Scope the probe list in writing with the model owner beforehand so that the first run is a configuration test rather than an unplanned assessment. The step is done when garak completes the probe without crashing and reports a pass or fail result for each probe it ran.

  6. Confirm the JSONL report was written

    Locate the JSONL report that garak writes for each run and open it to check that it contains one record per attempt with its evaluation. Keep the report with the run's configuration, including the llama.cpp build, the model file and the garak version, so the result can be reproduced. The step is done when the report file exists, is not empty and holds the attempts from the probe you ran.

  7. Read garak.log for errors and warnings

    Open the garak.log debugging file and search it for errors, timeouts and warnings from the ggml generator and the llama.cpp process. This file continues across runs, so filter it by the timestamp of your test run. Failures to launch the executable, missing model files or out-of-memory messages usually appear here before they appear in the report. The step is done when the log for the test run shows no unexplained errors and your team has recorded any warnings and their causes before the full scan is scheduled.

How garak calls llama.cpp on the scan host

The flow starts in garak's harness, which runs each probe with its recommended detectors. The ggml generator hands each prompt to the llama.cpp main executable, located through GGML_MAIN_PATH, which reads the gguf model file named in --target_name. Responses return to the detectors, and results are written to the JSONL report and the continued garak.log. The dashed host boundary marks everything that runs locally. Check that no step in the path reaches an external network, and that the model file and executable are the versions you approved.

Local data flow from garak's harness through llama.cpp to the scan outputs.

How prompts, outputs and files move through the local scan

In this path there are no hosted accounts or API keys to manage, so the access question becomes host access. Anyone who can log in to the scan host, read the model file or run the llama.cpp executable can effectively run or observe the scan. Before the first run, decide who holds shell access to the machine, set file permissions so the gguf model file and the llama.cpp main executable are readable only by the service account or engineers who run scans, and confirm that the directory where garak writes its output is not shared with a wider group. The model path is passed through --target_name and the executable path through GGML_MAIN_PATH, so both locations should be fixed and documented so that reviewers can check which binary and which weights produced a given report.

Each run writes two kinds of local output, and both can contain sensitive material. The JSONL report records every attempt and its evaluation, and the attempts include the probe prompts and the model's generated text. The garak.log debugging file is continued across runs and can also capture prompts and responses at the verbosity you select. Treat both files as sensitive records of the test, not as neutral metadata. Confirm with your own configuration exactly what each file captures at the log level you use, because prompts that were designed to elicit harmful output may themselves be something your security policy restricts.

Set storage and retention before the first scan rather than after the report is produced. Place the output in an encrypted volume with restricted ownership, define how long reports and logs are kept, and decide how they are deleted or moved into an approved evidence store. Because garak.log continues across runs, plan rotation or archiving so that old attempts do not accumulate indefinitely. Ask your security and records teams which retention rule applies to security test data, and write that rule into the scan runbook so that every rescan follows the same handling.

Hardening the offline scan host

An offline garak scan is only as trustworthy as the host it runs on. The four controls below cover what the model and binary are, who can read what the scan produces, whether the network stays closed, and whether results can be reproduced later.

Protect the model file and binary

Store the gguf model file and the llama.cpp main executable on storage that only the scan account can write to. Record a checksum for each file when it is approved, and compare it before every scan. If either file changes, the probe results no longer describe the model you approved, so treat a mismatch as a stop condition and investigate before scanning again.

Check model provenance and licence

Before loading a gguf file, confirm where it came from, which upstream model it was converted or quantised from, and whether its licence permits your intended use and internal testing. Quantisation changes the weights, so a quantised file is a different artefact from the original model and needs its own record. Ask your legal and security teams to approve the exact file, not only the model family.

Restrict access to reports and garak.log

Each run writes a JSONL report of every attempt and a garak.log file that continues across runs. Both can contain prompts, model outputs and sensitive fragments the probes elicited. Limit read access to the people who review results, set restrictive file permissions on the output directory, and decide how long reports are kept and how they are moved off the host.

Confirm the host stays offline

An air-gapped claim needs evidence. Before a scan, verify that the host has no default route or outbound firewall path your policy forbids, and check that garak and llama.cpp do not reach out during a run. Record the network configuration with the scan output so an assessor can see the conditions under which the results were produced.

Pin the llama.cpp build

Results are only comparable when the same inference build produces them. Record the llama.cpp commit or release tag used, build it from a known source, and keep the binary unchanged for the life of the test series. Garak's README lists gguf support from llama.cpp version 1046 onward, so confirm your pinned build meets that requirement and document the version alongside each report.

Why a local gguf scan fails and how to fix it

This table lists the most common reasons a local gguf scan through garak's ggml generator stops or produces unusable output, with the likely cause and fix for each. Start with garak.log, which records the failing call, then work down the rows that match your symptom. The main takeaway is that most failures trace back to one of three settings: the executable path, the model path flag, or the llama.cpp version.

SymptomLikely causeFix
GGML_MAIN_PATH not found or generator errors on first callThe variable points to a missing file, a directory, or an old build locationSet GGML_MAIN_PATH to the full path of the llama.cpp main executable, then confirm it runs from the same shell that launches garak
Model not loaded or wrong model reportedThe model path was passed to a different flag than the generator expectsPass the gguf file path in --target_name, and check garak.log to confirm the path the generator received
Generations fail on a gguf file that loads elsewherellama.cpp build is older than the supported versionRebuild llama.cpp at version 1046 or later, as listed in the garak README, and point GGML_MAIN_PATH at the new binary
Executable stops partway through a runInsufficient memory or disk for the model and its working filesCheck free RAM and disk before the run, use a smaller quantisation, and watch garak.log for the point where output stopped
Install fails before garak startsPython is below 3.11, which the PyPI package requiresInstall Python 3.11 or newer in a clean virtual environment, then reinstall garak with pip
Report missing or overwritten after several runsOutput files were reused or the report path was not set per runGive each run its own report location, and archive earlier JSONL reports before rerunning
Log shows no useful detailLogging was not read from the start of the runOpen garak.log first, since it continues across runs, and search for the most recent run start line

Questions teams ask before scanning gguf models offline

Are garak and its ggml generator free to use?

Yes, garak is licensed under Apache 2.0 and developed in the NVIDIA GitHub organization, and the maintainers describe it as a free tool. The ggml generator ships inside garak, so it carries no separate license fee. Your costs come from the hardware that runs the scan, the staff time to set it up and operate it, and any outside help you buy. Confirm the license terms of the llama.cpp build and the gguf model you plan to load, since those come from their own projects and model publishers, not from garak.

How much effort does an offline gguf setup take, and what drives it?

The effort is mostly environment work rather than garak configuration. The main drivers are:

  • Model size and format: the model must be in gguf format and must fit in the memory and disk of the scan host.
  • Hardware: CPU-only or GPU-equipped hosts change build options and throughput.
  • llama.cpp build management: you need a compiled llama.cpp main executable that matches the version your garak release expects. The README lists gguf models with llama.cpp version 1046 or later as supported.
  • Offline packaging: Python 3.11 or newer, garak and its dependencies must be staged from an internal mirror because the host has no route to the internet.

Confirm each item against your own environment before you commit to a schedule.

How long does a scan take on local hardware?

Scan time depends on the model size, the hardware, and the probes you select. Each probe runs its prompts through the model, and by default garak makes 5 generations per prompt, so a broad probe selection multiplies the work quickly. A narrow run against a small set of probes finishes far sooner than a full sweep. Benchmark a short run on the actual host first, then extrapolate using the probe count you plan to run. Ask any partner to show that benchmark in their quote rather than accept a generic duration.

Can an in-house team run garak against gguf models alone?

Often yes, if the team already operates Python tooling on Linux or macOS and can build and maintain a llama.cpp executable. The steps are installing garak from PyPI, pointing GGML_MAIN_PATH at the llama.cpp main executable, and setting the model path in --target_name. Teams usually find the harder parts are reading the JSONL report, deciding which findings matter for their use case, and keeping the build reproducible across scans. Staff who have not used a red-teaming tool before should plan time for learning the probe and detector model.

What does the work need from our side?

Plan for four inputs. First, a scan host with the access you approve, and no outbound network path needed for the scan itself. Second, a gguf model your organization is cleared to load, including its license and provenance. Third, a named owner who signs off on the findings before any report leaves the team. Fourth, a decision on where the JSONL reports and the garak.log file are stored, since both record model outputs that may contain sensitive content. Put these in writing before the work starts so the scope and the sign-off path are clear.

Do the scan results count as compliance evidence?

A scan report is test output, not an audit finding. It shows what the probes produced against the model under the configuration you ran, and it does not certify the model or the system around it. Auditors and certification bodies decide whether your testing meets a given framework. Ask your compliance lead which evidence they need, such as the scan configuration, the garak version, the model hash and the dated report, and keep those records with each run.

When does an outside partner add value?

A partner is most useful when the scan must be repeatable across several models or hosts, when the air-gapped build and packaging need a second pair of hands, or when findings need interpretation before a security review. DeployOpen plans and implements self-hosted platforms inside your own infrastructure, including air-gapped networks, and runs security testing, including AI and agent security review. Most engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts, and a quote follows from that scope.

Where to check the ggml generator and supported versions

Check the generator source before you write a single config value. The ggml generator lives in generators/ggml.py in the NVIDIA/garak repository, and that file is the authority on how GGML_MAIN_PATH and --target_name are read. Open it from the release tag you plan to install, not only from the main branch, because the environment variable name, the expected path format and the way the model path is passed to the llama.cpp executable can change between releases. Record the file's commit or tag alongside your scan results so a later reader can tell which behaviour produced them.

Next, confirm the llama.cpp version statement in the NVIDIA/garak README. The README lists gguf models through llama.cpp as supported and gives version 1046 or later as the supported build. Treat that as the minimum you must test against, and confirm with the garak maintainers or the release notes whether any later llama.cpp builds have changed the executable's flags or output format. If your team pins a specific llama.cpp build for air-gapped hosts, run one short test scan against it before the full evaluation begins.

Finally, use the garak user guide for the current invocation syntax and then verify behavior on your own host. Run a small probe set against a model you already understand, read the garak.log output, and confirm that the executable actually loads the gguf file and returns generations. Keep a short note of the garak version, the llama.cpp build and the generator settings you used, so that any change in scores after an upgrade can be traced to a specific cause.

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.