Daily AI Paper

Daily AI Paper

2026-11-19

Archived
2026-11-19

Jailbreak Detection on Large Language Models via Contrastive Prototype Structures

Yan Qiu, Yuanyuan Li

arXiv:2611.24936v1

Imagine you’re trying to build a safety filter for a large language model, but you don’t want a brittle system that only recognizes a fixed list of known attack patterns. That’s the problem this paper tackles. Jailbreak attempts and harmful prompts keep evolving, and as models are deployed in more agentic settings with tools, external environments, and multi-turn conversations, the attack surface gets bigger. So the question becomes: can we detect unsafe inputs not just by memorizing labels, but by exploiting the geometry of the model’s internal representation space? That matters because many existing safety guards are classifier-based. They take labeled examples of harmful and benign content, train a downstream classifier, and then use that classifier as the detector. That works, but it has a few weaknesses. The safety taxonomy may be incomplete. The classifier may focus on fine-grained category boundaries instead of the underlying harmful intent. And the resulting decision boundary may not align very well with how the representation space is actually organized. In other words, the model may already be arranging harmful and benign inputs in a meaningful structure, and a separate classifier may not be the best way to use that structure. This paper asks whether we can do better by learning a representation space where harmful and benign inputs are more cleanly separated, and then making decisions directly from that space. The method is called Jailbreak Detection with Prototype Inference, or JDPI. The key idea is simple: use contrastive learning to adapt a sentence encoder so harmful inputs cluster away from benign ones, then build one prototype for harmful content and one for benign content, and classify a new input by which prototype it is closer to. So instead of training a separate downstream classifier, the detector uses relative distances in the learned embedding space. To understand why that is interesting, it helps to place it in the broader safety landscape. LLM safety work has taken several forms. Some methods try to enforce instruction hierarchy at inference time. Others train models to reason over explicit safety rules. There are adversarial training approaches, representation-level interventions, and input preprocessing defenses. There are also embedding-based jailbreak detectors that use sentence representations plus a conventional classifier. More recent work has shown that internal hidden states can contain safety-relevant signals, and that geometric or contrastive scoring methods can sometimes separate benign from malicious inputs. This paper sits in that line of work, but with a particular emphasis on reducing reliance on a separate classifier and on using only binary safety labels. The method has two main stages. First is contrastive representation learning. They fine-tune a sentence-transformer encoder, specifically an MPNet-based encoder, using pairs of examples labeled as either positive or negative based on safety. Harmful-harmful pairs and benign-benign pairs are treated as positive pairs, while harmful-benign pairs are negative pairs. The goal is to make same-label examples closer together and different-label examples farther apart in embedding space. The paper uses a contrastive objective based on pairwise cosine similarity, with CoSENT-style training. The important point is not the exact loss formula, but the effect: the encoder learns a geometry where safety status is more explicitly encoded. The second stage is detection. Here the paper compares several increasingly structure-aware methods. Method A is the baseline: take the adapted embedding and train a standard linear classifier on top of it. That’s the usual embedding-based detector. Method B adds cluster geometry by running k-means on harmful examples in a structure split and appending distances to harmful centroids as extra features. Method C goes further and tries to identify harmful clusters that are especially prone to false negatives, then adds features describing distance to those high-error regions and to the remaining harmful regions. Method D is the most elaborate: it incorporates benign structure too, along with cross-class relationships, including “mirror” features that pair harmful and nearest benign centroids. So Methods B through D are basically testing whether explicit structural information in the embedding space helps a classifier beyond the embedding alone. But the real novelty is JDPI itself, which is the direct prototype-inference version. Instead of learning a downstream classifier, JDPI uses binary safety labels to construct harmful and benign prototypes and predicts based on relative prototype distances. That means the detector can operate with fewer labeled examples, because it avoids the separate split needed to train a classifier on top of the encoder. In the paper’s setup, this is an important efficiency advantage: the same binary labels are used for encoder adaptation, prototype construction, and validation. The evaluation is intentionally broad. They test on four benchmarks that cover different input formats, including prompt-level inputs, question-answer pairs, and multi-turn conversations, and they include adversarial examples. The benchmarks mentioned in the paper include datasets such as WildJailbreak, BeaverTails, Gibbs, and TomGibbs. One important aspect is cross-dataset robustness: they adapt the encoder on one dataset and then transfer the detector to other datasets without target-dataset adaptation. That tests whether the learned safety geometry generalizes, rather than merely fitting one benchmark. They also look at a multi-turn replay setting on TomGibbs, where the detector can use accumulated user history as the conversation unfolds, not just the current turn. So what do the results show? First, contrastive fine-tuning matters a lot. Across the four benchmarks, it improves JDPI’s detection accuracy by 9.1 to 18.0 percentage points. That tells us the representation learning stage is doing real work: the encoder is becoming more safety-aware, and the prototype structure becomes more usable once the embedding space has been contrastively shaped. Second, compared with the classifier baseline using the same encoder, JDPI performs very competitively. It achieves slightly higher ROC-AUC on one benchmark and stays within 0.017 of the baseline across all four. That’s a strong result because it suggests you can remove the downstream classifier without paying much, if any, performance penalty. In practical terms, the simpler geometric rule is nearly as effective as the learned classifier, and sometimes a bit better. Third, when they allow dataset-specific adaptation, JDPI surpasses the released Llama Guard 3-8B baseline by a substantial margin in ROC-AUC, specifically by 0.173 to 0.310 across the four benchmarks. That is a large gap, and it suggests the prototype-based approach can be very effective when it is adapted to the target dataset. Of course, this is not an apples-to-apples claim about all possible safety systems, but within the paper’s evaluation it is a strong indication that the learned geometric structure is useful. Fourth, on the multi-turn TomGibbs setting, using the accumulated conversation history improves conversation-level accuracy over using only the current turn. That makes intuitive sense: jailbreaks in dialogue often unfold over multiple turns, so the harmful intent may not be obvious from the latest message alone. The result supports the idea that safety detection should be context-aware in conversational settings. Finally, they test transfer across 12 directed transfers and find that JDPI outperforms the classifier by an average of 1.59 percentage points in accuracy. That’s not a huge absolute number, but it is meaningful because it points to better cross-dataset robustness. In safety detection, generalization is often the hardest part, so even a modest but consistent gain across transfers is valuable. What should we take away from all this? The core message is that binary safety labels can be used not only to train a classifier, but to shape a representation space where harmful and benign inputs occupy different regions with usable prototype structure. Once that structure is learned, direct distance-based inference can be nearly as good as a downstream classifier, sometimes better, while using fewer labeled examples and showing stronger robustness in transfer. There are also some limitations and things to watch next. First, the method still depends on labeled safety data, even if it uses it more efficiently. It is not fully label-free. Second, the quality of the prototype structure will depend on the benchmark and on how well the binary labels capture the real notion of harmfulness. Safety is often more nuanced than a binary split, and the paper itself notes that fine-grained taxonomies can be fuzzy. Third, the gains from direct prototype inference are impressive, but they are benchmark-dependent, and the paper’s strongest claims come from a specific evaluation setup. Fourth, multi-turn detection is promising, but the paper only evaluates one replay-style setting, so broader conversational robustness remains an open question. More broadly, this work suggests a direction that is increasingly important in LLM safety: instead of treating the detector as a black-box classifier layered on top of embeddings, we can ask whether the representation space itself already contains the right geometry for safety decisions. If it does, then prototype-based inference may offer a simpler, more interpretable, and more robust alternative. That does not eliminate the need for classifiers in every case, but it shows that geometric inference can be a serious contender for jailbreak detection.

