Scanning fine-tuned models with garak before release

A fine-tune can remove safety behavior the base model had, and it can ship unsafe files. This page explains how to scan a customised model with garak before release, compare it to its base, and decide what to rerun after each change.

On this page

Why a fine-tuned model needs its own garak scan before release

Run garak against the fine-tuned model and its base model on the same probe set, and add a file check of the model artifacts, before the model ships. garak is the Generative AI Red-teaming and Assessment Kit, an Apache 2.0 licensed command-line LLM vulnerability scanner installed from PyPI with pip. The PyPI package requires Python 3.11 or newer. It probes a model for weaknesses such as prompt injection, data leakage, jailbreaks and toxic generation, and it writes a JSONL report of every attempt. A fine-tune can change refusal behavior, system prompt handling and the tone of outputs in ways the base model never showed, so the base model's results cannot be assumed to carry over.

The comparison is the point of the exercise. A fine-tuned model that fails on probes the base model passes has a regression introduced by your training data or method, and the team needs that finding before release. A fine-tuned model that fails on probes the base model also fails has inherited a weakness that the fine-tune did not fix. Keep the probe selection, generation count and detectors identical across both runs so that differences reflect the model and not the configuration. The same question applies to the artifacts: the file check examines the files associated with the target rather than running inference, so it covers risks that a prompt-based scan cannot see.

garak does not replace a human red team or an independent audit. It runs known attack patterns, and it will not find a weakness that its probes do not target, so confirm with your security team which probe families match your deployment before accepting a clean result. Ask whether your training data was reviewed for sensitive content, and record who approved the release decision and on what evidence. Treat the garak report as one input to that decision, stored with the model version it describes.

Which garak scan path fits your model artifact

If the fine-tuned model is published to the Hugging Face Hub, garak can load it through its Hugging Face generator and run inference on the scanning host. The same Hub location also supports a file-level check. The fileformats module source shows that the HF_Files probe examines model files associated with the target without sending prompts, so it can run alongside the inference scan.

  • Generator: The Hugging Face generator loads the model by its Hub identifier. Confirm the generator name and model argument in the current user guide before writing the configuration.
  • Access: Private and gated repositories need a token with read permission. Supply it through an environment variable, not a config file committed to version control.
  • Hardware: Inference runs on your host, so memory and accelerator capacity must fit the model size and precision.
  • File probe: Run the fileformats module against the repository to flag file types that can execute code on load, such as pickle-based weights. This step runs no inference.
  • Revision pinning: Record the exact commit hash so the scanned weights can be matched to the release candidate.

Check that the scanned revision matches the artifact you intend to ship.

How to compare the fine-tune against its base model

The base model is the control for a fine-tune. A single garak run against the fine-tuned model tells you which probes it fails, but not whether the fine-tuning caused those failures. To answer that, run the same probe selection, generations, system prompt and detectors against both the base model and the fine-tune, then compare the two sets of results. Keep the generator configuration identical except for the model name or endpoint, because any other difference (a changed system prompt, a different temperature or a different detector set) will show up as a false regression. garak makes 5 generations per prompt by default. Leave that value unchanged for both runs unless you have a reason to change it for both.

Read the results per probe, not as one overall score. When any attempt for a probe produces undesirable output, garak marks that probe as FAIL and records a failure rate, so the useful question is how the failure rate moved for each probe between the base and the fine-tune. Open the JSONL report from each run, which records every attempt and its evaluation, and line up the probes side by side. A regression is a change between runs, not an absolute pass or fail. A probe that fails on both models is a known weakness of the base model that the fine-tune inherited, while a probe that passes on the base and fails on the fine-tune is the finding that should block or delay release.

Keep each run in its own labelled directory, such as one folder per model and date. garak writes a garak.log debugging file that continues across runs, so runs written into the same location will interleave their logs and make it harder to trace which attempts belong to which model. Record the exact model identifier, the fine-tune's training data version and the garak version used in the folder name or a run note, because the comparison is only meaningful if you can reproduce both runs later. Ask your team to confirm how the fine-tune is served, since a different serving stack or quantization can change outputs even when the weights are the same.

