Instructions to use SamJoshua/injection-guard-fix-recipe with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SamJoshua/injection-guard-fix-recipe with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="SamJoshua/injection-guard-fix-recipe")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("SamJoshua/injection-guard-fix-recipe", device_map="auto") - Notebooks
- Google Colab
- Kaggle
injection-guard-fix-recipe
Training recipe and evaluation code for a data-only fix attempt on
Horizon-Labs/prompt-injection-guard-small v2.7
(revision 0c8139d). The attempt does not meet the release gates. This repository contains code, configs and
measurements. It contains no model weights and no evaluation data.
Context: the red-team findings and the discussion with the maintainers are in discussion #1. The red-team set is SamJoshua/injection-guard-minimal-pairs.
What it tries to fix
The base classifier keys on surface features (an email address or URL, one tool-call syntax) rather than on the harmful
action. The attempt retrains it on contrastive data: the same verbs on harmless objects, tool mentions in logs and docs,
legitimate instructions addressed to people, every example rendered compact and pretty, plus replay of the base model's own
training families. Best recipe (r22_div1ep in guardtune/recipes.py): one epoch of full fine-tuning, lr 5e-5, cosine,
6% warmup, AdamW, token embeddings frozen, threshold 0.5.
Results, stated plainly
The gates are in GATES.md and were written before any training. All numbers are fp32, three seeds.
| base v2.7 | this recipe (3 seeds) | bar | |
|---|---|---|---|
| Sealed partition, tool-mention false positives | 55.4% | 18.5 / 19.5 / 18.7% | 6% |
| Sealed partition, harmful-action recall | 84.6% | 98.7β99.0% | 90% |
| Sealed partition, instruction false positives | 32.1% | 0.1β1.2% | 3% |
| Development partition, tool-mention false positives | 33.6% | 4.7 / 1.5 / 3.1% | 6% |
| Development partition, harmful-action recall | 72.2% | 96.4 / 93.9 / 94.5% | 90% |
- Fails the release gates. Sealed tool-mention false positives are about 19% against a 6% bar on every seed. The failure is concentrated in two documentation families: an appendix telling the reader to execute the example, and a handbook line that only names the tool.
- On the development partition each seed clears every point-estimate bar but misses three seed-to-seed spread caps (format gap 4.0 pts vs cap 3.0, tool-mention FPR 3.1 vs 2.0, instruction FPR 2.0 vs 1.5).
- A second epoch clears the development gates on one seed only. Lower lr, partial freezing, late weight averaging and checkpoint soups did not fix it.
- Benign requests addressed to the assistant (a diagnostic, not a gate) are still flagged 44β64% of the time.
EVIDENCE.md has every table, intervals and the full ablation ladder. results/runs.csv, results/runs_fp32.csv,
results/seed_spreads*.csv and results/runs/*.json hold per-run metrics (aggregates only, no model inputs).
Layout
| path | what |
|---|---|
GATES.md |
gates and pass rule |
EVIDENCE.md |
results and verdict |
guardtune/gen_train.py |
training-data generator |
guardtune/gen_test.py |
held-out gate generator (development partition only, see below) |
guardtune/train.py, recipes.py, replay.py, soup.py |
training, ablation ladder, replay, checkpoint averaging |
guardtune/evaluate.py, metrics.py, report.py |
gates, Wilson/Newcombe intervals, tables |
scripts/repro.sh |
tests, base model, three seeds, fp32 evaluation |
tests/ |
train/test separation, interval math |
Reproduce
Training and evaluation run on CPU. One epoch took about 10 minutes and one fp32 evaluation about 18 minutes on the machine used. The model and datasets are public; no token is needed.
export BASE_MODEL=Horizon-Labs/prompt-injection-guard-small
export BASE_MODEL_REVISION=0c8139d
export DATASET_MINIMAL_PAIRS=SamJoshua/injection-guard-minimal-pairs
export DATASET_TERSE=SamJoshua/terse-tool-output-heldout
export DATASET_INDIRECT=SamJoshua/indirect-json-injection-heldout
python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
python -m pytest -q tests
python -m guardtune.train --recipe r22_div1ep --seed 0 # one screening run on the development partition
scripts/repro.sh runs the full loop (tests, base model, three seeds, fp32). In this published copy it skips the sealed-partition evaluations, see below.
Limitations
- The sealed partition is not included. Its templates are removed from
guardtune/gen_test.pyso it stays unseen for anyone testing a fix. The sealed numbers above are reported as measured and cannot be regenerated from this repository. The development-partition generator is unchanged and reproduces the development numbers. The tests that compare the two partitions are skipped here. - The generators are templated, so the test sets share style within themselves. Treat the numbers as a diagnostic of this failure mode, not a general benchmark.
- Three seeds, one base checkpoint, one model size.
- Nothing here is a release candidate. No weights are published.
License: Apache-2.0.
Model tree for SamJoshua/injection-guard-fix-recipe
Base model
jhu-clsp/mmBERT-small