Previous daily papers

2026-11-28How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches2026-11-27Spectrum Adaptation of AI-Native Autoencoder Communications with Transfer Learning2026-11-26Stranger Things: When Objects Appear Without Their Typical Neighbors2026-11-25OmniAct: One Policy, One Million Embodiments2026-11-24Let Vision-Language Models Generate Images through Their Representations2026-11-24Pruning Autonomous Driving VLAs: What to Preserve for Reasoning and Action2026-11-24Tabular Foundation Models for Weighted Regression and Classification2026-11-23BioEmu2: Scalable Emulation of Biomolecular Dynamics2026-11-23Model Carving: Training Transformers That Optimize Their Own Topology2026-11-23MemOnce: A Scalable Memory Architecture for Large Language Models2026-11-22SoK: Assessing the Evolution of LLM Capability in Software Vulnerability Research2026-11-22Depth Pro 2: Sharp and Temporally Consistent Metric Monocular Depth2026-11-22RL Post-Training in Diffusion Transformers Is Activation Steering2026-11-20FrontierReplay: Split-Free Exact Prefix Caching for Hybrid Language Models2026-11-19Auditing black-box clinical prediction models with a large language model through queries alone: a blinded test with planted flaws2026-11-18Spool: Low-Latency Streaming Inference for Hybrid Vision-Language Models2026-11-18Ambient LLMs: Data-Efficient Supervised Fine-tuning via Temperature Matching2026-11-18Know When to Zoom: How Small Is Too Small for Vision-Language Models?2026-11-17ViRA: Toward Ultra-High-Resolution Visual Agents via Cross-Input Relative Policy Optimization2026-11-17Latent Lattice Language Models2026-11-17SWE-CoWork: Benchmarking Coding Agents as Digital Employees in Organizations2026-11-16StreamEmbed: Real-Time Indexing from Pixels for Screenshot Retrieval2026-11-15ArchSpace: Recording, Reviewing, and Referencing LLM Architecture Research2026-11-15Classical Energies Learn to Reason 1,000x Faster than Looped Models2026-11-15Unbundling Multimodal Vision Encoding2026-11-14Goal Encoding in LLMs2026-11-13Dataset Distillation via Drifting2026-11-12AutoScaffold: AI-Guided Scaffolding for Reinforcement Learning of Language Models2026-11-12Contrastive Discovery: Open-Ended Scientific Discovery over Competing Explanations2026-11-12Emergent Biological Capabilities in a Foundation Model for Molecular Interactions2026-11-11Medical Image Segmentation: Foundation Model Adaptation versus Task-Specific Training2026-11-10Mitigating Agentic Deception via Evaluation-Side Partially Observable Games2026-11-09On Agentic Manipulation Policies2026-11-09Can Agentic Systems Close the Gap in Radiology with Production AI Tools?2026-11-09Computer-Use Agents Are Embodied Generalists2026-11-08Failure Prediction and Classification in Vision-Language-Action Models Via Calibrated Latent Probing2026-11-08Scientist World: Grow a Research World for AI-Scientists2026-11-08Understanding AI from the Inside: The State of Mechanistic Interpretability for AI Safety2026-11-06User Embeddings are Superpositions of Interpretable Behavioral Modes2026-11-05FrontierPhysics: Evaluating Agents for End-to-End Physics Research2026-11-05Reinforcement Learning Enables Scaling Generalist Robot Policy Improvement2026-11-05Perceptive Humanoid Motion from Simulation2026-11-04From Autonomous Agents to Cognitive Symbionts: Toward AI-Augmented Human Intelligence2026-11-04DreamX: Video Diffusion Model is a Universal Latent Action Learner2026-11-04PyRUA-DataFarm: LLM Agent as a Cost-Efficient Teleoperator for Real-Ready Robot Data2026-11-03Pixel: A Co-Designed Full-Stack Robot System for Learning General-Purpose Mobile Manipulation2026-11-03Strategist: Evolving Reasoning with Agents2026-11-03DR Pixel: Page-Native Deep Research with Vision-Language Models2026-11-02ACCT: Asymmetric Cross-LLM Context Transfer2026-11-02Latent Reasoning in Continuous Space for Unified Multimodal Models2026-11-02Subquadratic Attention with a Hierarchical Tree-Structured Indexer2026-11-01Testimony from Timelines: Evidence-Grounded Significance Testing of Temporal Clinical Hypotheses2026-11-01ShallowDefend: Harnessing Shallow Safety Alignment for Multi-Turn Defender2026-10-31Difficulty Calibration Across Time for Membership Inference in Diffusion Models2026-10-30world2vec: Mechanistic world models through latent dynamics learning2026-10-30Elucidating the Design Space of LM Data Attribution2026-10-29Pushing Dexterity and Safety for In-Hand Object Pose Reaching That Works Remarkably Well2026-10-29Can LLMs Uncover Hidden Physical Laws through Free Exploration?2026-10-29Scaling Laws for Tool-Use Agents via Controllable Environment Synthesis