Where the pre-release scan sits between fine-tuning and shipping

The flow starts when a fine-tune finishes in the training environment and its model files are copied to the artifact store. The scanning host then checks those files with the HF_Files probe before running any prompts, so a risky file type stops the release early. The base and fine-tuned models are then scanned on the same probe set, and the two reports are compared. Each fine-tune repeats this loop, so the decision to ship or retrain is always based on a fresh comparison.

Fine-tuned model moves through file checks and paired scans before the ship decision.

What the Hugging Face file probe checks and what it does not

garak's fileformats module works differently from its prompt-based probes. It examines files associated with the target rather than sending prompts and reading responses. The HF_Files probe looks at Hugging Face model files and flags those with file types that can be potentially vulnerable, such as serialized formats that can run code when loaded. Treat its output as a static check of artifacts only. A clean result tells you the files it inspects contain no flagged types. It does not tell you the model behaves safely, resists jailbreaks, or leaks training data. Those questions belong to the behavioral probe families you run against the model itself.

Before you rely on the probe, confirm the current list of file types it checks by reading the probe source in the garak repository, since the list is code and can change between releases. Record the garak version you ran, because a finding or its absence depends on that list. Also confirm which files the probe actually receives for your model. A fine-tune often adds adapter weights, tokenizer changes or custom loading code alongside the base checkpoint, and each of these needs to be in scope for the check to mean anything. If the probe is run against a repository reference rather than your local copy, make sure the files match what you will ship.

Decide in advance what your pipeline does with a flagged file. Options include blocking the release, converting the artifact to a safer format, loading it only in an isolated environment, or accepting the risk with a named owner and a recorded reason. The decision should be written into your release checklist before the first scan, not improvised after a finding. Keep the probe output with the rest of the run's JSONL report and garak.log so that the reviewer who signs off on the release can see which artifacts were checked and what was done with each flag.

Which probe families to rerun after each fine-tune

This table pairs common fine-tune changes with the garak probe families each change most plausibly affects. Treat it as a starting point to confirm against the probe catalogue in the garak docs, not as a standard, and widen the rerun whenever the training data or the deployment context is unusual.

Change typeProbe families to rerunWhy it matters
Instruction tuning on domain dataHallucination, misinformation, data leakageDomain examples can shift factual answers and may memorize records from the training set.
Safety or refusal tuningJailbreaks, prompt injection, toxicityRefusal behavior is the property most directly altered, so the earlier refusal results are least reliable afterward.
Adapter (LoRA) merge into base weightsJailbreaks, data leakage, prompt injectionA merge changes the weights the endpoint serves, so rerun the full set rather than assuming the adapter results carry over.
Quantization to ggufJailbreaks, toxicity, hallucinationLower precision can change refusals and output quality, and the scan should target the quantized file actually shipped.
Changed system promptPrompt injection, jailbreaks, data leakageSystem prompt text controls guardrail behavior and any secrets or policy it contains may leak under probing.
New or changed model files from the HubFile format checks (HF_Files probe in the fileformats module)The fileformats module examines files associated with the target rather than running inference, so it is a separate check from behavioral probes.
Multilingual or domain data addedToxicity, misinformation, jailbreaks (in the added languages)Refusal and safety behavior often differs across languages, so confirm translation support for the probes you select.

Where fine-tuned model scans go wrong

Most failed fine-tuned model scans come from the comparison, not the tool. The cards below cover the mistakes that make a garak result look clean when it proves little, or make two runs impossible to compare. Check each one before you sign off a release.

Comparing against the wrong base model

A comparison is only meaningful if the base model is the true starting point of the fine-tune. Teams often scan a newer or different checkpoint of the same family, or a model that was already instruction-tuned, and then read differences as the effect of their own training. Record the exact base model identifier and revision used for the fine-tune, then scan that model with the same configuration. The question to answer is what changed between that base and the candidate, so the base must be right before any delta means anything.

Changing generations or detectors between runs

