Text Classification
Transformers
ONNX
Safetensors
modernbert
prompt-injection
jailbreak-detection
llm-security
ai-agents
guardrails
onnxruntime
mcp
text-embeddings-inference
Instructions to use usezn/Galvanize-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use usezn/Galvanize-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="usezn/Galvanize-2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("usezn/Galvanize-2") model = AutoModelForSequenceClassification.from_pretrained("usezn/Galvanize-2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Model card: overlapping windows for long inputs, with measured results
Browse files127 unmodified lines12812913013113113213313464 unmodified lines1992002012022032042052062072082092102112122132147 unmodified lines222223224215225226227228127 unmodified linesprint(f"{p:.3f}", "BLOCK" if p >= THRESHOLD else "ALLOW")```
Only the first 512 tokens are scored. For long documents where an injection could appear later, split the text into chunks and take the highest score.Only the first 512 tokens are scored in a single pass. For longer inputs, score overlapping windows and keep the highest score: each window holds 510 content tokens plus the start and end tokens (512 in total), windows move 256 tokens at a time, and the last window ends at the end of the text. The first window is exactly the single-pass input, so short texts score the same. See *Long inputs* under Evaluation for the measured effect.
## Evaluation
64 unmodified lines
**Long benign documents.** On our set of long benign documents, Galvanize-60M flagged about 66%. Galvanize 2 flags 4.1%.
**Long inputs.** We placed attacks from our held-out set inside long benign documents (at least 1,500 tokens; 300 pairs per position) and scored them at the 0.662 threshold.
| Attack position | First 512 tokens | Overlapping windows (stride 256) ||---|---|---|| Start | 76.3% | 79.7% || Middle | 1.0% | 91.0% || End | 1.0% | 86.0% |
Windowing raises false alarms on long benign documents from 3.7% to 5.7% (300-document subset) and costs about three times the compute on long inputs (3.6 windows per document on average). On our held-out set, where almost all texts are short, recall rises by 0.4 points and the false positive rate does not change.
**New attacks.** We also test the model against new attacks we generate internally against our own detector. On 601 fresh examples, none seen in training, Galvanize 2 catches 67.2%, against under 3% for Galvanize-60M (the attacks were generated to evade Galvanize-60M, so its low score is expected) and 65.6% for Horizon-Labs/prompt-injection-guard-small at the same false positive rate.
### Speed7 unmodified lines- **Indirect and structured injections.** BIPIA (injections inside emails, tables and code) and the deepset test set are clear weak spots, and recall on the Simsonsun jailbreak set is lower than on our own data.- **English-centric public benchmarks.** Most public sets are in English. Our multilingual numbers come from our own held-out data.- **Threshold trade-off.** 0.662 favours fewer false alarms. Recall-first deployments should use 0.5 and expect more false alarms.- **Context.** Scores cover the first 512 tokens. Chunk longer inputs.- **Context.** A single pass only sees the first 512 tokens, so an attack placed later in a long document is almost always missed. Use overlapping windows (see How to use it).- **Text only, in isolation.** The model cannot tell whether an instruction is legitimate for a given user or task.
## TrainingREADME.md+12-2