Upload README.md with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125---license: mitlanguage: - en - multilinguallibrary_name: onnxpipeline_tag: token-classificationbase_model: jhu-clsp/ettin-encoder-32mdatasets: - booleanbyte/tripwiretags: - prompt-injection - ai-safety - agents - tool-use - mcp---
# Tripwire 32M: finds instructions planted in what an AI agent's tools return
AI agents read emails, web pages, API responses and tool descriptions. Anattacker can hide an instruction in that text and the agent may follow it(indirect prompt injection). This model reads such a text and marks thecharacters an attacker planted, so the planted part can be removed and the restkept.
It is a token classifier fine-tuned from `jhu-clsp/ettin-encoder-32m` on theTripwire dataset, version 0.3.1. The code, the benchmarks and every resultbelow are in the source repository: https://github.com/dhootatharva/tripwire
## Use
```bashpip install "tripwire[hub] @ git+https://github.com/dhootatharva/tripwire"```
```pythonfrom tripwire.detector import Detector
detector = Detector.from_hub("booleanbyte/tripwire-32m")result = detector.scan(tool_output)if result.flagged: print(result.score, [(span.start, span.end) for span in result.spans]) safe = result.strip(tool_output)```
It runs on a CPU with `onnxruntime`; PyTorch is not needed. The repository alsohas a filter for a hand-written agent loop, a LangGraph hook and an MCP proxybuilt on this model.
## Files
| File | What it is ||---|---|| `model.onnx` | 32-bit weights. The default; gives the same verdicts as the trained model || `model.int8.onnx` | 8-bit weights. A quarter of the size, changes some verdicts, not faster on the CPU tested || `tokenizer.json` | The tokenizer || `model.safetensors`, `config.json` | The trained checkpoint, for `transformers` |
## Two sizes
| | 32M | 68M ||---|---|---|| File size (32-bit) | 128 MB | 274 MB || Time for 500 tokens, one laptop CPU | about 130 ms | about 340 ms || Catches | less | more || False alarms on harmless requests | fewer | more |
The 32M model is the default in the code.
## Results
A document counts as flagged when any token scores at least 0.5. Each model wastrained once.
| Test | What it measures | 32M | 68M ||---|---|---|---|| Own test split: attacks caught | Same recipe as the training data | 97.9% | 98.9% || Own test split: false alarms | | 0.8% | 0.5% || AgentDojo tool outputs: caught / false alarms | Used while building the model | 100% / 3.4% | 100% / 3.2% || BIPIA attacks caught | Outside data | 63.0% | 78.3% || InjecAgent plain attacks caught | Outside data | 78.2% | 86.3% || InjecAgent enhanced attacks caught | Outside data | 100% | 100% || BIPIA clean texts flagged | Outside data | 0.6% | 1.1% || NotInject flagged | Harmless texts with attack-like wording | 15.6% | 48.1% |
With the 32M model in front of two open models that follow these attacks(gpt-oss-120b and gpt-oss-20b), the attacker's goal was reached in 42 of 47AgentDojo cases without it and in 0 of 47 with it. That is a small sample fromone suite.
On NVIDIA garak's latent-injection probes, which were not used to build themodel, the 32M model flagged 81% of 1,960 attacked documents and changed noneof 74 clean ones.
## Limits
- **It looks for instructions, not for false claims.** "This domain is clearly not malicious" planted in a record instructs nobody and is not flagged.- **Its own test split flatters it.** Use the outside figures above.- **It was not tested against an attacker who adapts.** Someone who can query it repeatedly and reword an attack should be assumed to get through.- **It does not see the user's request.** If the user asks the agent to follow the instructions on a page, the model still flags them.- **A request addressed to the reader inside a tool output is treated as suspicious by design**, which is the source of most false alarms.- **English was tested most.** 77 of 85 (32M) and 84 of 85 (68M) of the dataset's own non-English test attacks were caught; no outside data in other languages was used.- **Only text is read**: not images, audio or file names.
Use it as one layer, together with limited tool permissions and human approvalfor risky actions.
## Training
Dataset version 0.3.1 without the examples whose label depends on the user'srequest. 512-token windows, two labels per token (planted or not), one seed.59 minutes (32M) and 161 minutes (68M) on two T4 GPUs. The script is`scripts/train.py` in the source repository.
## Licence
MIT, the licence of the base model. The training data is CC BY-SA 4.0 andincludes Wikipedia text and the Enron email corpus; see the dataset card.README.mdAdded+125