garak's default is 5 generations per prompt, and a probe is marked FAIL when any attempt produces undesirable output. If the base run used one setting and the fine-tuned run used another, or a detector was added or dropped, the failure rates no longer measure the same thing. Pin the generation count, probe selection, detectors and any system prompt in a config file and reuse that file for every model in the comparison. Note any deliberate change in the run record so the reader can separate model effects from configuration effects.

Treating a PASS as proof of safety

A PASS means garak's probes did not produce undesirable output in the attempts it made. It does not show that the model is safe, and it does not cover attacks outside the probe set or variations the probes never tried. Fine-tuning can also erode refusals on topics the probes do not touch, such as domain-specific misuse. State in the release record which probe families ran and what they cover. Treat a clean scan as one input alongside application-level testing and human review.

Scanning a quantized file only

Teams often convert a fine-tuned model to a smaller quantized format, such as gguf for llama.cpp, and scan only the file they deploy. Quantization changes weights and can change behavior, so a result on the quantized build does not establish how the full-precision model behaves, or the reverse. Decide which artifact is the release candidate. If you ship both, scan both, and keep the results separate in your records. Confirm with your inference runtime which build serves production traffic.

Missing reruns after merges or adapters

A scan of the base fine-tune does not cover a later merge of adapter weights, a new LoRA layer, a model merge or a retrained checkpoint. Each change to weights can shift refusal behavior, so each one needs a decision about which probe families to rerun. Write that rule down before the next training cycle: which changes trigger a full rescan, which trigger a targeted rerun, and who signs off. Without it, the scan record describes a model that is no longer in production.

Keeping reports without version records

garak writes a JSONL report of every attempt and evaluation, and a garak.log file that continues across runs. Those files show results only if you also record the garak version, the probe and detector set, the generator settings and the exact model artifact. Without that metadata, a later reader cannot tell why two reports differ or reproduce the run. Store the config file and the garak version beside each report, and check the release notes before upgrading, since scores can shift between versions.

garak releases

Setting up a pre-release garak scan

This sequence gives you a repeatable pre-release scan that compares a fine-tuned model against its base model on the same probes, with reports stored against the exact model version. The output is a set of run records you can review, defend and rerun after the next fine-tune.

  1. Install garak in a Python 3.11 environment

    Create an isolated Python environment running Python 3.11 or newer, then install garak from PyPI with pip. Your ML or security engineer does this on the scanning host, which should be a Linux or macOS machine since garak is developed on those platforms. Record the exact garak version with the command reporting the installed version, and keep that string with the scan records. You know the step is done when the version command returns a value and the environment can start a help call without errors.

  2. Record the garak version and scan host

    Capture the garak version alongside the host details, Python version and the date of the run in a scan log kept with your model records. Pin the version in a requirements file so the same release is used for both the base and the fine-tuned scans. Version changes can shift scores, so note any later upgrade as a separate event. The step closes when a reviewer can rebuild the environment from the recorded pin and get the same garak version.

  3. Define base and fine-tuned targets in config

    Write one configuration file per target, or one file with two named generators, so the base model and the fine-tuned model differ only in the model identifier and any endpoint settings. Keep the generator type, sampling settings, system prompt and any serving parameters identical across both. Your ML engineer owns this file and the security reviewer checks that the only intended difference is the model. The step is done when a dry review shows the two configs diff to the model name and endpoint alone.

  4. Run the HF_Files check on model files

    Run garak's fileformats module with the HF_Files probe against the fine-tuned model's Hugging Face repository or local copy. This check examines the files associated with the target rather than sending prompts, so it reviews what a fine-tune delivered, including file types that can carry executable content. Your security engineer reviews the flagged files and confirms whether each one is expected in the release. The step is done when every flagged file has a recorded decision: accepted with reason, removed, or blocking the release.

  5. Run the same probe set against both models

    Run one probe selection against the base model and then against the fine-tuned model, using the same configuration apart from the target. Keep the probe list, generation count and detectors fixed for both runs so that failure rates are comparable. Each run writes a JSONL report and garak.log, and the run is complete when both finish without errors. Check that the report names the model identifier you expect for each run, because a wrong identifier means the comparison is invalid.

  6. Save JSONL reports and garak.log per run

    Store the JSONL report and the garak.log for each run in a directory named with the model, model version, garak version and run date. Do not overwrite earlier files, because garak.log continues across runs and needs to be separated per scan for review. Your compliance or release owner checks that each run folder contains both files and the recorded versions. The step is done when a run can be found and opened from its folder name alone.

  7. Review FAIL results against the base

    Open the summaries for both runs and list every probe marked FAIL, along with its failure rate. Treat a probe that fails on the fine-tuned model but not on the base as a regression to investigate, and read sample attempts in the JSONL report to judge whether the detector is correct. Record a decision for each regression: fix the fine-tune, add a mitigation, or accept with a named owner and reason. The step closes when every new FAIL has a written disposition.

  8. Store reports with the model version

    File the run records, the HF_Files decisions and the regression dispositions with the model version in your model registry or release record. Link the record to the base model identifier and the fine-tuning dataset version so the comparison can be traced later. This record is the evidence you will reuse when deciding which probe families to rerun after the next fine-tune. The step is done when the release record lists both run folders, the garak version and the decisions, and a reviewer who was not involved can find them.

