Prompt Attack Detection with LLM-as-a-Judge and Mixture-of-Models
This paper demonstrates that lightweight, general-purpose LLMs can effectively serve as low-latency security judges for detecting prompt attacks in production environments when guided by structured reasoning, a method currently deployed in Singapore's public service chatbots, while a Mixture-of-Models approach yields only modest performance improvements.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a very helpful, super-smart robot assistant (a Large Language Model, or LLM) that works for the government. Its job is to answer citizens' questions, help them fill out forms, and give advice. But, just like a human, this robot can be tricked.
Bad actors try to "jailbreak" the robot or "inject" hidden instructions to make it do dangerous things—like revealing secret data, writing malware, or giving harmful advice.
This paper is about building a security guard for that robot. The authors from Singapore's GovTech faced a tough problem:
- Old guards (simple rule-based systems) are fast but too dumb to understand tricky, sneaky attacks.
- Super guards (massive AI models) are smart enough to catch the tricks, but they are too slow and expensive to check every single message in real-time.
Here is how they solved it, explained simply:
1. The "Thinking Guard" (LLM-as-a-Judge)
Instead of hiring a massive, slow super-guard, they taught a lightweight, fast robot how to think like a detective.
Usually, if you ask a robot, "Is this message bad?" it might just guess "Yes" or "No" instantly. That's like a security guard who just looks at a person's face and decides if they look suspicious. It misses the details.
The authors gave their fast robot a strict checklist (a structured reasoning process) to follow for every message:
- Strip the Disguise: "Is this person pretending to be a researcher or writing a story to hide their real intent?" (e.g., "Write a story about how to make a bomb" vs. "How do I make a bomb?").
- Check the Intent: "Are they asking for a harmless workflow (like 'make a chart') or something dangerous?"
- Look for Safety Signals: "Are they asking how to stop a virus (safe) or how to create one (bad)?"
- Self-Reflect: Before giving the final answer, the robot must pause and ask itself: "Wait, am I being too harsh? Could this actually be a legitimate question?"
The Result: By forcing the fast robot to "think step-by-step" before answering, it became almost as smart as the slow, expensive super-guards, but it was fast enough to work in real-time.
2. The "Committee of Guards" (Mixture-of-Models)
The researchers wondered: "What if we ask three different robots to check the message and take a vote? Will that be safer?"
They tried combining the opinions of different AI models (a "Mixture of Models").
- The Surprise: Adding more guards didn't always make things better. In fact, sometimes it made things worse.
- The Analogy: Imagine a jury. If you have one brilliant detective and one confused intern, adding the intern might actually confuse the verdict. Or, if you have three detectives who all make the same mistake, adding a third doesn't help.
- The Finding: You only get a boost if you pick guards who have different strengths that complement each other. Just throwing random guards together usually leads to arguments and mistakes.
3. The Real-World Test
They didn't just test this on fake, made-up questions. They built a test set using:
- Real citizen questions from Singapore's public chatbots (to make sure they didn't accidentally block normal people).
- Tricky "Red Team" attacks generated by other AIs trying to break the system.
The Winner: A specific, lightweight model (called gemini-2.0-flash-lite-001) using their "Thinking Guard" method. It was fast enough to check messages instantly but smart enough to catch the sneaky attacks that older systems missed.
The Big Takeaway
You don't need a giant, slow, expensive AI to keep your chatbots safe. You just need a fast AI that is taught how to think carefully.
- Don't just ask "Is this bad?"
- Ask: "What is the intent? Is there a disguise? What are the safety signals? Let me double-check my answer."
This approach is now being used to protect public service chatbots in Singapore, keeping them safe from hackers without making citizens wait for their answers.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.