RAG管道中基于小语言模型的上下文感知提示注入检测:nokast-secureRAG
Context-Aware Prompt Injection Detection via Small Language Models in RAG Pipelines: nokast-secureRAG
AI总结:
本文提出nokast-secureRAG小语言模型作为RAG管道的语义防火墙,可联合评估用户查询与检索上下文以检测提示注入,在同分布测试中表现优于多个基线,同时指出其对事实投毒攻击的局限性并开源相关资源。
摘要:
本地检索增强生成(RAG)系统易受间接提示注入和检索投毒攻击,其中检索内容中的恶意指令会被误认为可信输入。本文提出nokast-secureRAG,这是一个约0.5B参数的小语言模型,作为检索与生成之间的语义防火墙,联合评估用户查询和检索上下文,将该对分类为安全、可疑或恶意。该模型采用教师-评判者-学生流水线训练:一个35B的教师模型生成四个攻击类别共5233个样本,一个独立的120B评判者对这些样本重新标注,在学生微调前达到95.0%的一致性。在保留的同分布测试集上,该模型在0.026的误报率下达到0.994的检测召回率,以及0.006的攻击成功率代理值,优于正则表达式基线、公开提示注入分类器、Llama Guard 3 1B及其未微调版本;Prompt-Guard-86M达到0.900的召回率,但误报率为0.690。在判断翻转测试中,即同一句子因上下文不同而良性或恶意时,该模型75%的时间能正确分类两种情况,优于对比基线。消融实验表明,检索上下文携带主要攻击信号,而查询-上下文一致性可降低误报率。单请求延迟为293-404ms,高于100ms的目标,而批处理下的摊销吞吐量延迟为37ms。在外部PoisonedRAG基准上,召回率降至接近零,表明流畅的事实投毒攻击超出了检测器的指令一致性威胁模型。本文报告了这一限制以及同分布结果,该模型、数据生成流水线和评估工具均以开源形式发布。
英文摘要:
Local Retrieval-Augmented Generation (RAG) systems are vulnerable to indirect prompt injection and retrieval poisoning, where malicious instructions in retrieved content are mistaken for trusted input. We present nokast-secureRAG, a roughly 0.5B-parameter small language model that acts as a semantic firewall between retrieval and generation. It jointly evaluates the user query and retrieved context, classifying the pair as safe, suspicious, or malicious. The model is trained using a teacher-judge-student pipeline: a 35B teacher generates 5,233 examples across four attack families, and an independent 120B judge re-labels them, achieving 95.0% agreement before student fine-tuning. On a held-out in-distribution test set, the model achieves 0.994 detection recall at a 0.026 false-positive rate and a 0.006 attack-success-rate proxy, outperforming a regex baseline, a public prompt-injection classifier, Llama Guard 3 1B, and its untuned version. Prompt-Guard-86M reaches 0.900 recall but has a 0.690 false-positive rate. On a judgment-flip test, where the same sentence is benign or malicious depending on context, the model correctly classifies both cases 75% of the time, outperforming the compared baselines. Ablations indicate that retrieved context carries the main attack signal, while query-context consistency reduces false positives. Single-request latency is 293-404 ms, above the target of 100 ms, while amortized throughput latency is 37 ms under batching. On the external PoisonedRAG benchmark, recall falls to near zero, indicating that fluent fact-poisoning attacks lie outside the detector's instruction-consistency threat model. We report this limitation alongside the in-distribution results. The model, data-generation pipeline, and evaluation harness are released open source.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。