Security and operational considerations for scanning model artifacts

A garak run against a fine-tuned model touches unreleased weights, live endpoints, credentials and a report full of adversarial prompts. Each of these needs an owner and a control before the first scan starts, not after the model is approved.

Unreleased weights on the scanning host

Scanning a local fine-tune means the weights, tokenizer and config files sit on the host that runs garak. Decide which machine that is, who can log into it, and whether the weights are copied or read in place. Confirm the host is inside the same access boundary as the training environment, and that the copy is deleted or moved under your retention rules once the scan is complete.

Network access for hosted targets

When garak calls a served endpoint, every probe is an outbound request carrying adversarial text. Confirm which hosts the scanning machine may reach, whether a proxy or egress policy applies, and whether the endpoint is a staging service that is permitted to receive test traffic. Record the endpoint address in the run configuration so the same target can be identified later.

Credentials for Hub and hosted APIs

Hugging Face Hub tokens, hosted model API keys and cloud credentials used by garak generators are long-lived secrets with access to private model repositories. Keep them out of configuration files committed to source control, scope them to the repositories and projects the scan needs, and rotate them after the release cycle. Check which account the scan runs under so usage appears in the right audit trail.

Report contents and retention

Each garak run writes a JSONL report of every attempt and its evaluation, and a garak.log file that continues across runs. These files hold the adversarial prompts and the model outputs that matched them, which can reproduce sensitive content from your fine-tuning data. Set a retention period for reports and logs before the first run, and decide whether the log is kept, trimmed or deleted with the report.

garak README

Access control on the report store

Reports that show a fine-tuned model failing a probe are sensitive before the model is released. Store them in a location with named access, separate from public project folders and from general CI artifact storage that many people can read. Grant read access to the release reviewers and the model owners, and log who opened or downloaded a report.

Confirming the scan setup with the vendor

Before the scan is approved, confirm the retention and logging behavior of any hosted service garak calls, and whether that service stores prompts for its own use. Check the garak version in use against the current user guide, since file layout and log handling can change between releases. Write these answers into the release record so reviewers can see what was tested and where the data went.

garak user guide

Questions teams ask before scanning a fine-tuned model

How much effort does a pre-release garak scan of a fine-tuned model take?

Effort depends mainly on how many probes you run, how many targets you compare, how many generations each prompt gets, and how fast the endpoint answers. garak makes 5 generations per prompt by default, so a probe set that runs against both the base model and the fine-tune doubles the calls before any retries. A narrow set limited to the probe families your fine-tune could plausibly weaken finishes far sooner than a full sweep. Ask for the probe list, target count and endpoint throughput in any quote, because those three numbers set the run time and the cost of the compute that answers the prompts.

Can an internal team run a garak scan on a fine-tuned model alone?

