Model improves safety and usefulness when following external instructions
Identify, Classify, Act: Per-Instruction Controlled Compliance for LLMs over External Data
Computation and LanguageCryptography and Security
Summary
Large language models (LLMs) sometimes get confusing instructions mixed with harmful prompts when accessing outside information or tools. The authors found that existing methods either ignore too many good instructions or follow bad ones, which isn’t ideal. They created a new system called EDIC that looks at each instruction closely to decide if it should be followed or rejected. This approach helps the model be safer and more helpful at the same time.
What this means in practice
- •For ai system developers: Improve how AI models safely process mixed external instructions by deciding which to follow or reject individually.
- •For chatbot platform engineers: Enhance chatbot reliability with better handling of potentially harmful external instructions embedded in user data or tool outputs.
Authors
Zesheng Shi, Xue Li, Chenrui Dai, Jing Li
Abstract
LLMs over external data face a per-instruction tension: a single document or tool return often interleaves legitimate directives with adversarial prompt injections, and the model must follow the former while rejecting the latter. Existing defenses suppress or trust all external instructions, collapsing the safety-utility frontier and forcing a choice between over-refusal and over-compliance. We argue the missing capability is \textbf{per-instruction credit attribution} and formalize it as External-Data Instruction Classification, an identify-classify-act decision over each embedded directive. We propose \textbf{EDIC}, a decomposed reward framework for per-instruction compliance. A scene-grounded pipeline injects mixed beneficial and harmful instructions with counterfactual filtering, while a generative judge is initialized by SFT and refined with GRPO to attribute compliance at the instruction level. The judge then produces a reward that separately encourages beneficial compliance and penalizes harmful compliance for RL training. Across two backbones and five benchmarks, EDIC improves both safety and utility over the strongest prior defense, lifting harmful-rejection by up to 7.7\% and Arena-Hard-Auto utility by 12.5\% on Qwen3-4B. The code repository is hosted at https://github.com/yingyingxia666/EDIC.