用严格几何结构的数据设计,实现毫秒级精准的提示注入检测。
The Mirror Design Pattern: Strict Data Geometry over Model Scale for Prompt Injection Detection
- 构建正负样本对的镜像数据结构,让模型学攻击机制而非数据捷径。
- 在524条测试样本上达到95.97%召回率,延迟低于1毫秒。
- 适合需要快速、确定性、可审计的首层安全防护场景。
提示注入防御常被当作语义理解问题,交由越来越大的神经网络检测器处理。但作为第一道筛查层,检测器需满足快速、确定、不可被提示劫持且可审计的要求。我们提出「镜像设计模式」(Mirror),将提示注入语料库组织为匹配的正负样本单元,使分类器学习控制面攻击机制而非数据集中的偶然捷径。基于5000个严格筛选的开源样本(符合公开数据有效性协议的最大规模),定义32个单元的镜像拓扑,其中31个由公开数据填充,训练稀疏字符n-gram线性SVM,将其权重编译为静态Rust模块。在524例保留测试集上,实现95.97%召回率和92.07% F1,延迟低于1毫秒,无需外部模型运行时依赖。作为第二道防线的2200万参数Prompt Guard~2模型,在相同测试集上仅达44.35%召回率和59.14% F1,中位延迟49毫秒,95分位延迟324毫秒。线性模型仍存在语义模糊如使用与提及之别,但在该范围内,结果表明对于第一层提示注入筛查,严格的数据几何比模型规模更重要。
原文摘要 · Abstract (English)
Prompt injection defenses are often framed as semantic understanding problems and delegated to increasingly large neural detectors. For the first screening layer, however, the requirements are different: the detector runs on every request and therefore must be fast, deterministic, non-promptable, and auditable. We introduce Mirror, a data-curation design pattern that organizes prompt injection corpora into matched positive and negative cells so that a classifier learns control-plane attack mechanics rather than incidental corpus shortcuts. Using 5,000 strictly curated open-source samples -- the largest corpus supportable under our public-data validity contract -- we define a 32-cell mirror topology, fill 31 of those cells with public data, train a sparse character n-gram linear SVM, compile its weights into a static Rust artifact, and obtain 95.97\% recall and 92.07\% F1 on a 524-case holdout at sub-millisecond latency with no external model runtime dependencies. On the same holdout, our next line of defense, a 22-million-parameter Prompt Guard~2 model reaches 44.35\% recall and 59.14\% F1 at 49\,ms median and 324\,ms p95 latency. Linear models still leave residual semantic ambiguities such as use-versus-mention for later pipeline layers, but within that scope our results show that for L1 prompt injection screening, strict data geometry can matter more than model scale.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。