Skip to content

Prompt Injection Detection — Lightweight Guardrails

An empirical study extending Guardrailer, comparing embedding-centroid scoring with lightweight statistical models, feature ablations and cross-dataset tests for prompt injection detection.

Prompt Injection Detection — Lightweight Guardrails

Cross-dataset evaluation figure: Prashanna Tiwari · Author-provided research figure · Resized and converted to WebP.

Created by Prashanna Tiwari.

Testing what a guardrail actually learns

This ADHAYAN research project extends Guardrailer with experiments on embedding geometry, nearest-centroid scoring and a lightweight ensemble combining TF-IDF with handcrafted text features. It includes notebooks, evaluation code, result files, figures and a LaTeX manuscript.

The repository reports 83.0% in-distribution accuracy for its full hybrid model, while TF-IDF alone reaches 85.0% in the reported ablation. Average external benchmark accuracy falls to 51.4%, exposing a substantial generalization gap. These are author-reported experimental results, not independent validation or a production security guarantee.

Licensing

The repository’s LICENSE file contains the MIT License, but the README’s license section separately asks users to contact the author for permission. Both notices are linked here so visitors can see the discrepancy. The cover is the repository’s cross-dataset evaluation figure.

Contributors

  • Prashanna Tiwari