ArsGuard is an open-source neural network developed by Evgenii Arsentev that detects prompt injections — hidden instructions aimed at AI agents — in English, Spanish and Russian text, so agents reading emails, web pages, documents or tool outputs are not hijacked. The model is fine-tuned from mDeBERTa-v3-base, a multilingual transformer with about 280M parameters, and is distributed under the MIT license for commercial use.
On an independent test of native texts, ArsGuard catches 98.8% of English prompt injections, versus 60% for ProtectAI v2, the most downloaded open-source detector. For Spanish it catches 99.7% versus 86%, and for Russian 99.7% versus 37%. On ordinary messages from real users, it raises a false alarm 0.9% of the time, versus 10.8% for ProtectAI v2. The model runs fully local with no API calls after the initial download, and the 1.1 GB model weights are stored on disk.
Multilingual strength from native training
Most open detectors were trained mainly on English, so attacks written natively in Spanish or Russian slip past them. ArsGuard was trained on native attacks in all three languages. On an independent test comprising 4,783 texts (about half attacks) in English, Spanish and Russian, ArsGuard achieved 99.5% attack catch overall with an AUC of 0.995, while ProtectAI v2 achieved 61.2% catch with AUC 0.530. The independent test set was published as the independent_test split of arsguard-injections and contains carriers including API responses, terminal output, PDF text, chat logs, error logs, lab reports, marketplace ads and plain chat messages.
The dataset was constructed from 241,162 training examples, 38,000 of which are a new set of native English, Spanish and Russian attacks, each paired with a benign text of the same form. The set covers 20 attack techniques in 20 kinds of carriers across 40 domains. Every source with a non-commercial or share-alike license was excluded from the training data, so the model can be embedded in commercial products.
Technical details and operation
The model reads 512 tokens at a time. The Guard class handles longer texts by splitting them into overlapping windows and reporting the highest score, so an instruction hidden in the middle of a long document is still found. On an ordinary user message, the false alarm rate is 0.9%; on deliberately hard benign texts — such as articles and warnings about prompt injection itself — the false alarm rate rises to 25.3% on the test set, though 71% of those flagged texts were actually discussing prompt injection or AI security.
Commands and integration:
- pip install git+https://github.com/arsentev-ai/arsguard
- from arsguard import Guard; guard = Guard() # downloads on first use
- guard.check("text") returns Result(label, score, is_injection)
- guard.check_many(texts) checks a list; guard.scores(texts) returns raw probabilities
- Command-line: arsguard "text" exits with code 1 if flagged; arsguard --file inbox.txt processes one text per line
- Plain transformers: clf = pipeline("text-classification", model="arsentev-ai/arsguard", truncation=True, max_length=512)
ArsGuard also runs as a Model Context Protocol server so Claude Desktop, Claude Code, Cursor, Cline and other MCP clients can check text themselves. The server runs locally over stdio with two read-only tools: check_text for one text and check_texts for a batch.
{ "mcpServers": { "arsguard": { "command": "uvx", "args": ["arsguard", "mcp"] } } }Claude Code: claude mcp add arsguard -- uvx arsguard mcp. Docker: docker build -t arsguard . && docker run -i --rm -v hf:/root/.cache/huggingface arsguard.
Language support beyond the three training languages
ArsGuard's base model (mDeBERTa-v3) is multilingual. To check other languages, 300 English texts from the independent test (150 attacks, 150 benign, each under 1,500 characters) were machine-translated into six languages. Results:
- English: 100% attacks caught, 25.3% false alarms, 300 texts
- French: 100% attacks caught, 24.0% false alarms, 300 texts
- German: 100% attacks caught, 32.7% false alarms, 300 texts
- Turkish: 100% attacks caught, 37.8% false alarms, 270 texts
- Arabic: 99.3% attacks caught, 30.7% false alarms, 300 texts
- Tatar: 99.1% attacks caught, 36.9% false alarms, 210 texts
- Chinese: 95.3% attacks caught, 25.3% false alarms, 300 texts
False alarms on Turkish, Tatar and German are 8–13 points higher than on the three training languages. The test set's benign texts are deliberately hard — about half are about injections themselves or look like instructions — so false alarms are higher than on ordinary user messages (0.9%). Attacks were machine-translated, not written by native speakers, so results on native attacks in these languages may be lower.
Threshold adjustment and known limitations
At the default threshold of 0.5, On two English jailbreak-style benchmarks ProtectAI v2 catches more attacks: jayavibhav (82.7% vs 98.6%, at 19.4% vs 75.3% false alarms) and yanismiraoui (84.2% vs 98.3%). Raising the threshold to 0.99 changes the tradeoff: on jayavibhav, ArsGuard catches 71.3% of attacks with 11.1% false alarms, and on the independent test 99.4% with 16.6% false alarms.
Texts that discuss prompt injection, such as security articles, policies and warnings, are often flagged as injections. For an agent this is a cautious failure mode, but expect it if the agent reads security content. The labels of the generated and independent test sets were assigned by the generating models; a re-check of 200 benign texts agreed with 97.5% of the labels.
Comparisons were made with ProtectAI v2 only; Meta Prompt Guard 2 and commercial detectors were not evaluated. The model takes 1.1 GB on disk and uses about 1.0 GB RAM while loaded; a modern laptop with 4 GB RAM is enough, 8 GB is comfortable. Loading the model takes 2–11 seconds; short messages are checked in about 0.2 s, an email of about 400 words in 1.8 s, and a long web page of about 3,200 words (using 512-token windows) in 9.6 s.
Commercial use and privacy
The model, code and dataset are MIT-licensed. After the first download it runs locally with transformers — no internet connection or API key is needed. Own data: arsguard-injections (MIT). Open datasets include deepset/prompt-injections (Apache-2.0), jackhhao/jailbreak-classification (Apache-2.0), Lakera/gandalf_ignore_instructions (MIT), Lakera/mosscap_prompt_injection (MIT), reshabhs/SPML_Chatbot_Prompt_Injection (MIT), hendzh/PromptShield (Apache-2.0), neuralchemy/Prompt-injection-dataset (Apache-2.0, train split only), S-Labs/prompt-injection-dataset (MIT), dmilush/shieldlm-prompt-injection (MIT), walledai/JailbreakHub (MIT), TrustAIRLab/in-the-wild-jailbreak-prompts (MIT), microsoft/llmail-inject-challenge (MIT), Open-Prompt-Injection benchmark (MIT, via guychuk/open-prompt-injection), OpenAssistant/oasst2 (Apache-2.0, train split only), FineWeb and FineWeb-2 pages (ODC-By) and the Enron email corpus released publicly by the US Federal Energy Regulatory Commission. Part of the English data was translated into Spanish and Russian with Helsinki-NLP opus-mt models (Apache-2.0).
Cite the concept DOI 10.5281/zenodo.24682051, which always resolves to the latest version. GitHub's "Cite this repository" button gives the same reference.