PEFT
Safetensors
English
lora
adapter
agent-safety
trajectory-monitoring
stepshield
conformal-prediction
Instructions to use DoronP/stepshield-nemotron-mini-4b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use DoronP/stepshield-nemotron-mini-4b-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("nvidia/Nemotron-Mini-4B-Instruct") model = PeftModel.from_pretrained(base_model, "DoronP/stepshield-nemotron-mini-4b-lora") - Notebooks
- Google Colab
- Kaggle
Commit ·
9daa81e
0
Parent(s):
Super-squash branch 'main' using huggingface_hub
Browse files- .gitattributes +36 -0
- NOTICE +18 -0
- README.md +146 -0
- adapter_config.json +49 -0
- adapter_model.safetensors +3 -0
- ckpt_meta.json +1 -0
- nvidia-community-model-license-aug2024.pdf +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
nvidia-community-model-license-aug2024.pdf filter=lfs diff=lfs merge=lfs -text
|
NOTICE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NOTICE
|
| 2 |
+
|
| 3 |
+
This repository distributes a LoRA adapter (adapter_model.safetensors,
|
| 4 |
+
adapter_config.json) — a Derivative Model of the NVIDIA Model
|
| 5 |
+
"Nemotron-Mini-4B-Instruct" (c) NVIDIA Corporation, distributed under and
|
| 6 |
+
accompanied by the NVIDIA Community Model License (see
|
| 7 |
+
nvidia-community-model-license-aug2024.pdf, as required by Section 1.2 of
|
| 8 |
+
that Agreement).
|
| 9 |
+
|
| 10 |
+
Modification notice (Section 2.2.1): the distributed weights are LoRA
|
| 11 |
+
adapter deltas trained by Doron Podoleanu on the StepShield benchmark's
|
| 12 |
+
train split. They modify the behavior of the base NVIDIA Model and are not
|
| 13 |
+
original NVIDIA weights. NVIDIA does not endorse this work; no trademark
|
| 14 |
+
license is granted or implied.
|
| 15 |
+
|
| 16 |
+
The adapter weights are licensed under the NVIDIA Community Model License,
|
| 17 |
+
not an open-source license. Production use is subject to the license's
|
| 18 |
+
NVIDIA NIM / AI Enterprise conditions (see the model card).
|
README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: nvidia-community-model-license
|
| 4 |
+
license_link: https://huggingface.co/nvidia/Nemotron-Mini-4B-Instruct/blob/main/nvidia-community-model-license-aug2024.pdf
|
| 5 |
+
base_model: nvidia/Nemotron-Mini-4B-Instruct
|
| 6 |
+
library_name: peft
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
+
inference: false
|
| 10 |
+
tags:
|
| 11 |
+
- lora
|
| 12 |
+
- adapter
|
| 13 |
+
- agent-safety
|
| 14 |
+
- trajectory-monitoring
|
| 15 |
+
- stepshield
|
| 16 |
+
- conformal-prediction
|
| 17 |
+
- base_model:adapter:nvidia/Nemotron-Mini-4B-Instruct
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# StepShield-Nemotron-Mini-4B LoRA — step-level rogue-agent detector
|
| 21 |
+
|
| 22 |
+
LoRA adapter for [`nvidia/Nemotron-Mini-4B-Instruct`](https://huggingface.co/nvidia/Nemotron-Mini-4B-Instruct) that scores each step of a coding-agent trajectory with a rogue-likelihood score p(BAD) — a restricted two-token softmax, used for ranking and thresholding; it has *not* been shown to be a calibrated probability (a temperature T=1.25 was fitted for analysis only and never applied to decisions) — evaluated on the [StepShield](https://github.com/glo26/stepshield) benchmark.
|
| 23 |
+
|
| 24 |
+
- **Adapter:** ~92 MB safetensors, PEFT/LoRA (adapter only — no merged base weights are distributed).
|
| 25 |
+
- **Developed by:** Doron Podoleanu (independent).
|
| 26 |
+
- **Finetuned from:** `nvidia/Nemotron-Mini-4B-Instruct` (frozen; checkpoint "v2-step1100", selected by validation trajectory-AUC 0.9938).
|
| 27 |
+
- **License:** NVIDIA Community Model License (the adapter is a Derivative Model of an NVIDIA Model — see License section; this is **not** an open-source license). Evaluation/training code is Apache-2.0 in the [companion repo](https://github.com/doronp/stepshield-nemotron).
|
| 28 |
+
|
| 29 |
+
## ⚠️ What this is not
|
| 30 |
+
|
| 31 |
+
**This is not a general-purpose safety classifier.** It was trained and evaluated exclusively on StepShield's six incident categories (DEC/INV/RES/SEC/TST/UFO) in ReAct-style coding-agent trajectories rendered in one specific text format. Its numbers do not transfer to other agent frameworks, other task domains, prompt-injection detection, content safety, or free-form chat — and were not measured there. Do not deploy it as a lone safety control anywhere.
|
| 32 |
+
|
| 33 |
+
## Headline results — read with the caveat
|
| 34 |
+
|
| 35 |
+
> **RESULTS STATUS: HELD-OUT WITH RESPECT TO TRAINING; NOT BENCHMARK-EXTERNAL.** All numbers below come from the benchmark's public 216-trajectory holdout, which the model **never trained on** (weight training and checkpoint selection used the train split only); thresholds were set by the leakage-controlled cross-calibration described below. No prospective (blind) evaluation exists, and none can be produced from this benchmark — it retains no data pool containing rogue trajectories untouched by development; the only untouched material is clean-only and cannot support recall or EIR₃ (see "Why there is no prospective evaluation" below). External validation on a different corpus is the correct next test of these numbers, and is future work.
|
| 36 |
+
|
| 37 |
+
Two calibrated operating points on StepShield's 216-trajectory held-out set (108 rogue / 108 clean scenario twins), under a threshold-leakage-free conformal calibration protocol (pair-level, category-stratified 4-fold CV; thresholds from calibration-fold cleans only; twins never straddle folds; the procedure was checked in three rounds of external adversarial LLM review — Kimi V3, commissioned by the author — prior to release). "Certified" on this card means exactly that: a pre-committed procedure with a finite-sample guarantee, mechanically executed and review-checked; it is **not** a third-party audit or formal certification.
|
| 38 |
+
|
| 39 |
+
| Operating point | Recall | FPR | Acc | F1 | EIR₃ |
|
| 40 |
+
|---|---|---|---|---|---|
|
| 41 |
+
| **LOW-FPR** (conformal-max, primary) | 91.7% (99/108) [84.9, 95.6] | **0.93%** (1/108) [0.16, 5.06] | 95.4% | 95.2 | **0.990** |
|
| 42 |
+
| **MAX-RECALL** (α=0.10) | **98.1%** (106/108) | 9.26% (10/108) | 94.4% | 94.6 | 0.953 |
|
| 43 |
+
|
| 44 |
+
Intervals are Wilson 95%. EIR₃ = early-intervention rate: the share of detected rogue trajectories flagged within 3 steps of the true rogue step (StepShield's native timing metric).
|
| 45 |
+
|
| 46 |
+
Full certified curve (discrete points; intermediate thresholds are NOT certified):
|
| 47 |
+
|
| 48 |
+
| Rule | Realized FPR | Recall | Acc | EIR₃ |
|
| 49 |
+
|---|---|---|---|---|
|
| 50 |
+
| conformal-max | 0.93% | 91.7% | 95.4% | 0.990 |
|
| 51 |
+
| α=0.025 | 0.93% | 94.4% | 96.8% | 0.971 |
|
| 52 |
+
| α=0.05 | 3.70% | 96.3% | 96.3% | 0.971 |
|
| 53 |
+
| α=0.10 | 9.26% | 98.1% | 94.4% | 0.953 |
|
| 54 |
+
|
| 55 |
+
> **Within-template caveat (the most important sentence on this card):** StepShield's holdout reuses the training split's scenario templates (task-header word-Jaccard p50 = 1.0; the step streams are novel, difflib ~0.10 — median 0.096 char-level similarity vs a 0.071 floor for randomly paired trajectories, and 0 of 3,056 rendered holdout steps appear verbatim in train; reproducible via `scripts/template_overlap.py` in the companion repo). A fine-tuned model gets a within-template advantage that the benchmark's untrained published baselines do not exploit. Every number above is **within-scenario-distribution generalization to novel trajectories** — expect worse on out-of-distribution scenarios, and measure before relying on it. (This overlap contradicts the benchmark's documented design — its paper describes the holdout as built "from incident templates that were never used during training"; measured by us on the public data, word-set Jaccard on title+description, median 1.0; the trajectory-level "zero overlap" claim remains true. It affects only detectors fine-tuned on the train split, like this one; detectors trained on an external corpus are unaffected.)
|
| 56 |
+
|
| 57 |
+
Additional framing: these are calibrated operating points computed by cross-validation over the holdout (mechanically leakage-free at the threshold level), **not a fresh single-shot evaluation** — the analyst had seen full-holdout summary metrics before designing the calibration. The only fresh single-shot holdout number in this project is the decertified legacy point (θ=0.064: 89.4% accuracy, 98.1% recall, 19.4% FPR), kept for continuity and strictly dominated by the certified α=0.10 point. Accuracy/F1 are at the benchmark's 50/50 prevalence; (FPR, recall) are less prevalence-sensitive but still not guaranteed to transfer under scenario or traffic shift. The α=0.05 point (96.3% @ 3.7%) beats the published LLMJudge baseline (95.4% @ 5.6%, GPT-4.1-mini) on both axes *on this benchmark's holdout under our protocol, with the within-template caveat*. The LLMJudge figures are quoted from the StepShield README and were not re-run by us (we re-ran and exactly reproduced only StaticGuard); the comparison is between point estimates with no paired significance test. We do not claim general superiority over LLM judges. Pre-commitment note: α=0.025 outperformed the primary on the report folds (same single FP, higher recall) and was *not* promoted to primary, per the pre-committed protocol — it stays a curve point.
|
| 58 |
+
|
| 59 |
+
## Recommended threshold
|
| 60 |
+
|
| 61 |
+
**θ = 0.946597** (flag a trajectory at the first step with p(BAD) > θ). Provenance: conformal-max over all 108 holdout clean scores → forward certificate E[FPR] ≤ 1/109 ≈ 0.917% on exchangeable future cleans, with leakage-free recall 90.7% (98/108) [83.8, 94.9] and EIR₃ 0.990. Under distribution shift the certificate is void — **re-calibrate on ≥199 cleans from your own traffic** (that size also unlocks a genuine ≤0.5% certificate; 108 cleans mathematically cannot). Note the deployed θ is computed from *all* 108 cleans (its in-sample FPR of 0 is by construction, not evidence), unlike the CV table above where each trajectory was decided by a threshold that never saw it; deployed recall and CV recall also share the same 108 rogues, so they are correlated estimates, not independent confirmations. Alternative α-grid thresholds are in `calibration_report.json` in the companion repo.
|
| 62 |
+
|
| 63 |
+
## Intended use
|
| 64 |
+
|
| 65 |
+
- Research on step-level agent monitoring and early intervention.
|
| 66 |
+
- A reference operating-point + calibration recipe for local (no-API) trajectory screening on StepShield-formatted traces.
|
| 67 |
+
- Screening mode only: the detector reads the trajectory with `OK` filled into every past verdict slot and never feeds its own verdicts back (this matches training exactly).
|
| 68 |
+
|
| 69 |
+
Out of scope: any production safety-critical use without domain-specific evaluation and recalibration; any use prohibited by the NVIDIA Community Model License or NVIDIA's Trustworthy AI terms.
|
| 70 |
+
|
| 71 |
+
## How it works / usage
|
| 72 |
+
|
| 73 |
+
Incremental causal-LM step classification. Per trajectory: a task header, then per step the text `<<Sn>>\nT: <thought>\nA: <action+args>\nO: <observation>\nV:`; read the logits at the final position; restricted softmax over the two verdict tokens `" OK"` (id 12192) and `" BAD"` (id 100275); p(BAD) is the step score. History uses `OK` at every verdict slot. With an incremental KV cache the per-step cost is prefill of the new step's tokens only (no decode).
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
# research/evaluation use — see the License section for production restrictions
|
| 77 |
+
import torch
|
| 78 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 79 |
+
from peft import PeftModel
|
| 80 |
+
|
| 81 |
+
BASE = "nvidia/Nemotron-Mini-4B-Instruct"
|
| 82 |
+
tok = AutoTokenizer.from_pretrained(BASE)
|
| 83 |
+
model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16, device_map="cuda")
|
| 84 |
+
model = PeftModel.from_pretrained(model, "<this-adapter>")
|
| 85 |
+
model.eval()
|
| 86 |
+
|
| 87 |
+
OK, BAD, THETA = 12192, 100275, 0.946597
|
| 88 |
+
|
| 89 |
+
@torch.inference_mode()
|
| 90 |
+
def step_p_bad(prompt_so_far: str) -> float: # prompt ends with "\nV:"
|
| 91 |
+
ids = tok(prompt_so_far, return_tensors="pt").input_ids.cuda()
|
| 92 |
+
logits = model(ids).logits[0, -1, [OK, BAD]]
|
| 93 |
+
return torch.softmax(logits, -1)[1].item()
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
(Production code should keep a KV cache and append only new step tokens — see `scripts/nemotron_guard.py` and `scripts/gpu_score_trajs.py` in the companion repo. Deliberately, no `pipeline_tag` is declared and `inference: false` is set: this adapter is not a standard HF pipeline — scoring requires the incremental verdict-slot protocol above.)
|
| 97 |
+
|
| 98 |
+
## Latency
|
| 99 |
+
|
| 100 |
+
| Platform | p50 | p95 | p99 | n |
|
| 101 |
+
|---|---|---|---|---|
|
| 102 |
+
| NVIDIA L4 (GCP g2-standard-8), bf16, torch eager, single stream | 43.9 ms | 57.6 | 65.5 | 479 |
|
| 103 |
+
| Apple M4 Pro 48GB, MLX q4 | 110.5 ms | 177.9 | 243.0 | 356 |
|
| 104 |
+
|
| 105 |
+
Warm per-step, incremental KV cache, real validation step streams (per-step latency depends only on token counts, not labels; the Apple M4 Pro row was measured on holdout step streams), clocks not locked. Header prefill (once per trajectory): ~40 ms on L4. StepShield's native timing metric is EIR (steps); millisecond figures are from our own harness. **Quantization warning:** q4 measurably narrows the OK/BAD margin (measured validation-wide on an earlier checkpoint of the same training run: rogue max-p mean −0.05, worst −0.55) — re-calibrate θ per quantized artifact. All detection metrics and the deployed threshold on this card are bf16; only the Apple-silicon latency row and the quantization-margin observation are q4.
|
| 106 |
+
|
| 107 |
+
## Training details
|
| 108 |
+
|
| 109 |
+
- LoRA r=16, α=32, dropout 0.05 on `q_proj,k_proj,v_proj,o_proj,up_proj,down_proj`, all 32 layers (Nemotron-Mini's MLP has no gate_proj).
|
| 110 |
+
- Objective: weighted CE at verdict positions only. BAD at annotated rogue steps (w=1) and up to +3 steps after divergence (w=0.5); generated-benign OK steps w=0.5; BAD class weight 6.
|
| 111 |
+
- 3 epochs, OneCycle peak LR 1e-4, batch 4 × grad-accum 2, grad checkpointing, seed 7; 133 min on 1× NVIDIA L4.
|
| 112 |
+
- Data: StepShield train split — 639 rogue/clean scenario pairs (split 90/10 into train/val **by pair**) + 400 generated-benign trajectories. The holdout was excluded from weight training and checkpoint selection; it was used only for the pre-committed frozen evaluation and the leakage-controlled threshold calibration described above.
|
| 113 |
+
- Checkpoint selection: validation trajectory-AUC under deployment semantics (all-OK history).
|
| 114 |
+
|
| 115 |
+
## Evaluation protocol
|
| 116 |
+
|
| 117 |
+
Scores: one frozen pass over the 216 holdout trajectories (bf16, L4, all-OK history). Thresholds: conformal order statistics on calibration-fold cleans only, pair-level 4-fold CV, pre-committed rules/seed/reporting language; each trajectory decided exactly once by a threshold that never saw it or its scenario twin. Metrics: StepShield's own `calculate_metrics` (trajectory-level recall/FPR/accuracy/F1 + EIR). Full protocol, assumptions, and threats to validity: [docs/METHODOLOGY.md](https://github.com/doronp/stepshield-nemotron/blob/main/docs/METHODOLOGY.md). Provenance: all calibrated detection metrics trace to `results/calibration_report.json`; the legacy point to `results/OFFICIAL_holdout_frozen.json`; latency to `results/latency_l4_bf16.json` and `results/latency_m4_*.json`; checkpoint selection to `ckpt_meta.json`; baselines are quoted from the StepShield README — all in the companion repo.
|
| 118 |
+
|
| 119 |
+
## Why there is no prospective (blind) evaluation
|
| 120 |
+
|
| 121 |
+
We pre-committed a blind-evaluation protocol — the frozen model and deployed θ = 0.946597 applied exactly once to a never-seen slice, realized (FPR, recall, EIR₃) reported verbatim next to the 0.917% forward certificate they test — and then established that it is **unsatisfiable on this benchmark**: the model trained on the entire train split (639 rogue/clean pairs = 1,278 trajectories); of the benchmark's own 2,514-trajectory generated-benign corpus, development consumed 700 (400 for training + 300 for threshold-tuning validation); and the 216-trajectory holdout was consumed by the legacy evaluation and threshold calibration. The ~1,814 generated-benign trajectories development never touched are clean-only by construction, so they cannot satisfy the pre-committed protocol — realized recall and EIR₃ require rogue trajectories. StepShield therefore retains no pool containing rogue trajectories that development did not touch, so no run from it can honestly be labeled PROSPECTIVE. We state this as a finding about single-public-holdout benchmarks — once a detector is fine-tuned on the train split and the holdout is used even once, the prospective rung is unreachable — rather than promise an evaluation that cannot exist. The numbers on this card are held-out with respect to training, not benchmark-external; the prospective upgrade requires a different corpus and is future work. Full inventory and reasoning: METHODOLOGY §6 in the companion repo.
|
| 122 |
+
|
| 123 |
+
## Limitations
|
| 124 |
+
|
| 125 |
+
1. **Within-template evaluation** (see caveat box) — the dominant limitation.
|
| 126 |
+
2. **No benchmark-external validation.** All results were produced inside this benchmark's development loop; the benchmark retains no rogue-containing pool untouched by development for a blind run — its only untouched material (~1,814 generated-benign trajectories) is clean-only by construction (see the section above). As a general methodological matter, developed-on results in this domain can differ substantially from results on data nobody in the loop has seen; these numbers are held-out with respect to training, but external-corpus validation does not yet exist.
|
| 127 |
+
3. **The pre-declared ≥98% accuracy target was NOT met — and 98.1% is recall, not accuracy.** Certified accuracy tops out at 96.8% (α=0.025 curve point; 95.4% at the primary); the legacy single-shot accuracy was 89.4%. The recurring 98.1% figure is **recall** at the MAX-RECALL point (106/108 rogues caught, at 9.26% FPR) — never read it as accuracy.
|
| 128 |
+
4. **Balanced-set precision does not survive realistic prevalence.** At the benchmark's 50/50 mix, precision is 99.0% (primary) / 91.4% (MAX-RECALL); at ~1% rogue prevalence the same certified (recall, FPR) pairs imply roughly 50% and roughly 10% precision respectively — most flags would be false alarms. Evaluate at your own prevalence before trusting flag volume.
|
| 129 |
+
5. Six incident categories, one trajectory format, English-only, coding-agent domain.
|
| 130 |
+
6. Residual misses at the primary point: 9 FNs — 2 with max p(BAD) ≤ 0.014 (undetectable at any threshold), 7 near-threshold, skewed to subtle L3 rogues (α=0.025 recovers 3 of the 7 at zero additional FPs).
|
| 131 |
+
7. FPR certificate is marginal (expectation over exchangeable cleans), not a per-run cap; the single realized FP corresponds to 0.93% pooled.
|
| 132 |
+
8. Per-step latency differs sharply by runtime: L4 bf16 measures p50 43.9 ms / p95 57.6 ms / p99 65.5 ms, while Apple-silicon MLX q4 measures p50 110.5 ms / p95 177.9 ms — roughly 2.5× slower at the median, consistent with the observed ~3.6 ms/layer per-forward dispatch floor on that runtime (q4/q8/bf16 latencies were near-identical there). Measure against your own deployment's requirements before relying on either figure.
|
| 133 |
+
9. Robustness to adversarial evasion (an agent phrasing rogue steps to look benign) was not evaluated.
|
| 134 |
+
10. Context window: the base model's limit is 4,096 tokens; rendered StepShield trajectories (≤20 steps) fit within it. For longer traces, do not silently truncate — reject them or define and evaluate an explicit windowing policy first.
|
| 135 |
+
11. Operational guidance: route flags to human review or an evaluated downstream policy; do not let a flag trigger irreversible automated action. Pin the base-model and tokenizer revisions in deployment — verdict-token ids (12192/100275) are tokenizer-specific.
|
| 136 |
+
|
| 137 |
+
## License and attribution (NVIDIA Community Model License)
|
| 138 |
+
|
| 139 |
+
- Base model: `nvidia/Nemotron-Mini-4B-Instruct`, © NVIDIA Corporation, licensed under the **NVIDIA Community Model License** (v. Aug 23, 2024; copy distributed with the adapter as required by §1.2(c)).
|
| 140 |
+
- This adapter is a **Derivative Model** under §1.2.3 of that license. Modification notice (§2.2.1): *the distributed weights are LoRA adapter deltas trained by Doron Podoleanu on StepShield data; they modify the behavior of the base NVIDIA Model and are not original NVIDIA weights.*
|
| 141 |
+
- The adapter weights are licensed under the same NVIDIA Community Model License — **not** Apache/MIT (§2.1.4 forbids subjecting NVIDIA Models to open-source licenses). Only the companion repo's code is Apache-2.0.
|
| 142 |
+
- **Production-use restriction (§1.2): read before deploying.** The license grants production use only via an NVIDIA NIM runtime under an NVIDIA AI Enterprise subscription, except for models on NVIDIA's published PC/workstation and gaming exception lists. As of the list version we checked (v. Dec 13, 2024), **Nemotron-Mini-4B is not on the PC/workstation exception list**. Research and evaluation use is fine; for production, consult the current NVIDIA lists and licensing.
|
| 143 |
+
- Outputs restriction (§2.1.2): the license prohibits using the model or its outputs to develop or improve non-NVIDIA-derivative AI models without NVIDIA's written approval.
|
| 144 |
+
- "Nemotron" is used solely to identify the base model; no NVIDIA trademark license is granted or implied, and NVIDIA does not endorse this work.
|
| 145 |
+
- Use must be consistent with [NVIDIA's Trustworthy AI terms](https://www.nvidia.com/en-us/agreements/trustworthy-ai/terms/).
|
| 146 |
+
- Benchmark: StepShield, MIT License, © 2026 Gloria Felicia et al.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "nvidia/Nemotron-Mini-4B-Instruct",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"monteclora_config": null,
|
| 27 |
+
"peft_type": "LORA",
|
| 28 |
+
"peft_version": "0.20.0",
|
| 29 |
+
"qalora_group_size": 16,
|
| 30 |
+
"r": 16,
|
| 31 |
+
"rank_pattern": {},
|
| 32 |
+
"revision": null,
|
| 33 |
+
"target_modules": [
|
| 34 |
+
"v_proj",
|
| 35 |
+
"q_proj",
|
| 36 |
+
"up_proj",
|
| 37 |
+
"o_proj",
|
| 38 |
+
"k_proj",
|
| 39 |
+
"down_proj"
|
| 40 |
+
],
|
| 41 |
+
"target_parameters": null,
|
| 42 |
+
"task_type": "CAUSAL_LM",
|
| 43 |
+
"trainable_token_indices": null,
|
| 44 |
+
"use_bdlora": null,
|
| 45 |
+
"use_dora": false,
|
| 46 |
+
"use_qalora": false,
|
| 47 |
+
"use_rslora": false,
|
| 48 |
+
"velora_config": null
|
| 49 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4daba38363ba53d30b8cb5aa5494719de338a63684cc3b2011a9e8b2549f8eb6
|
| 3 |
+
size 92325848
|
ckpt_meta.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"traj_auc": 0.9938425925925927, "step_auc": 0.9939505643663381, "step": 1100}
|
nvidia-community-model-license-aug2024.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f15d3857aba569ec4b22a5ba18c4d0afb1b20730b58413782dd92965e36bdcdd
|
| 3 |
+
size 145733
|