Yes, a team with Python and access to the model can install garak from PyPI and run it, since garak is a free, Apache 2.0 licensed command-line tool that requires Python 3.11 or newer. The harder part is interpreting results: a FAIL with a failure rate needs someone who knows the application to decide whether the output is a real weakness, and detectors are not perfect. Teams often run the scans in-house and bring in outside help for the endpoint wiring, the comparison design or the review of findings. The garak user guide covers the setup steps your engineers will follow.

What does the work need from our team before it starts?

A pre-release scan needs four things from your side:

  • Access to the fine-tuned model, either as weights for a local run or as an endpoint that garak can call.
  • A reference to the base model, with the same version and settings, so the two runs can be compared fairly.
  • A test environment that matches production closely enough for the results to mean something, including the system prompt and any guardrails in front of the model.
  • Someone accountable for reviewing FAIL results and deciding what blocks the release.

Missing the last item is the most common gap, because a scan without a reviewer produces a report nobody acts on.

How often should we rerun garak after each fine-tune?

Rerun after every fine-tune that changes model behavior, and use the change to choose the probe families rather than rerunning everything each time. A fine-tune on customer support data may affect data leakage and prompt injection probes more than a fine-tune on code, so map each training change to the families most likely to shift. Keep a full sweep for major releases and for a new base model. Also rerun after a garak upgrade, because scores can move between releases, and compare runs only when the configuration matches.

Does a garak report count as compliance evidence?

A garak report is testing evidence, but it is not a certification or an audit result on its own. It shows which probes ran, the configuration used, and how the model responded, which can support a compliance file. Auditors and certification bodies decide whether the evidence is sufficient for a given framework, so confirm the requirements with them before you rely on it. Keep the JSONL report, the configuration, the model version and the review record together, so the scan can be reproduced and explained later.

What does a garak scan of a fine-tuned model not tell us?

A garak scan does not prove a model is safe, because it tests only the attacks in its probe library and relies on detectors that can misclassify output. It also tests the model as configured at that moment, so changes to the system prompt, retrieval layer or guardrails can change the result. Treat the scan as one input to the release decision, alongside application-level testing and human review of the failures that matter for your use case.

Does a fine-tune need a full garak scan or only a subset of probes?

Start with a comparison against the base model on the probe families your fine-tune could affect, then widen the scope if the results or the risk profile call for it. Targeted runs are faster and cheaper, but they miss weaknesses outside the selected families. Document the choice in your release record, so reviewers can see why certain families were skipped and when they will be covered next.

How DeployOpen scopes and delivers fine-tuned model scans

DeployOpen treats a fine-tuned model scan as a bounded testing engagement with a written scope, a documented baseline against the base model, and a rerun plan for later fine-tunes. We test the model and its files in the environment where it will be served, then hand over the evidence your release team needs to decide.

How we scope

  • Agree which base model, fine-tuned checkpoints and serving endpoints fall inside the written scope before any scan starts
  • Confirm which probe families match the intended use, such as jailbreaks, data leakage and toxicity, and record why each is included
  • Define the release decision the results must support, and who signs off on accepting or blocking the model

How we build

  • Run garak against the base model and the fine-tuned model on the same probe set so differences are attributable to the fine-tune
  • Inspect the model files with garak's Hugging Face file probe in the artifact store, without running inference on those files
  • Set up repeatable run configuration and log retention inside your infrastructure so each candidate checkpoint can be rescanned

How we hand over

  • Deliver the JSONL reports, garak.log files and a written summary comparing the base and fine-tuned runs
  • Document the probe families rerun after each fine-tune, with the reasoning, so your team can repeat the process unaided
  • Provide a findings list with reproduction steps for every failing probe, and agree the retest scope in writing

How we support

  • Ongoing scan support, upgrades to garak releases and rescans for new fine-tunes are available as a retainer
  • Ask for the retainer terms, response expectations and what triggers a new scan in the quote
  • Confirm with DeployOpen how garak version changes will be handled so earlier comparisons remain interpretable

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.