cs.AIAug 20, 2026

Enforcing LLM Safety through DMD-based Classification of Prompt-Response Embedding Dynamics

Authors: Mohamed Akrout, Olivera Kotevska, Dan Wilson

Organizations: Department of Electrical Engineering and Computer Science, University of Tennessee, Knoxville, TN 37996, USA · Computer Science and Mathematics Division, Oak Ridge National Laboratory, Oak Ridge, TN 37830, USA

Abstract

Large Language Models (LLMs) are increasingly deployed in high-stakes applications, yet their tendency to generate toxic, harmful, or policy-violating content poses significant risks. Detecting these unsafe outputs efficiently in a black-box manner remains an open challenge. In this paper, we extend a recently proposed dynamical systems framework designed for hallucination detection to LLM safety classification. By projecting both prompts and responses into high-dimensional embedding spaces and fitting separate Koopman-based predictive models for safe and unsafe regimes, we classify new outputs using a new differential residual score that compares prediction errors of the safe and unsafe regimes. A key contribution is the incorporation of the prompt and response embedding dynamics, yielding fitted Koopman operators that capture crucial interaction patterns. We evaluate our black-box method across three safety benchmarks using three embedding models. Our results show that incorporating prompt embeddings yields consistent improvements, particularly for interaction-dependent violations when paired with causal decoders (e.g., in Llama-3), while response-only violations benefit more from dense semantic embedding representations. These findings opens the door for using dynamical systems to analyze AI systems rather than the dominant paradigm of using AI to model dynamical systems.

Figures & tables

Explore similar work

CardsList
  1. Safety Beyond the Interface: Detecting Harm via Latent States in Large Language Models

    Sep 16, 2026Alizishaan Khatri, Chiquita Prabhu, Omkar NeogiSafety FilteringLLM Safety

  2. Separating Prompt Harmfulness from Interaction Safety via Partial Generation

    Oct 12, 2026Ram Vikas Mishra, Shashank Aggarwal, Jahnavi Kumar +1LLM SafetyLLM Guardrails

  3. From Detection to Refusal: Safer LLMs via Circuit-Guided Weight Scaling

    Aug 30, 2026Kuan-Lin Chu, Chung-En Sun, Tsui-Wei WengLLM SafetyRefusal Behavior in Language Models