7  Recipe: serve a tiny local model and run your first LLM01 scan end-to-end

Field Value
Tools ollama + garak
Section Getting started
Level easy
Time ~30 min (the model download dominates)
Layer/Category OPS / o-04 + ATTACK / a-02
Tags getting-started, first-scan, ollama, garak, llm01

7.1 Problem

A Kailash system (or any Linux box carrying its tooling) is in place. The goal is one loop that proves the whole stack works. The loop: serve a real model on a controlled port. Prove the endpoint is alive. Point the flagship LLM scanner at it. Read an actual report — all in one sitting, cheap enough to repeat after every change. This loop is the operator version of the OS spec’s own CI assertion. The CI side is the O-4 tiny-local-model + A-2 garak integration, nightly.

7.2 Solution

Both ends are manifest rows. Ollama (OPS, o-04, native, safety safe) serves the target. Garak (ATTACK, a-02, bespoke, safety requires-target) does the firing. Work the loop top to bottom:

# 1. Confirm both rows from the manifest view (also your first
#    `kailash info` run — see the CLI inventory recipe)
kailash info ollama   # -> OPS / o-04 / native / safety safe
kailash info garak    # -> ATTACK / a-02 / bespoke / requires-target

# 2. Pull the tiny test model (a sub-1B quant keeps every scan loop
#    short; the pull is roughly 0.7 GB of layers)
ollama pull smollm2:360m

# 3. Serve it bound to loopback ONLY — the blast-radius boundary
OLLAMA_HOST=127.0.0.1:11434 ollama serve

# 4. In a second terminal: prove health BEFORE the scanner touches it
curl http://127.0.0.1:11434/
curl http://127.0.0.1:11434/api/generate \
     -d '{"model":"smollm2:360m","prompt":"Reply with OK only.","stream":false}'

# 5. THE scan: OWASP-LLM01 scoped, 5 generations per probe, seeded for
#    reproducibility
garak --target_type ollama --target_name smollm2:360m \
      --spec tag:owasp:llm01 -g 5 -s 42

# 6. Read the run as a report (the JSONL file from step 5's banner)
garak --report garak_<timestamp>.jsonl

What success looks like:

  • ollama pull ends with a "success" line for the tag
  • ollama list shows smollm2:360m with a non-zero SIZE column
  • the root endpoint answers Ollama is running
  • the generate call returns one JSON object with a response field (streaming off)
  • the scan prints its banner and 📜 reporting to garak_<ts>.jsonl, then one progress line + per-detector scores per probe
  • the seeded run (-s 42) reproduces the same probe/target interaction set. Re-run after any config change and diff the reports

Expected output shape (abridged — the scan leg, shapes not transcripts):

garak LLM safety & security scanning tool v<version> ( https://github.com/NVIDIA/garak ) at <ISO timestamp>
📜 reporting to garak_<timestamp>.jsonl
...
🔍 probing <probe> (<n> generation(s))
   <detector>  passed  <n>/<m>

7.3 Discussion

  • Why this loop is the baseline: it is the smallest chain that exercises every layer contract at once. The chain spans a native OPS serving row (safety safe). It spans a bespoke ATTACK firing row (requires-target). The OWASP mapping (LLM01 in both manifest epochs) does the scoping. After a rebuild, re-run steps 4–6 as the smoke check.
  • Why loopback binding is mandatory: a scan target is a deliberate attack surface. Garak drives the model with adversarial prompts by design. A 0.0.0.0 bind puts that surface on the network. Bind 127.0.0.1 and keep the target on the lab box.
  • Why the endpoint and generator agree by default: garak’s Ollama generator defaults its host to 127.0.0.1:11434. That is the same loopback bind step 3 uses, so no extra wiring is needed. Move the port? Move both sides in the same change and re-verify health first.
  • Why -g 5 and -s 42, and no more: five generations per probe keep a scoped run quick, and the detectors still get samples. The seed makes the scan a regression test: change a system prompt or a guardrail, re-scan same-seed, diff. A first run answers one question — injection resistance (tag:owasp:llm01) — not the full catalogue. Scale up when a real engagement needs it.
  • The CI-side twin: the spec’s test chapter names integration-garak-local as the standing assertion of this pairing. The integration row: O-4 tiny local model + A-2 garak, one probe class, nightly flag. An operator who runs this recipe by hand can diff the results against the nightly record.
  • Alternate tiny model: the o-04 module’s notes name qwen2.5:0.5b (~0.4 GB, the module’s primary operator example). smollm2:360m is the smaller-tag alternative. Any sub-1B quant works. Pick one and keep it pinned for the loop’s baseline.

7.4 See also


Recipe provenance. Manifest rows (ollama: OPS/o-04 native safe, MIT; garak: ATTACK/a-02 bespoke, Apache-2.0, AML.T0051+T0054, LLM01 both epochs, requires-target) are read from the packages manifest, verified 2026-10-14 at main. The garak CLI surface (--target_type/--target_name/--spec/-g/-s, --report) is verified against upstream garak/cli.py at source HEAD and the packaged pin 0.17.1.pre1-unstable-2026-10-09 (pin source: pkgs/garak/default.nix + nvfetcher/_sources/generated.nix); the Ollama generator’s default host 127.0.0.1:11434 is its generators/ollama.py contract. The Ollama surfaces (pull, OLLAMA_HOST, /, /api/generate stream:false) are the upstream CLI/API contract. Pull sizes are registry-manifest sums (layer bytes at publish time; they move when quants update). Smoke status of the packaged garak binary on the darwin lane: recorded PENDING on kailash-os#81 — the full hands-on loop above has not been worked on a live boot yet; the spec’s integration-garak-local design is its CI-side instrument.