ADTGuard:面向大语言模型流式推理的自适应深度-时间防护机制

arXiv cs.AI 论文

摘要

ADTGuard 提出一种自适应深度-时间安全机制,在流式推理中逐 token 检测风险,通过整合多层安全信号与渐进式 token 级训练目标,在仅 16M 可训练参数下达到或超越现有安全护栏的检测性能。

arXiv:2610.36574v1 Announce Type: new Abstract: Large Language Models (LLMs) can generate fluent responses to diverse user requests, yet streaming may expose users to harmful content before generation is complete. Existing guardrails face two limitations in this setting. First, post-hoc moderation at response or chunk boundaries delays intervention, risking harmful exposure when content is released before verification. Second, even with token-level detection, coarse response-level supervision does not specify when harmful content begins, while fixed-layer readouts may miss relevant safety signals at other depths. To address these limitations, we introduce ADTGuard, which checks each token before release, progressively refines token-level training targets, and adapts layer selection to the current prefix. ADTGuard models risk across depth and time through Depth-Time Safety Dynamics (DTSD), which integrates safety evidence across layers at each token and uses it to guide risk accumulation over successive tokens. To adapt the choice of observation layers to the current prefix, we propose the Causal Depth Router (CDR). With only response-level labels available, we further develop Risk-Onset Target Refinement (RTR) to progressively construct token-level training targets for both components. Through extensive experiments across multiple safety benchmarks, we demonstrate that ADTGuard consistently achieves strong streaming detection performance, matching or surpassing state-of-the-art safeguards while requiring only 16M trainable parameters and maintaining competitive per-token latency.
查看原文
查看缓存全文

缓存时间: 2026/10/28 08:06

# 1Introduction
Source: [https://arxiv.org/html/2610.36574](https://arxiv.org/html/2610.36574)
ADTGUARD: ADAPTIVE DEPTH\-TIME SAFEGUARDS FOR STREAMING INFERENCE IN LARGE LANGUAGE MODELS

Chuming Wei1,∗\*Churui Yang1,∗\*Zihan ZHANG2Ruien Li3

Wusheng zhang4Yan Zhang4,†\\daggerGuangwen Yang4

1Academy of Artificial Intelligence and Advanced Technology, Xi’an Jiaotong\-Liverpool University

2Faculty of Science and Engineering, University of Nottingham Ningbo China

3Department of Computer Sciences, University of Wisconsin–Madison

4Department of Computer Science and Technology, Tsinghua University

11footnotetext:Equal contribution\.22footnotetext:Correspondence to: Yan Zhang <yanzhang24@mails\.tsinghua\.edu\.cn\>\.###### Abstract

Large Language Models \(LLMs\) can generate fluent responses to diverse user requests, yet streaming may expose users to harmful content before generation is complete\. Existing guardrails face two limitations in this setting\. First, post\-hoc moderation at response or chunk boundaries delays intervention, risking harmful exposure when content is released before verification\. Second, even with token\-level detection, coarse response\-level supervision does not specify when harmful content begins, while fixed\-layer readouts may miss relevant safety signals at other depths\. To address these limitations, we introduce ADTGuard, which checks each token before release, progressively refines token\-level training targets, and adapts layer selection to the current prefix\. ADTGuard models risk across depth and time through Depth\-Time Safety Dynamics \(DTSD\), which integrates safety evidence across layers at each token and uses it to guide risk accumulation over successive tokens\. To adapt the choice of observation layers to the current prefix, we propose the Causal Depth Router \(CDR\)\. With only response\-level labels available, we further develop Risk\-Onset Target Refinement \(RTR\) to progressively construct token\-level training targets for both components\. Through extensive experiments across multiple safety benchmarks, we demonstrate that ADTGuard consistently achieves strong streaming detection performance, matching or surpassing state\-of\-the\-art safeguards while requiring only 16M trainable parameters and maintaining competitive per\-token latency\.

## 1Introduction

Large language models \(LLMs\) are increasingly deployed in interactive settings where outputs are generated and delivered incrementally\. Despite substantial progress in alignment and content moderation, capable models can still be induced to generate harmful or policy\-violating content under adversarial or challenging inputs\([Andriushchenko et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib1);[Sharma et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib32)\)\. This is particularly consequential for autoregressive generation, where unsafe text may reach the user before a response\-level safeguard can evaluate the completed response\([Inan et al\., 2023](https://arxiv.org/html/2610.36574#bib.bib16);[Wang et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib35);[Yu et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib38)\)\. Effective streaming safeguards must therefore assess risk as generation unfolds and enable intervention before harmful content is exposed to the user\.

Recent work has advanced safety monitoring from post\-hoc detection to chunk\-level and ultimately per\-token detection\([Xuan et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib36);[Zhao et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib40);[Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\)\. However, finer temporal granularity does not make internal observation adaptive\. Most representation\-based safeguards still rely on a fixed layer or predetermined internal states\([Xuan et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib36);[Jiao et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib18);[Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5)\), although safety information can vary substantially across model depth\([Li et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib22);[Zhao et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib41)\)\. A detector may therefore operate at token granularity while still observing the model from a fixed depth\. This raises a complementary question:*where within the model should safety evidence be read as generation evolves?*

A second challenge is supervision granularity\. Most publicly available safety datasets provide response\-level labels rather than token\-level annotations of harmful onset\([Han et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib13);[Ji et al\., 2023](https://arxiv.org/html/2610.36574#bib.bib17);[Ghosh et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib9)\)\. Obtaining such fine\-grained token\-level annotations manually is costly and difficult to scale\. Broadcasting a harmful response label to every decoding position incorrectly marks early benign prefixes as unsafe\([Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5);[He et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib14)\), whereas manually designed temporal priors impose a shared risk progression across responses whose harmful content may emerge at different positions\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\)\. Thus, token\-level monitoring alone does not resolve the mismatch between coarse response\-level supervision and evolving prefix risk\.

To address these challenges, we propose ADTGuard, a lightweight plug\-in safeguard that jointly adapts*where*safety evidence is read and*how*token\-level risk is learned\. A Causal Depth Router \(CDR\) conditions on the prompt and causal response prefix to select a sparse subset of model layers for each response token\. The routed representations are then modeled by Depth\-Time Safety Dynamics \(DTSD\), which integrates safety evidence across selected depth positions and tracks its evolution over response tokens using selective state\-space modeling\([Gu & Dao, 2024](https://arxiv.org/html/2610.36574#bib.bib11)\)\. Together, CDR and DTSD characterize how safety evidence evolves across model depth and generation time as the response unfolds, while keeping the underlying LLM frozen\.

To recover fine\-grained supervision from response\-level labels, we introduce Risk\-Onset Target Refinement \(RTR\)\. RTR uses the detached risk trajectory cached during the preceding training epoch to progressively construct refined token\-level soft targets\([Laine & Aila, 2017](https://arxiv.org/html/2610.36574#bib.bib21);[Wang et al\., 2021](https://arxiv.org/html/2610.36574#bib.bib34)\), refining coarse response labels toward temporally differentiated risk estimates\. This enables fine\-grained risk learning without requiring explicit token\-level onset annotations\. We further characterize the refinement as the solution to a weighted forward\-KL objective and use response\-equal loss aggregation to prevent response length from implicitly reweighting training examples\.

Our contributions are summarized as follows:

1. 1\.We proposeADTGuard, a lightweight streaming safeguard that adaptively selects safety\-relevant internal observations as generation unfolds\. ItsCausal Depth Router \(CDR\)performs prefix\-aware sparse routing over model depth, whileDepth\-Time Safety Dynamics \(DTSD\)jointly models safety evidence across depth and generation time over a frozen LLM\.
2. 2\.We introduceRisk\-Onset Target Refinement \(RTR\), which progressively derives fine\-grained token targets from response\-level supervision without requiring costly token\-level annotations\.
3. 3\.We conduct extensive experiments across multiple safety benchmarks against representative response\-level, representation\-based, and streaming safeguards\. ADTGuard achieves strong streaming detection performance while retaining a lightweight trainable footprint and competitive per\-token latency\.

## 2Related Work

### 2\.1Streaming Safety Detection Based on Internal Representations

Internal representations provide useful signals for safety monitoring, with prior work identifying refusal\-related directions, separating harmfulness from refusal behavior, and revealing substantial variation in safety information across model depth\([Arditi et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib2);[Zhao et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib41);[Li et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib22)\)\. Recent safeguards increasingly exploit such signals at token level\. ShieldHead performs token\-wise detection from hidden representations\([Xuan et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib36)\), while Disentangled Safety Adapters and HiddenGuard use specialized internal representations for safety classification or intervention\([Krishna et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib20);[Mei et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib26)\)\. SIREN aggregates safety\-relevant neurons across layers\([Jiao et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib18)\), whereas Kelp, TrajGuard, Constitutional Classifiers\+\+, and Segment\-Level Coherence model risk across model depth or generation time\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23);[Liu et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib25);[Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5);[He et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib14)\)\. However, their internal observation schemes are typically fixed after training rather than adapting token by token to the evolving response prefix\.

### 2\.2Adaptive Depth and Sequential Modeling

Adaptive computation methods dynamically vary how information is processed across model depth\. Depth\-Adaptive Transformer and Confident Adaptive Language Modeling adjust executed depth\([Elbayad et al\., 2020](https://arxiv.org/html/2610.36574#bib.bib7);[Schuster et al\., 2022](https://arxiv.org/html/2610.36574#bib.bib31)\), while Mixture\-of\-Depths and Mixture\-of\-Recursions route tokens through different computation depths\([Raposo et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib29);[Bae et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib3)\)\. Dynamic layer aggregation and token–layer selective probes further learn input\-dependent readouts across depth\([Dou et al\., 2019](https://arxiv.org/html/2610.36574#bib.bib6);[Meyoyan & Del Corro, 2026](https://arxiv.org/html/2610.36574#bib.bib28)\)\. These methods, however, primarily target general inference or classification rather than adaptive safety readout over a frozen LLM whose full depth is executed\.

Structured state\-space models such as S4 and Mamba provide efficient sequential modeling, with Mamba introducing input\-dependent selective state updates\([Gu et al\., 2022](https://arxiv.org/html/2610.36574#bib.bib12);[Gu & Dao, 2024](https://arxiv.org/html/2610.36574#bib.bib11)\)\. Related safety methods also model temporal risk trajectories\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23);[Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5)\), but depth and time are typically treated separately\. Consequently, temporal modeling does not explicitly account for where safety evidence is read within the model or how depth\-wise observations interact with evolving prefix risk\.

### 2\.3Training Strategies for Token\-Level Safety Detection

Streaming detectors are often trained from response\-level labels, creating a mismatch with token\-level predictions\. Existing approaches use temporal aggregation or regularization, including cumulative\-maximum objectives, smoothing, and window\-based pooling\([Sharma et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib32);[Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5);[He et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib14)\)\. ShieldHead and Kelp derive finer token\-level signals using class prototypes or temporal constraints\([Xuan et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib36);[Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\), while SCM, Qwen3Guard\-Stream, and StreamGuard rely on sentence\-level judgments, unsafe boundaries, or continuation\-based risk estimates\([Li et al\., 2025c](https://arxiv.org/html/2610.36574#bib.bib24);[Zhao et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib40);[Kavumba et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib19)\)\. More broadly, multiple\-instance learning and self\-training show that coarse labels can support instance\-level aggregation or progressively refined targets\([Ilse et al\., 2018](https://arxiv.org/html/2610.36574#bib.bib15);[Laine & Aila, 2017](https://arxiv.org/html/2610.36574#bib.bib21);[Wang et al\., 2021](https://arxiv.org/html/2610.36574#bib.bib34)\)\. Nevertheless, fine\-grained supervision often still depends on additional assumptions, annotations, or rollout procedures, leaving open how to derive temporally differentiated token\-level supervision directly from response\-level labels\.

## 3Methodology

We turn read\-only hidden states of a frozen LLM into a streaming safeguard that evaluates the harmfulness of each generated response prefix\. Existing representation\-based safeguards typically monitor fixed layers\([Xuan et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib36);[Jiao et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib18);[Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5)\), despite substantial variation in safety\-relevant information across model depth\([Li et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib22);[Zhao et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib41)\)\. Meanwhile, response\-level safety labels\([Han et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib13);[Ji et al\., 2023](https://arxiv.org/html/2610.36574#bib.bib17);[Ghosh et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib9)\)leave token\-level risk unspecified, leading detectors to rely on label broadcasting, hand\-crafted temporal priors, or additional boundary or rollout supervision\([Cunningham et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib5);[He et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib14);[Zhao et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib40);[Kavumba et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib19)\)\. ADTGuard addresses these limitations through prefix\-dependent layer selection, depth\-time risk modeling, and progressive token\-target refinement\. As shown in Figure[1](https://arxiv.org/html/2610.36574#S3.F1), ADTGuard integrates these components into a causal streaming detection pipeline over a frozen LLM\. A frozen LLM withLLlayers receives a promptQ1:n=\(q1,…,qn\)Q\_\{1:n\}=\(q\_\{1\},\\ldots,q\_\{n\}\)and generates a responseR1:m=\(r1,…,rm\)R\_\{1:m\}=\(r\_\{1\},\\ldots,r\_\{m\}\)\. We denote the layer\-ℓ\\ellhidden states of prompt tokenqiq\_\{i\}and response tokenrtr\_\{t\}by𝐮i\(ℓ\),𝐡t\(ℓ\)∈ℝd\\mathbf\{u\}\_\{i\}^\{\(\\ell\)\},\\mathbf\{h\}\_\{t\}^\{\(\\ell\)\}\\in\\mathbb\{R\}^\{d\}, respectively, whereddis the backbone hidden dimension\. All hidden states are accessed read\-only\.

![Refer to caption](https://arxiv.org/html/2610.36574v1/adtguard_architecture_paper.png)Figure 1:Overview of ADTGuard\. At each generation step, CDR selects a prefix\-dependent Top\-KKset of layers and normalizes their routing weights\. The selected features are individually reweighted and processed in depth order by DSD, while their weighted fusion is fed to TSD\. The DSD output further conditions the TSD update, coupling depth\-wise safety evidence with temporal risk evolution to produce a causal safety score for each response prefix over a frozen LLM\.### 3\.1Causal Depth Router

#### Prompt initialization\.

To avoid repeatedly processing the prompt during decoding, we compute an initial state𝐬0\\mathbf\{s\}\_\{0\}once before generation\. We average each prompt token’s hidden states across allLLlayers, apply the shared projectionϕ\\phi, and pool over prompt tokens:

𝐬0=Pool⁡\(\{ϕ⁡\(1L​∑ℓ=1L𝐮i\(ℓ\)\)\}i=1n\)\.\\mathbf\{s\}\_\{0\}=\\operatorname\{Pool\}\\\!\\left\(\\left\\\{\\phi\\\!\\left\(\\frac\{1\}\{L\}\\sum\_\{\\ell=1\}^\{L\}\\mathbf\{u\}\_\{i\}^\{\(\\ell\)\}\\right\)\\right\\\}\_\{i=1\}^\{n\}\\right\)\.\(1\)Here,ϕ:ℝd→ℝdp\\phi:\\mathbb\{R\}^\{d\}\\rightarrow\\mathbb\{R\}^\{d\_\{p\}\}projects states to dimensiondpd\_\{p\}, andPool\\operatorname\{Pool\}combines attention pooling with a learned mapping\. The resulting𝐬0∈ℝdp\\mathbf\{s\}\_\{0\}\\in\\mathbb\{R\}^\{d\_\{p\}\}initializes the temporal branch and provides prompt context to the Router\.

#### Prefix\-dependent layer selection\.

We applyϕ\\phito the response hidden states𝐡t\(0\)\\mathbf\{h\}\_\{t\}^\{\(0\)\}from the embedding layer\. Conditioned on𝐬0\\mathbf\{s\}\_\{0\}, causal self\-attention produces contextualized Router states:

\[𝐜0,𝐜1,…,𝐜m\]=CausalAttn⁡\(\[ψ⁡\(𝐬0\),ψ⁡\(ϕ⁡\(𝐡1\(0\)\)\),…,ψ⁡\(ϕ⁡\(𝐡m\(0\)\)\)\]\)\.\[\\mathbf\{c\}\_\{0\},\\mathbf\{c\}\_\{1\},\\ldots,\\mathbf\{c\}\_\{m\}\]=\\operatorname\{CausalAttn\}\\\!\\left\(\[\\psi\(\\mathbf\{s\}\_\{0\}\),\\psi\(\\phi\(\\mathbf\{h\}\_\{1\}^\{\(0\)\}\)\),\\ldots,\\psi\(\\phi\(\\mathbf\{h\}\_\{m\}^\{\(0\)\}\)\)\]\\right\)\.\(2\)We discard𝐜0\\mathbf\{c\}\_\{0\}and use𝐜t\\mathbf\{c\}\_\{t\}as the Router context for response positiontt\. Here,ψ\\psimaps inputs into thedrd\_\{r\}\-dimensional Router space,𝐖q\\mathbf\{W\}\_\{q\}is a learned query projection, and we use sinusoidal positional encodings\([Vaswani et al\., 2017](https://arxiv.org/html/2610.36574#bib.bib33)\)\. Each layer has a learned depth key𝐤ℓ∈ℝdr\\mathbf\{k\}\_\{\\ell\}\\in\\mathbb\{R\}^\{d\_\{r\}\}\. With routing budget1≤K≤L1\\leq K\\leq L, CDR scores all layers, selects the topKK, and normalizes scores within the selected set:

et,ℓ\\displaystyle e\_\{t,\\ell\}=\(𝐖q​𝐜t\)⊤​𝐤ℓdr,\\displaystyle=\\frac\{\(\\mathbf\{W\}\_\{q\}\\mathbf\{c\}\_\{t\}\)^\{\\top\}\\mathbf\{k\}\_\{\\ell\}\}\{\\sqrt\{d\_\{r\}\}\},ℐt\\displaystyle\\mathcal\{I\}\_\{t\}=TopKℓ∈\{1,…,L\}⁡\(et,ℓ,K\),\\displaystyle=\\operatorname\{TopK\}\_\{\\ell\\in\\\{1,\\ldots,L\\\}\}\(e\_\{t,\\ell\},K\),\(3\)αt,j\\displaystyle\\alpha\_\{t,j\}=exp⁡\(et,ℓt,j\)∑j′=1Kexp⁡\(et,ℓt,j′\),\\displaystyle=\\frac\{\\exp\(e\_\{t,\\ell\_\{t,j\}\}\)\}\{\\sum\_\{j^\{\\prime\}=1\}^\{K\}\\exp\(e\_\{t,\\ell\_\{t,j^\{\\prime\}\}\}\)\},ℓt,1\\displaystyle\\ell\_\{t,1\}<⋯<ℓt,K\.\\displaystyle<\\cdots<\\ell\_\{t,K\}\.\(4\)The selected setℐt=\{ℓt,1,…,ℓt,K\}\\mathcal\{I\}\_\{t\}=\\\{\\ell\_\{t,1\},\\ldots,\\ell\_\{t,K\}\\\}is ordered by depth with weightsαt,j\\alpha\_\{t,j\}\. The frozen backbone still executes all layers; CDR only determines whichKKhidden states are read by the safeguard\.

### 3\.2Depth\-Time Safety Dynamics

Depth\-Time Safety Dynamics \(DTSD\) contains two selective state\-space branches: Depth Safety Dynamics \(DSD\) integrates routed evidence across model depth, while Temporal Safety Dynamics \(TSD\) tracks its evolution across response tokens conditioned on the depth output\. For𝐯t,j=ϕ⁡\(𝐡t\(ℓt,j\)\)\\mathbf\{v\}\_\{t,j\}=\\phi\(\\mathbf\{h\}\_\{t\}^\{\(\\ell\_\{t,j\}\)\}\), we define

𝐱t,jD=K​αt,j​𝐯t,j,𝐱tT=∑j=1Kαt,j​𝐯t,j\.\\mathbf\{x\}^\{D\}\_\{t,j\}=K\\alpha\_\{t,j\}\\mathbf\{v\}\_\{t,j\},\\qquad\\mathbf\{x\}^\{T\}\_\{t\}=\\sum\_\{j=1\}^\{K\}\\alpha\_\{t,j\}\\mathbf\{v\}\_\{t,j\}\.\(5\)The factorKKpreserves the scale of each projected state under uniform routing\. Conceptually, letting𝐱tD​\(u\)\\mathbf\{x\}\_\{t\}^\{D\}\(u\)and𝐱T​\(τ\)\\mathbf\{x\}^\{T\}\(\\tau\)denote the continuous counterparts of the above inputs, depth and temporal states𝐝t​\(u\),𝐬⁡\(τ\)∈ℝdp\\mathbf\{d\}\_\{t\}\(u\),\\mathbf\{s\}\(\\tau\)\\in\\mathbb\{R\}^\{d\_\{p\}\}evolve over normalized depthu∈\[0,1\]u\\in\[0,1\]and generation progressτ\\tauas\([Chen et al\., 2018](https://arxiv.org/html/2610.36574#bib.bib4)\)

∂𝐝t​\(u\)∂u=FD​\(𝐝t​\(u\),𝐱tD​\(u\)\),d​𝐬​\(τ\)d​τ=FT​\(𝐬⁡\(τ\),𝐱T​\(τ\),𝐝⁡\(τ\)\)\.\\frac\{\\partial\\mathbf\{d\}\_\{t\}\(u\)\}\{\\partial u\}=F\_\{D\}\\\!\\left\(\\mathbf\{d\}\_\{t\}\(u\),\\mathbf\{x\}\_\{t\}^\{D\}\(u\)\\right\),\\quad\\frac\{\\mathrm\{d\}\\mathbf\{s\}\(\\tau\)\}\{\\mathrm\{d\}\\tau\}=F\_\{T\}\\\!\\left\(\\mathbf\{s\}\(\\tau\),\\mathbf\{x\}^\{T\}\(\\tau\);\\mathbf\{d\}\(\\tau\)\\right\)\.\(6\)Here,𝐝⁡\(τ\)\\mathbf\{d\}\(\\tau\)denotes the corresponding depth summary;FDF\_\{D\}integrates depth evidence, whileFTF\_\{T\}evolves the temporal state conditioned on it\.

#### Selective state\-space realization\.

Both DSD and TSD use selective state\-space recurrences with separate parameters\([Gu et al\., 2022](https://arxiv.org/html/2610.36574#bib.bib12);[Gu & Dao, 2024](https://arxiv.org/html/2610.36574#bib.bib11)\)\. For input𝐱k\\mathbf\{x\}\_\{k\}, a learned mappingΠ\\Piproduces𝚫^k\\widehat\{\\bm\{\\Delta\}\}\_\{k\}, input coefficients𝐁k\\mathbf\{B\}\_\{k\}, and readout coefficients𝐂k\\mathbf\{C\}\_\{k\}\. For clarity, the recurrence below is written for a single channel, wherexk,Δk,ok,Dx\_\{k\},\\Delta\_\{k\},o\_\{k\},Dare scalars and𝐪k\\mathbf\{q\}\_\{k\}is the recurrent state:

\(𝚫^k,𝐁k,𝐂k\)\\displaystyle\(\\widehat\{\\bm\{\\Delta\}\}\_\{k\},\\mathbf\{B\}\_\{k\},\\mathbf\{C\}\_\{k\}\)=Π⁡\(𝐱k\),\\displaystyle=\\Pi\(\\mathbf\{x\}\_\{k\}\),𝚫k\\displaystyle\\qquad\\bm\{\\Delta\}\_\{k\}=softplus⁡\(𝚫^k\),\\displaystyle=\\operatorname\{softplus\}\(\\widehat\{\\bm\{\\Delta\}\}\_\{k\}\),\(7\)𝐀¯k\\displaystyle\\bar\{\\mathbf\{A\}\}\_\{k\}=exp⁡\(Δk​𝐀\),\\displaystyle=\\exp\(\\Delta\_\{k\}\\mathbf\{A\}\),𝐁¯k\\displaystyle\\bar\{\\mathbf\{B\}\}\_\{k\}=Δk​𝐁k,\\displaystyle=\\Delta\_\{k\}\\mathbf\{B\}\_\{k\},\(8\)𝐪k\\displaystyle\\mathbf\{q\}\_\{k\}=𝐀¯k​𝐪k−1\+𝐁¯k​xk,\\displaystyle=\\bar\{\\mathbf\{A\}\}\_\{k\}\\mathbf\{q\}\_\{k\-1\}\+\\bar\{\\mathbf\{B\}\}\_\{k\}x\_\{k\},ok\\displaystyle o\_\{k\}=𝐂k​𝐪k\+D​xk\.\\displaystyle=\\mathbf\{C\}\_\{k\}\\mathbf\{q\}\_\{k\}\+Dx\_\{k\}\.\(9\)Here,kkindexes selected layers or response positions,𝐀\\mathbf\{A\}is a learned diagonal transition matrix, andDDprovides a direct input\-to\-output mapping\. The step size controls the rate of state evolution\.

#### Depth Safety Dynamics\.

To account for uneven spacing between selected layers\([Rubanova et al\., 2019](https://arxiv.org/html/2610.36574#bib.bib30)\), we scale the depth step size by their normalized gaps\. Withut,j=ℓt,j/Lu\_\{t,j\}=\\ell\_\{t,j\}/Landut,0=0u\_\{t,0\}=0,

gt,j=K⁡\(ut,j−ut,j−1\),𝚫t,jD=gt,j​softplus⁡\(𝚫^t,jD\)\.g\_\{t,j\}=K\(u\_\{t,j\}\-u\_\{t,j\-1\}\),\\qquad\\bm\{\\Delta\}^\{D\}\_\{t,j\}=g\_\{t,j\}\\operatorname\{softplus\}\(\\widehat\{\\bm\{\\Delta\}\}^\{D\}\_\{t,j\}\)\.\(10\)The factorKKexpresses each gap relative to the uniform spacing1/K1/K\. The depth branch processes𝐱Dt,1:K\\mathbf\{x\}^\{D\}\_\{t,1:K\}in depth order, initializes its recurrent state to zero for each response token, and uses the final selected\-layer output as𝐝t\\mathbf\{d\}\_\{t\}\.

#### Temporal Safety Dynamics\.

The temporal branch is initialized from𝐬0\\mathbf\{s\}\_\{0\}and carries its recurrent state across response positions\. At positiontt, it receives𝐱tT\\mathbf\{x\}\_\{t\}^\{T\}, while the depth output modulates its step size:

𝚫tT=softplus⁡\(𝚫^tT\+γ⁡\(𝐝t\)\)\.\\bm\{\\Delta\}^\{T\}\_\{t\}=\\operatorname\{softplus\}\\\!\\left\(\\widehat\{\\bm\{\\Delta\}\}^\{T\}\_\{t\}\+\\gamma\(\\mathbf\{d\}\_\{t\}\)\\right\)\.\(11\)The learned mappingγ\\gammaadjusts the base step size according to the current depth evidence, coupling depth\-wise safety information to temporal risk evolution\.

#### Risk prediction\.

Each branchb∈\{D,T\}b\\in\\\{D,T\\\}produces benign and harmful logits𝐳tb=\(zt,0b,zt,1b\)\\mathbf\{z\}\_\{t\}^\{b\}=\(z\_\{t,0\}^\{b\},z\_\{t,1\}^\{b\}\):

atb=zt,1b−zt,0b,ptb=σ⁡\(atb\)=softmax⁡\(𝐳tb\)1\.a\_\{t\}^\{b\}=z\_\{t,1\}^\{b\}\-z\_\{t,0\}^\{b\},\\qquad p\_\{t\}^\{b\}=\\sigma\(a\_\{t\}^\{b\}\)=\\operatorname\{softmax\}\(\\mathbf\{z\}\_\{t\}^\{b\}\)\_\{1\}\.\(12\)The temporal predictionpt=ptTp\_\{t\}=p\_\{t\}^\{T\}is the final risk score for the response prefix up to positiontt\.

### 3\.3Risk\-Onset Target Refinement

Response\-level labels indicate overall harmfulness but leave token\-level risk unspecified\. Risk\-Onset Target Refinement \(RTR\) progressively derives token\-level targets from detached risk trajectories cached during the preceding epoch, avoiding a separate teacher or additional inference pass\([Laine & Aila, 2017](https://arxiv.org/html/2610.36574#bib.bib21);[Wang et al\., 2021](https://arxiv.org/html/2610.36574#bib.bib34)\)\. For a harmful responseiiwithyi=1y\_\{i\}=1, the onset distributionρi,t\(e−1\)\\rho\_\{i,t\}^\{\(e\-1\)\}is obtained by normalizing the positive increments\[pi,t\(e−1\)−pi,t−1\(e−1\)\]\+\[p\_\{i,t\}^\{\(e\-1\)\}\-p\_\{i,t\-1\}^\{\(e\-1\)\}\]\_\{\+\}of the cached trajectory over valid positions, with cumulative profile

ci,t\(e−1\)=∑τ=1tρi,τ\(e−1\)\.c\_\{i,t\}^\{\(e\-1\)\}=\\sum\_\{\\tau=1\}^\{t\}\\rho\_\{i,\\tau\}^\{\(e\-1\)\}\.\(13\)With epoch\-dependent weightβe∈\[0,1\]\\beta\_\{e\}\\in\[0,1\], RTR refines the target as

qi,t\(e\)=βe\+\(1−βe\)​ci,t\(e−1\),yi=1,q\_\{i,t\}^\{\(e\)\}=\\beta\_\{e\}\+\(1\-\\beta\_\{e\}\)c\_\{i,t\}^\{\(e\-1\)\},\\qquad y\_\{i\}=1,\(14\)while benign responses useci,t\(e−1\)=qi,t\(e\)=0c\_\{i,t\}^\{\(e\-1\)\}=q\_\{i,t\}^\{\(e\)\}=0\. The first epoch uses the response\-level label throughout; decreasingβe\\beta\_\{e\}progressively shifts supervision toward the model\-derived onset profile\.

#### Forward\-KL characterization of RTR\.

ForBer⁡\(a\)\\operatorname\{Ber\}\(a\)denoting a Bernoulli distribution, response labely∈\{0,1\}y\\in\\\{0,1\\\}, and fixed profilec∈\[0,1\]c\\in\[0,1\]withc=0c=0for benign responses,

𝒥\(q\)=βDKL\(Ber\(y\)∥Ber\(q\)\)\+\(1−β\)DKL\(Ber\(c\)∥Ber\(q\)\)\\mathcal\{J\}\(q\)=\\beta D\_\{\\mathrm\{KL\}\}\\\!\\left\(\\operatorname\{Ber\}\(y\)\\,\\\|\\,\\operatorname\{Ber\}\(q\)\\right\)\+\(1\-\\beta\)D\_\{\\mathrm\{KL\}\}\\\!\\left\(\\operatorname\{Ber\}\(c\)\\,\\\|\\,\\operatorname\{Ber\}\(q\)\\right\)\(15\)has the unique minimizer

q⋆=β​y\+\(1−β\)​c\.q^\{\\star\}=\\beta y\+\(1\-\\beta\)c\.\(16\)Thus, conditioned on a fixed model\-derived onset profile, the RTR target is the exact weighted forward\-KL optimum between response\-level supervision and the onset profile; see Appendix[D\.1](https://arxiv.org/html/2610.36574#A4.SS1)\.

### 3\.4Training Objective and Streaming Inference

We train both branches with RTR targets, averaging binary cross\-entropy within each response and then across the batch so that responses receive equal weight:

ℒREb=1B​∑i=1B1mi​∑t=1miBCEWithLogits⁡\(ai,tb,qi,t\(e\)\),b∈\{D,T\}\.\\mathcal\{L\}\_\{\\mathrm\{RE\}\}^\{b\}=\\frac\{1\}\{B\}\\sum\_\{i=1\}^\{B\}\\frac\{1\}\{m\_\{i\}\}\\sum\_\{t=1\}^\{m\_\{i\}\}\\operatorname\{BCEWithLogits\}\(a\_\{i,t\}^\{b\},q\_\{i,t\}^\{\(e\)\}\),\\qquad b\\in\\\{D,T\\\}\.\(17\)Here,BBis the batch size andmim\_\{i\}counts valid response tokens, excluding padding and terminal EOS\. To encourage nondecreasing temporal predictions, we penalize risk decreases over valid adjacent token pairs:

ℒmono=∑i=1B∑t=2mimax⁡\(pi,t−1T−pi,tT,0\)max⁡\{1,∑i=1B\(mi−1\)\}\.\\mathcal\{L\}\_\{\\mathrm\{mono\}\}=\\frac\{\\sum\_\{i=1\}^\{B\}\\sum\_\{t=2\}^\{m\_\{i\}\}\\max\(p^\{T\}\_\{i,t\-1\}\-p^\{T\}\_\{i,t\},0\)\}\{\\max\\\{1,\\sum\_\{i=1\}^\{B\}\(m\_\{i\}\-1\)\\\}\}\.\(18\)The total loss is

ℒ=λT​ℒRET\+λD​ℒRED\+λM​ℒmono,\\mathcal\{L\}=\\lambda\_\{T\}\\mathcal\{L\}\_\{\\mathrm\{RE\}\}^\{T\}\+\\lambda\_\{D\}\\mathcal\{L\}\_\{\\mathrm\{RE\}\}^\{D\}\+\\lambda\_\{M\}\\mathcal\{L\}\_\{\\mathrm\{mono\}\},\(19\)whereλT,λD,λM\\lambda\_\{T\},\\lambda\_\{D\},\\lambda\_\{M\}weight the three terms\. Training processes response positions in parallel while preserving causality\. During streaming inference, the LLM and Router KV caches and the recurrent TSD state are reused across decoding steps, avoiding recomputation of earlier tokens\. Each risk prediction therefore depends only on the prompt and currently available response prefix\.

## 4Experiments

### 4\.1Experimental Setup

We use four NVIDIA A800 GPUs \(80 GB each\) for the default training setup\. Qwen3\-8B Base\([Yang et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib37)\)serves as the primary backbone, with additional experiments on Llama\-3\.1\-8B Base\([Grattafiori et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib10)\)and Gemma\-7B Base\([Gemma Team et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib8)\)\. During training, the backbone remains frozen and only the attached ADTGuard module is updated, with approximately 15\.6M trainable parameters\. For each backbone–dataset pair, a separate detector is trained for 5 epochs with a global batch size of 8 and a maximum combined prompt–response length of 4,096 tokens\. Training uses AdamW with a learning rate of5×10−55\\times 10^\{\-5\}, weight decay of 0\.1, a warmup ratio of 0\.05, and a cosine learning\-rate schedule\. Unless otherwise specified, the same ADTGuard configuration is fixed across all backbone–dataset settings; the analyses in Section 4\.5 are post\-hoc sensitivity studies and do not affect the reported main results\. Further implementation details are provided in Appendix[B\.1](https://arxiv.org/html/2610.36574#A2.SS1)\.

Datasets\.We evaluate on five safety benchmarks: SGB\-S\-Eval and SGB\-WildGuard from StreamGuardBench \(SGB\)\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\), AEGIS2\.0\([Ghosh et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib9)\), BeaverTails\([Ji et al\., 2023](https://arxiv.org/html/2610.36574#bib.bib17)\), and WildGuard\([Han et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib13)\)\. Within SGB, SGB\-S\-Eval and SGB\-WildGuard contain generated and annotated responses to prompts drawn from S\-Eval and WildGuard, respectively, whereas WildGuard uses the original public responses and safety annotations\.

Baselines\.We compare ADTGuard against two groups of safeguards\. \(i\) Dedicated moderation models include Qwen3Guard\-Gen\-8B, Qwen3Guard\-Stream\-8B\([Zhao et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib40)\), Llama\-Guard\-4\-12B\([Meta, 2025](https://arxiv.org/html/2610.36574#bib.bib27)\), and SentGuard\-4B\([Yu et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib38)\), all adapted to the corresponding training split using LoRA\. \(ii\) Representation\-based safeguards are evaluated on the same backbone as ADTGuard\. SIREN\([Jiao et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib18)\)aggregates safety\-relevant neurons across layers, while Kelp\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\)incorporates recurrent latent dynamics to track risk over time\.

Metrics\.Safety evaluation should capture both the correctness of the final response judgment and the ability to identify risk as generation unfolds\. Therefore, we use unsafe\-class F1 as the primary metric, treating unsafe responses as the positive class, and report two variants: \(i\)*Response F1*, computed from the prediction at the final response token; and \(ii\)*Streaming F1*, where a response is considered unsafe if any evaluated prefix is detected as unsafe\. Detailed evaluation protocols are provided in Appendix[B\.3](https://arxiv.org/html/2610.36574#A2.SS3)\.

### 4\.2Main Results

Table[1](https://arxiv.org/html/2610.36574#S4.T1)compares representation\-based safeguards on the same backbone\. Table[2](https://arxiv.org/html/2610.36574#S4.T2)compares dedicated moderation models\.

Comparison with representation\-based safeguards\.As shown in Table[1](https://arxiv.org/html/2610.36574#S4.T1), ADTGuard achieves the best Streaming F1 in 14 of 15 backbone–dataset settings and the best Response F1 in 14 of 15 settings\. With Qwen3\-8B, ADTGuard reaches Streaming F1 scores of 93\.57 on SGB\-S\-Eval and 85\.87 on SGB\-WildGuard, outperforming the strongest baselines by 5\.24 and 25\.75 points, respectively\. Similar gains are observed across Llama\-3\.1\-8B and Gemma\-7B, indicating that the improvement is not tied to a specific backbone\. These results suggest that adaptive layer selection and joint depth\-time modeling provide stronger streaming safety representations than fixed readout schemes\. Notably, ADTGuard’s Streaming F1 also remains close to its Response F1 across most settings, indicating consistent risk detection as generation unfolds\.

Comparison with dedicated moderation models\.As shown in Table[2](https://arxiv.org/html/2610.36574#S4.T2), we further compare ADTGuard with standalone dedicated moderation models\. In this comparison, ADTGuard uses Qwen3\-8B Base and reuses its internal representations, requiring only an additional 15\.6M\-parameter detection module, whereas the dedicated guards operate as separate 4B–12B moderation models\. Despite this difference in deployment paradigm, ADTGuard achieves the highest Streaming F1 on four of the five datasets, with the largest improvement of 5\.05 points over Qwen3Guard\-Stream\-8B on SGB\-WildGuard\. These results show that leveraging the protected model’s internal representations can provide competitive streaming detection without deploying an additional large\-scale moderation model\.

Table 1:Comparison on the same backbone\. F1 comparison among representation\-based safeguards, including SIREN, Kelp, and ADTGuard, using Qwen3\-8B Base, Llama\-3\.1\-8B Base, and Gemma\-7B Base as shared backbones\. Response / Streaming unsafe\-class F1 \(%\) are reported\. Bold and underline denote the best and second\-best results, respectively, for each metric and dataset within the same backbone\.SIREN \(in\-domain\): trained separately on the corresponding benchmark training split\. SIREN \(official\): trained on the seven official datasets used by SIREN\.

Table 2:Comparison with dedicated moderation models\. F1 comparison with standalone moderation models, including Qwen3Guard\-Gen\-8B, Qwen3Guard\-Stream\-8B, Llama\-Guard\-4\-12B, and SentGuard\-4B\. ADTGuard uses Qwen3\-8B Base as the protected backbone\. Response / Streaming unsafe\-class F1 are reported\. Bold and underline denote the best and second\-best results, respectively, for each metric and dataset\.The four LoRA\-adapted guards check every 10 tokens on SGB\. On public datasets, Qwen3Guard\-Stream checks tokens and SentGuard checks cumulative sentences\. “—” denotes unreported results\.

### 4\.3Ablation Study

We conduct all ablations on SGB\-S\-Eval with Qwen3\-8B Base, using the same data split, optimizer, five\-epoch training budget, and random seed \(42\) throughout\. All ablations report the final checkpoint at a threshold of 0\.5\.

Table 3:Component ablation\. Starting from an approximately parameter\-matched token\-wise MLP baseline, we progressively introduce CDR, replace the MLP with DTSD, and then add RTR and Mono on SGB\-S\-Eval with Qwen3\-8B Base\. Final\-epoch unsafe\-class F1 \(%\) is reported\. Bold and underline denote the best and second\-best results, respectively\.Component Analysis\.We progressively introduce CDR, DTSD, RTR, and Mono to an approximately parameter\-matched token\-wise MLP baseline to examine the contribution of each component\. As shown in Table[3](https://arxiv.org/html/2610.36574#S4.T3), adding CDR alone yields only a modest improvement, whereas combining CDR with DTSD increases Response F1 from 88\.06 to 92\.83 and Streaming F1 from 86\.09 to 87\.51\. This suggests that adaptive layer selection becomes substantially more effective when the routed representations are further integrated through depth\-time dynamics, allowing the detector to aggregate safety evidence across both selected model depths and successive response positions\. RTR then produces the largest improvement in streaming performance, increasing Streaming F1 from 87\.51 to 93\.58 while also improving Response F1 to 93\.58\. This result highlights the importance of progressively refined token\-level targets, which reduce the mismatch between coarse response\-level supervision and the evolving risk of intermediate prefixes\. Finally, the monotonicity regularizer penalizes decreases in temporal risk, encouraging a more consistent risk trajectory across generation\. It slightly improves Response F1 from 93\.58 to 93\.67 while keeping Streaming F1 essentially unchanged, indicating that monotonic regularization mainly stabilizes the learned risk evolution without sacrificing streaming detection performance\.

### 4\.4Latency Evaluation

ADTGuard enables token\-by\-token safety monitoring with modest inference overhead\. We evaluate Qwen3\-8B Base on a single NVIDIA A800 GPU \(80 GB\) with batch size 1, retaining all token\-level checks without early termination\. With a 1,000\-token prompt and 1,024 output tokens, ADTGuard adds 2\.33 ms of amortized latency per output token, increasing total request time from 19\.32 s to 21\.71 s \(\+12\.36%\)\. At the same output length, the added cost remains within 2\.31–2\.35 ms/token across prompt lengths of 128–2,048 tokens\. Together with the detection results above, these measurements highlight ADTGuard’s effective balance between streaming detection performance and inference efficiency\. Full latency results and evaluation details are provided in Appendix[C\.3](https://arxiv.org/html/2610.36574#A3.SS3)\.

### 4\.5Hyperparameter Analysis

We conduct a controlled hyperparameter analysis on SGB\-S\-Eval with Qwen3\-8B Base\. All experiments follow the same training configuration as the default ADTGuard setting, with only the hyperparameter under study varied in each comparison\. Specifically, we examine two key choices: the routing budgetkk, which determines the number of selected observation layers, and the RTR scheduleβ1:5\\beta\_\{1:5\}, which controls the transition from response\-level supervision to model\-derived token\-level targets\. For the routing study, we varykkfrom 1 to 9 while keeping the default RTR schedule fixed\. For the target\-refinement study, we fixk=4k=4and compare different RTR schedules over the five training epochs\.

Table 4:Hyperparameter analysis\. Routing budget and target\-refinement schedule on SGB\-S\-Eval with Qwen3\-8B Base\. Final\-epoch unsafe\-class F1 \(%\) is reported\. Panel \(a\) varies only the routing budgetkk, while panel \(b\) fixesk=4k=4and varies the five epoch\-wiseβ\\betavalues\. FP/FN counts refer to Streaming\. Bold and underline denote the best and second\-best results, respectively, within each panel and metric\.\(a\) Number of observation layers

\(b\) Soft\-target schedule

Routing Budget\.Fork=1k=1–99, Response and Streaming F1 remain consistently high, with the best overall performance obtained atk=4k=4\(Table[4](https://arxiv.org/html/2610.36574#S4.T4)\(a\)\)\. In particular,k=1k=1yields noticeably lower scores than the multi\-layer settings, suggesting that relying on a single observation layer may provide insufficient coverage of the distributed safety evidence across model depth\. Increasingkkto 4 improves both Response and Streaming F1, indicating that a small set of adaptively selected layers is sufficient to capture complementary safety signals\. Beyondk=4k=4, however, larger routing budgets bring no further gains and instead produce small fluctuations in performance\. Since increasingkkalso requires processing more selected representations in the detector, it introduces additional inference cost without corresponding performance improvements\. These results supportk=4k=4as a practical operating point that balances detection quality and computational efficiency\.

Target Refinement\.We further study the effect of the RTR refinement schedule by comparing several choices ofβ1:5\\beta\_\{1:5\}\. The two extreme settings exhibit noticeably different behavior: keeping hard response\-level targets throughout training leads to a substantially lower Streaming F1 of 87\.68, while immediately switching to model\-derived targets improves it to 93\.10\. In contrast, the three gradual schedules, Linear, Cosine, and Default, achieve very similar performance, with Response F1 ranging from 93\.51 to 93\.67 and Streaming F1 from 93\.41 to 93\.58\. This suggests that RTR is not overly sensitive to the exact form of the decay schedule once supervision is refined progressively rather than switched abruptly\. The consistently strong performance across these gradual schedules demonstrates the robustness of RTR to reasonable choices ofβ\\beta\.

## 5Conclusion

We introduced ADTGuard, a lightweight streaming safeguard that checks each token before release while keeping the protected LLM frozen\. Its central contribution is to jointly adapt the internal evidence used for detection and the supervision used to learn token\-level risk\. DTSD integrates safety evidence across model depth to guide temporal risk accumulation, with CDR selecting observation layers conditioned on the evolving prefix\. RTR progressively constructs token\-level training targets from predicted risk trajectories under response\-level supervision, without requiring additional token annotations or rollout generation\. Across the evaluated safety benchmarks, ADTGuard matches or surpasses state\-of\-the\-art safeguards with 16M trainable parameters and competitive per\-token latency\. These results highlight the value of coupling adaptive internal observation with progressively refined supervision, providing a practical path toward effective streaming safety detection learned from coarse response\-level labels\.

## References

- Andriushchenko et al\. \(2025\)Maksym Andriushchenko, Francesco Croce, and Nicolas Flammarion\.Jailbreaking leading safety\-aligned LLMs with simple adaptive attacks\.In*International Conference on Learning Representations*, 2025\.URL[https://arxiv\.org/abs/2404\.02151](https://arxiv.org/abs/2404.02151)\.
- Arditi et al\. \(2024\)Andy Arditi, Oscar Obeso, Aaquib Syed, Daniel Paleka, Nina Panickssery, Wes Gurnee, and Neel Nanda\.Refusal in language models is mediated by a single direction\.In*Advances in Neural Information Processing Systems*, 2024\.URL[https://arxiv\.org/abs/2406\.11717](https://arxiv.org/abs/2406.11717)\.
- Bae et al\. \(2025\)Sangmin Bae, Yujin Kim, Reza Bayat, Sungnyun Kim, Jiyoun Ha, Tal Schuster, Adam Fisch, Hrayr Harutyunyan, Ziwei Ji, Aaron Courville, and Se\-Young Yun\.Mixture\-of\-recursions: Learning dynamic recursive depths for adaptive token\-level computation\.In*Advances in Neural Information Processing Systems*, 2025\.URL[https://arxiv\.org/abs/2507\.10524](https://arxiv.org/abs/2507.10524)\.
- Chen et al\. \(2018\)Ricky T\. Q\. Chen, Yulia Rubanova, Jesse Bettencourt, and David K\. Duvenaud\.Neural ordinary differential equations\.In*Advances in Neural Information Processing Systems*, volume 31, 2018\.URL[https://proceedings\.neurips\.cc/paper/2018/hash/69386f6bb1dfed68692a24c8686939b9\-Abstract\.html](https://proceedings.neurips.cc/paper/2018/hash/69386f6bb1dfed68692a24c8686939b9-Abstract.html)\.
- Cunningham et al\. \(2026\)Hoagy Cunningham, Jerry Wei, Zihan Wang, Andrew Persic, Alwin Peng, Jordan Abderrachid, Raj Agarwal, Bobby Chen, Andy Dau, Alek Dimitriev, et al\.Constitutional classifiers\+\+: Efficient production\-grade defenses against universal jailbreaks\.In*International Conference on Learning Representations*, 2026\.URL[https://arxiv\.org/abs/2601\.04603](https://arxiv.org/abs/2601.04603)\.
- Dou et al\. \(2019\)Zi\-Yi Dou, Zhaopeng Tu, Xing Wang, Longyue Wang, Shuming Shi, and Tong Zhang\.Dynamic layer aggregation for neural machine translation with routing\-by\-agreement\.In*Proceedings of the AAAI Conference on Artificial Intelligence*, volume 33, pp\. 86–93, 2019\.doi:10\.1609/aaai\.v33i01\.330186\.URL[https://ojs\.aaai\.org/index\.php/AAAI/article/view/3772](https://ojs.aaai.org/index.php/AAAI/article/view/3772)\.
- Elbayad et al\. \(2020\)Maha Elbayad, Jiatao Gu, Edouard Grave, and Michael Auli\.Depth\-adaptive transformer\.In*International Conference on Learning Representations*, 2020\.URL[https://arxiv\.org/abs/1910\.10073](https://arxiv.org/abs/1910.10073)\.
- Gemma Team et al\. \(2024\)Gemma Team, Thomas Mesnard, Cassidy Hardin, Robert Dadashi, Surya Bhupatiraju, Shreya Pathak, Laurent Sifre, Morgane Rivière, Mihir Sanjay Kale, Juliette Love, et al\.Gemma: Open models based on gemini research and technology\.*arXiv preprint arXiv:2403\.08295*, 2024\.URL[https://arxiv\.org/abs/2403\.08295](https://arxiv.org/abs/2403.08295)\.
- Ghosh et al\. \(2025\)Shaona Ghosh, Prasoon Varshney, Makesh Narsimhan Sreedhar, Aishwarya Padmakumar, Traian Rebedea, Jibin Rajan Varghese, and Christopher Parisien\.AEGIS2\.0: A diverse AI safety dataset and risks taxonomy for alignment of LLM guardrails\.In*Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies \(Volume 1: Long Papers\)*, pp\. 5992–6026\. Association for Computational Linguistics, 2025\.doi:10\.18653/v1/2025\.naacl\-long\.306\.URL[https://aclanthology\.org/2025\.naacl\-long\.306/](https://aclanthology.org/2025.naacl-long.306/)\.
- Grattafiori et al\. \(2024\)Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al\-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, et al\.The llama 3 herd of models\.*arXiv preprint arXiv:2407\.21783*, 2024\.URL[https://arxiv\.org/abs/2407\.21783](https://arxiv.org/abs/2407.21783)\.
- Gu & Dao \(2024\)Albert Gu and Tri Dao\.Mamba: Linear\-time sequence modeling with selective state spaces\.In*First Conference on Language Modeling*, 2024\.URL[https://openreview\.net/forum?id=tEYskw1VY2](https://openreview.net/forum?id=tEYskw1VY2)\.
- Gu et al\. \(2022\)Albert Gu, Karan Goel, and Christopher Ré\.Efficiently modeling long sequences with structured state spaces\.In*International Conference on Learning Representations*, 2022\.URL[https://arxiv\.org/abs/2111\.00396](https://arxiv.org/abs/2111.00396)\.
- Han et al\. \(2024\)Seungju Han, Kavel Rao, Allyson Ettinger, Liwei Jiang, Bill Yuchen Lin, Nathan Lambert, Yejin Choi, and Nouha Dziri\.WildGuard: Open one\-stop moderation tools for safety risks, jailbreaks, and refusals of LLMs\.In*Advances in Neural Information Processing Systems*, 2024\.doi:10\.52202/079017\-0261\.URL[https://papers\.nips\.cc/paper\_files/paper/2024/hash/0f69b4b96a46f284b726fbd70f74fb3b\-Abstract\-Datasets\_and\_Benchmarks\_Track\.html](https://papers.nips.cc/paper_files/paper/2024/hash/0f69b4b96a46f284b726fbd70f74fb3b-Abstract-Datasets_and_Benchmarks_Track.html)\.
- He et al\. \(2026\)Xuanli He, Bilgehan Sel, Faizan Ali, Jenny Bao, Hoagy Cunningham, and Jerry Wei\.Segment\-level coherence for robust harmful intent probing in LLMs\.*arXiv preprint arXiv:2604\.14865*, 2026\.URL[https://arxiv\.org/abs/2604\.14865](https://arxiv.org/abs/2604.14865)\.
- Ilse et al\. \(2018\)Maximilian Ilse, Jakub M\. Tomczak, and Max Welling\.Attention\-based deep multiple instance learning\.In*Proceedings of the 35th International Conference on Machine Learning*, volume 80, pp\. 2127–2136\. PMLR, 2018\.URL[https://proceedings\.mlr\.press/v80/ilse18a\.html](https://proceedings.mlr.press/v80/ilse18a.html)\.
- Inan et al\. \(2023\)Hakan Inan, Kartikeya Upasani, Jianfeng Chi, Rashi Rungta, Krithika Iyer, Yuning Mao, Michael Tontchev, Qing Hu, Brian Fuller, Davide Testuggine, and Madian Khabsa\.Llama Guard: LLM\-based input\-output safeguard for human\-AI conversations\.*arXiv preprint arXiv:2312\.06674*, 2023\.URL[https://arxiv\.org/abs/2312\.06674](https://arxiv.org/abs/2312.06674)\.
- Ji et al\. \(2023\)Jiaming Ji, Mickel Liu, Juntao Dai, Xuehai Pan, Chi Zhang, Ce Bian, Boyuan Chen, Ruiyang Sun, Yizhou Wang, and Yaodong Yang\.BeaverTails: Towards improved safety alignment of LLM via a human\-preference dataset\.In*Advances in Neural Information Processing Systems*, 2023\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2023/hash/4dbb61cb68671edc4ca3712d70083b9f\-Abstract\.html](https://proceedings.neurips.cc/paper_files/paper/2023/hash/4dbb61cb68671edc4ca3712d70083b9f-Abstract.html)\.
- Jiao et al\. \(2026\)Difan Jiao, Yilun Liu, Ye Yuan, Zhenwei Tang, Linfeng Du, Haolun Wu, and Ashton Anderson\.LLM safety from within: Detecting harmful content with internal representations\.In*Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\)*\. Association for Computational Linguistics, 2026\.URL[https://aclanthology\.org/2026\.acl\-long\.1844/](https://aclanthology.org/2026.acl-long.1844/)\.
- Kavumba et al\. \(2026\)Pride Kavumba, Koki Wataoka, Huy H\. Nguyen, Jiaxuan Li, and Masaya Ohagi\.Predict, don’t react: Value\-based safety forecasting for LLM streaming\.*arXiv preprint arXiv:2604\.03962*, 2026\.URL[https://arxiv\.org/abs/2604\.03962](https://arxiv.org/abs/2604.03962)\.
- Krishna et al\. \(2026\)Kundan Krishna, Joseph Y\. Cheng, Charles Maalouf, and Leon A\. Gatys\.Disentangled safety adapters enable efficient guardrails and flexible inference\-time alignment\.In*ICLR 2026 Workshop on Principled Design for Trustworthy AI, Interpretability, Robustness, and Safety across Modalities*, 2026\.URL[https://arxiv\.org/abs/2506\.00166](https://arxiv.org/abs/2506.00166)\.
- Laine & Aila \(2017\)Samuli Laine and Timo Aila\.Temporal ensembling for semi\-supervised learning\.In*International Conference on Learning Representations*, 2017\.URL[https://arxiv\.org/abs/1610\.02242](https://arxiv.org/abs/1610.02242)\.
- Li et al\. \(2025a\)Shen Li, Liuyi Yao, Lan Zhang, and Yaliang Li\.Safety layers in aligned large language models: The key to LLM security\.In*International Conference on Learning Representations*, 2025a\.URL[https://openreview\.net/forum?id=kUH1yPMAn7](https://openreview.net/forum?id=kUH1yPMAn7)\.
- Li et al\. \(2025b\)Xiaodan Li, Mengjie Wu, Yao Zhu, Yunna Lv, YueFeng Chen, Cen Chen, Jianmei Guo, and Hui Xue\.Kelp: A streaming safeguard for large models via latent dynamics\-guided risk detection\.*arXiv preprint arXiv:2510\.09694*, 2025b\.URL[https://arxiv\.org/abs/2510\.09694](https://arxiv.org/abs/2510.09694)\.
- Li et al\. \(2025c\)Yang Li, Qiang Sheng, Yehan Yang, Xueyao Zhang, and Juan Cao\.From judgment to interference: Early stopping LLM harmful outputs via streaming content monitoring\.In*Advances in Neural Information Processing Systems*, volume 38, pp\. 54305–54333, 2025c\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2025/hash/4e3157021c5f833bb2204081f1dda573\-Abstract\-Conference\.html](https://proceedings.neurips.cc/paper_files/paper/2025/hash/4e3157021c5f833bb2204081f1dda573-Abstract-Conference.html)\.
- Liu et al\. \(2026\)Cheng Liu, Xiaolei Liu, Xingyu Li, Bangzhou Xin, and Kangyi Ding\.TrajGuard: Streaming hidden\-state trajectory detection for decoding\-time jailbreak defense\.In*Findings of the Association for Computational Linguistics: ACL 2026*, pp\. 13371–13388\. Association for Computational Linguistics, 2026\.doi:10\.18653/v1/2026\.findings\-acl\.655\.URL[https://aclanthology\.org/2026\.findings\-acl\.655/](https://aclanthology.org/2026.findings-acl.655/)\.
- Mei et al\. \(2026\)Lingrui Mei, Shenghua Liu, Yiwei Wang, Baolong Bi, Ruibin Yuan, and Xueqi Cheng\.HiddenGuard: Fine\-grained safe generation with specialized representation router\.In*Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\)*, pp\. 32124–32156\. Association for Computational Linguistics, 2026\.doi:10\.18653/v1/2026\.acl\-long\.1482\.URL[https://aclanthology\.org/2026\.acl\-long\.1482/](https://aclanthology.org/2026.acl-long.1482/)\.
- Meta \(2025\)Meta\.Llama guard 4: Model card and prompt formats, 2025\.URL[https://dev\.meta\.ai/llama/docs/model\-cards\-and\-prompt\-formats/llama\-guard\-4](https://dev.meta.ai/llama/docs/model-cards-and-prompt-formats/llama-guard-4)\.
- Meyoyan & Del Corro \(2026\)Gonzalo Ariel Meyoyan and Luciano Del Corro\.A BERTology view of LLM orchestrations: Token\- and layer\-selective probes for efficient single\-pass classification\.In*Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\)*, pp\. 42226–42239\. Association for Computational Linguistics, 2026\.doi:10\.18653/v1/2026\.acl\-long\.1955\.URL[https://aclanthology\.org/2026\.acl\-long\.1955/](https://aclanthology.org/2026.acl-long.1955/)\.
- Raposo et al\. \(2024\)David Raposo, Sam Ritter, Blake Richards, Timothy Lillicrap, Peter Conway Humphreys, and Adam Santoro\.Mixture\-of\-depths: Dynamically allocating compute in transformer\-based language models\.*arXiv preprint arXiv:2404\.02258*, 2024\.URL[https://arxiv\.org/abs/2404\.02258](https://arxiv.org/abs/2404.02258)\.
- Rubanova et al\. \(2019\)Yulia Rubanova, Ricky T\. Q\. Chen, and David K\. Duvenaud\.Latent ordinary differential equations for irregularly\-sampled time series\.In*Advances in Neural Information Processing Systems*, volume 32, pp\. 5320–5330, 2019\.URL[https://proceedings\.neurips\.cc/paper/2019/hash/42a6845a557bef704ad8ac9cb4461d43\-Abstract\.html](https://proceedings.neurips.cc/paper/2019/hash/42a6845a557bef704ad8ac9cb4461d43-Abstract.html)\.
- Schuster et al\. \(2022\)Tal Schuster, Adam Fisch, Jai Gupta, Mostafa Dehghani, Dara Bahri, Vinh Q\. Tran, Yi Tay, and Donald Metzler\.Confident adaptive language modeling\.In*Advances in Neural Information Processing Systems*, 2022\.URL[https://arxiv\.org/abs/2207\.07061](https://arxiv.org/abs/2207.07061)\.
- Sharma et al\. \(2025\)Mrinank Sharma, Meg Tong, Jesse Mu, Jerry Wei, Jorrit Kruthoff, Scott Goodfriend, Euan Ong, Alwin Peng, Raj Agarwal, Cem Anil, et al\.Constitutional classifiers: Defending against universal jailbreaks across thousands of hours of red teaming\.*arXiv preprint arXiv:2501\.18837*, 2025\.URL[https://arxiv\.org/abs/2501\.18837](https://arxiv.org/abs/2501.18837)\.
- Vaswani et al\. \(2017\)Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N\. Gomez, Lukasz Kaiser, and Illia Polosukhin\.Attention is all you need\.In*Advances in Neural Information Processing Systems*, volume 30, pp\. 5998–6008, 2017\.URL[https://proceedings\.neurips\.cc/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa\-Abstract\.html](https://proceedings.neurips.cc/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html)\.
- Wang et al\. \(2021\)Xinshao Wang, Yang Hua, Elyor Kodirov, David A\. Clifton, and Neil M\. Robertson\.ProSelfLC: Progressive self label correction for training robust deep neural networks\.In*Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition*, pp\. 752–761, 2021\.doi:10\.1109/CVPR46437\.2021\.00081\.URL[https://openaccess\.thecvf\.com/content/CVPR2021/html/Wang\_ProSelfLC\_Progressive\_Self\_Label\_Correction\_for\_Training\_Robust\_Deep\_Neural\_CVPR\_2021\_paper\.html](https://openaccess.thecvf.com/content/CVPR2021/html/Wang_ProSelfLC_Progressive_Self_Label_Correction_for_Training_Robust_Deep_Neural_CVPR_2021_paper.html)\.
- Wang et al\. \(2025\)Xunguang Wang, Daoyuan Wu, Zhenlan Ji, Zongjie Li, Pingchuan Ma, Shuai Wang, Yingjiu Li, Yang Liu, Ning Liu, and Juergen Rahmel\.SelfDefend: LLMs can defend themselves against jailbreaking in a practical manner\.In*34th USENIX Security Symposium \(USENIX Security 25\)*, pp\. 2441–2460\. USENIX Association, 2025\.URL[https://www\.usenix\.org/conference/usenixsecurity25/presentation/wang\-xunguang](https://www.usenix.org/conference/usenixsecurity25/presentation/wang-xunguang)\.
- Xuan et al\. \(2025\)Zitao Xuan, Xiaofeng Mao, Da Chen, Xin Zhang, Yuhan Dong, and Jun Zhou\.ShieldHead: Decoding\-time safeguard for large language models\.In*Findings of the Association for Computational Linguistics: ACL 2025*, pp\. 18129–18143\. Association for Computational Linguistics, 2025\.doi:10\.18653/v1/2025\.findings\-acl\.932\.URL[https://aclanthology\.org/2025\.findings\-acl\.932/](https://aclanthology.org/2025.findings-acl.932/)\.
- Yang et al\. \(2025\)An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, Chujie Zheng, Dayiheng Liu, Fan Zhou, Fei Huang, Feng Hu, Hao Ge, Haoran Wei, Huan Lin, Jialong Tang, Jian Yang, et al\.Qwen3 technical report\.*arXiv preprint arXiv:2505\.09388*, 2025\.URL[https://arxiv\.org/abs/2505\.09388](https://arxiv.org/abs/2505.09388)\.
- Yu et al\. \(2026\)Jiaqi Yu, Xin Wang, Yixu Wang, Jie Li, Yan Teng, Xingjun Ma, and Yingchun Wang\.SentGuard: Sentence\-level streaming guardrails for large language models\.*arXiv preprint arXiv:2606\.02041*, 2026\.URL[https://arxiv\.org/abs/2606\.02041](https://arxiv.org/abs/2606.02041)\.
- Yuan et al\. \(2025\)Xiaohan Yuan, Jinfeng Li, Dongxia Wang, Yuefeng Chen, Xiaofeng Mao, Longtao Huang, Jialuo Chen, Hui Xue, Xiaoxia Liu, Wenhai Wang, Kui Ren, and Jingyi Wang\.S\-Eval: Towards automated and comprehensive safety evaluation for large language models\.*Proceedings of the ACM on Software Engineering*, 2\(ISSTA\):2136–2157, 2025\.doi:10\.1145/3728971\.URL[https://s\-eval\.github\.io/](https://s-eval.github.io/)\.
- Zhao et al\. \(2025a\)Haiquan Zhao, Chenhan Yuan, Fei Huang, Xiaomeng Hu, Yichang Zhang, An Yang, Bowen Yu, Dayiheng Liu, Jingren Zhou, Junyang Lin, et al\.Qwen3Guard technical report\.*arXiv preprint arXiv:2510\.14276*, 2025a\.URL[https://arxiv\.org/abs/2510\.14276](https://arxiv.org/abs/2510.14276)\.
- Zhao et al\. \(2025b\)Jiachen Zhao, Jing Huang, Zhengxuan Wu, David Bau, and Weiyan Shi\.LLMs encode harmfulness and refusal separately\.In*Advances in Neural Information Processing Systems*, 2025b\.URL[https://arxiv\.org/abs/2507\.11878](https://arxiv.org/abs/2507.11878)\.

## Appendix ABenchmarks and Datasets

### A\.1Dataset Descriptions

#### SGB\-S\-Eval\.

SGB\-S\-Eval is the S\-Eval\-derived benchmark in StreamGuardBench\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\)\. Its prompts originate from the English Base Risk Prompt Set of S\-Eval\([Yuan et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib39)\), which is constructed to cover a broad range of safety\-critical scenarios\. Following the StreamGuardBench construction protocol, responses are generated by Qwen3\-8B using deterministic decoding \(do\_sample=False\) with a maximum of 2,048 new tokens\. The benchmark contains 9,000 training examples and 1,000 test examples\. Response\-level safety labels are obtained through the evaluation procedure provided by the S\-Eval creators\. In our experiments, we use the complete released training and test splits of SGB\-S\-Eval\.

#### SGB\-WildGuard\.

SGB\-WildGuard is the WildGuard\-derived benchmark in StreamGuardBench\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\)\. Its prompts originate from WildGuard\([Han et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib13)\), which covers benign, harmful, and adversarial interactions and provides annotations for prompt harmfulness, response harmfulness, and refusal behavior\. StreamGuardBench regenerates responses to these prompts using Qwen3\-8B with deterministic decoding and a maximum of 2,048 new tokens, rather than reusing the original WildGuard responses\. The regenerated responses are then annotated for response safety using Kimi\-K2\. The benchmark contains 37,934 training examples and 1,725 test examples\. We use the complete released training and test splits of SGB\-WildGuard\.

#### AEGIS2\.0\.

AEGIS2\.0\([Ghosh et al\., 2025](https://arxiv.org/html/2610.36574#bib.bib9)\)is a content\-moderation benchmark designed to cover diverse benign, harmful, and adversarial human–LLM interactions\. Its safety taxonomy includes 12 core hazard categories together with additional fine\-grained risks, covering categories such as hate, sexual content, violence, self\-harm, privacy violations, illegal activity, malware, manipulation, and misinformation\. The original dataset contains both standalone prompts and prompt–response pairs, with response\-level safety judgments provided for moderation evaluation\. In our experiments, we use the released prompt–response training and test splits with valid response\-safety labels and formulate the task as binary response classification, where safe responses are labeled as00and unsafe responses as11\.

#### BeaverTails\.

BeaverTails\([Ji et al\., 2023](https://arxiv.org/html/2610.36574#bib.bib17)\)is a human\-annotated safety\-alignment dataset containing question–answer pairs with separate annotations for helpfulness and harmlessness\. We use the BeaverTails\-30k benchmark, which contains approximately 30K question–answer pairs and covers 14 categories of potentially harmful content\. Each response is associated with a binary safety meta\-label indicating whether it is safe or unsafe, while the original dataset additionally provides preference information for alignment research\. In our experiments, we use the complete released training and test splits after label filtering and retain the binary safety meta\-label as the response\-level supervision signal\.

#### WildGuard\.

WildGuard\([Han et al\., 2024](https://arxiv.org/html/2610.36574#bib.bib13)\)is a safety\-moderation benchmark covering three complementary tasks: harmful\-prompt detection, harmful\-response detection, and refusal detection\. It contains benign, harmful, and adversarial interactions spanning a broad range of safety categories, with human annotations for both prompt and response behavior\. In contrast to SGB\-WildGuard, which regenerates responses to WildGuard prompts using Qwen3\-8B, this setting directly uses the original released WildGuard responses and their response\-harmfulness annotations\. We use the complete released training split and the test split with valid response\-safety labels\. After excluding the 16 test examples without valid response\-safety annotations, 1,709 test examples remain\. Across training and evaluation, safe responses are mapped to00and unsafe responses to11\.

### A\.2Data Statistics and Splits

Table[5](https://arxiv.org/html/2610.36574#A1.T5)summarizes the dataset sizes and class distributions after dataset\-level label filtering\. The train–test partitions are fixed across backbone settings\.

Table 5:Dataset statistics after dataset\-level label filtering\. Safe and unsafe counts are reported separately for the training and test splits\.For Public WildGuard, we exclude 16 test examples without valid response\-safety labels, leaving 1,709 test examples\. The counts in Table[5](https://arxiv.org/html/2610.36574#A1.T5)describe the datasets before method\-specific tokenization\.

## Appendix BImplementation Details

This section supplements Section[4\.1](https://arxiv.org/html/2610.36574#S4.SS1)with implementation settings and protocol exceptions for the results in Tables[1](https://arxiv.org/html/2610.36574#S4.T1)and[2](https://arxiv.org/html/2610.36574#S4.T2)\.

### B\.1ADTGuard Configuration

Table[6](https://arxiv.org/html/2610.36574#A2.T6)lists the remaining architecture and training parameters\. The routing budget, refinement schedule, and default optimization setup follow the main text\.

Table 6:Additional ADTGuard implementation parameters\.
### B\.2Baseline Implementations

We adapt the four dedicated moderation models to each benchmark using LoRA on the corresponding training data\. The adapters target the attention query, key, and value projections, with rank88, scaling factor1616, and zero dropout, while the pretrained parameters remain frozen\. Table[7](https://arxiv.org/html/2610.36574#A2.T7)summarizes the training configurations\. The dedicated moderation models and Kelp use random seed4242and the final training checkpoint\. SIREN follows the multistage training and selection procedure described below\.

Table 7:Training configurations of the baseline methods\. For SIREN, paired values denote the linear\-probe and MLP stages, respectively\.ParameterQwen3Guard\-Gen\-8BQwen3Guard\-Stream\-8BLlama\-Guard\-4\-12BSentGuard\-4BKelpSIREN\(in\-domain\)SIREN\(official\-data\)OptimizerAdamWAdamWAdamWAdamWAdamWAdamAdamLearning rate5×10−55\\times 10^\{\-5\}5×10−55\\times 10^\{\-5\}5×10−55\\times 10^\{\-5\}5×10−55\\times 10^\{\-5\}5×10−55\\times 10^\{\-5\}0\.010\.01/ tuned0\.010\.01/ tunedGlobal batch size3232323232256 / 8,192256 / 8,192Micro\-batch size per GPU11111256 / 8,192256 / 8,192Accumulation steps per GPU32323232811Warmup ratio00000\.0500Weight decay00000\.100/10−410^\{\-4\}00/10−410^\{\-4\}Learning\-rate scheduleConstantConstantConstantConstantCosineConstantConstantMaximum input length4,0964,0964,0964,096Full input512512Epochs11111Multi\-stageMulti\-stage

SIREN batch sizes refer to training on extracted features\. Its MLP learning rate is searched over\[10−4,5×10−3\]\[10^\{\-4\},5\\times 10^\{\-3\}\], with the training stages described below\. Kelp uses four workers, giving a global batch size of4×1×8=324\\times 1\\times 8=32; the final incomplete accumulation group does not produce an optimizer update\. Its runner processes full formatted inputs within the backbone’s context limit, without a fixed4,0964\{,\}096\-token truncation\.

#### Qwen3Guard\-Gen\-8B\.

Qwen3Guard\-Gen\-8B\([Zhao et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib40)\)is fine\-tuned using its native moderation template for prompt–response pairs\. Response\-level labels are converted into the target verdictsSafety: SafeandSafety: Unsafe, with the language\-modeling loss applied to the target verdict sequence\. At evaluation time, the generated verdict is parsed to obtain the safety prediction\.

#### Qwen3Guard\-Stream\-8B\.

Qwen3Guard\-Stream\-8B\([Zhao et al\., 2025a](https://arxiv.org/html/2610.36574#bib.bib40)\)retains its pretrained three\-class risk head during adaptation\. We freeze this head and update the attention adapters using cross\-entropy supervision at the final assistant\-turn position\. Training uses the benchmark’s Safe or Unsafe response label\. During evaluation, bothUnsafeandControversialpredictions trigger an alarm\.

#### Llama\-Guard\-4\-12B\.

Llama\-Guard\-4\-12B is fine\-tuned on text\-only prompt–response pairs using its native moderation template\. LoRA adapters are restricted to the language\-model attention modules, while the vision encoder and pretrained language\-model parameters remain frozen\. The model learns to generatesafeorunsafe, and the generated verdict is used as the response\-level prediction\.

#### SentGuard\-4B\.

SentGuard\-4B\([Yu et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib38)\)is adapted using an instruction that asks the model to assess the agent response\. Binary labels are represented as<answer\>safe</answer\>or<answer\>unsafe</answer\>, without additional evidence or category annotations\. We use this benchmark\-specific LoRA adaptation of the released checkpoint for comparison\. Streaming evaluation checks cumulative prefixes every ten response tokens on SGB and uses the native response\-only instruction with cumulative sentence prefixes on the public datasets\.

#### Kelp\.

We build on Kelp’s released detection head and temporal regularization loss\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\), with adapters for the evaluated backbones and datasets\. A separate detection head is trained for each backbone–benchmark pair while the backbone remains frozen\. The reported runs extracthidden\_statesentries3232,3232, and2525for Qwen3\-8B, Llama\-3\.1\-8B, and Gemma\-7B, respectively\. Projection and memory dimensions are both1,0241\{,\}024\. The total\-variation and monotonicity regularization coefficients are both0\.010\.01\.

Inputs use backbone\-specific conversation formatting, including an explicit turn\-format adapter for Gemma\-7B Base\. Feature extraction retains the assistant trajectory and its special\-token suffix while removing the final encoded input token\. Training combines classification supervision near the beginning and end of the trajectory with temporal regularization\. The input adapters also handle token boundaries and short nonempty responses\.

#### SIREN \(in\-domain\)\.

We adapt SIREN’s released representation\-probing, neuron\-selection, and MLP components\([Jiao et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib18)\)to train an independent detector for each backbone–benchmark pair\. Inputs concatenate the prompt, a newline, and the response, with a maximum length of512512tokens\. The backbone remains frozen, and BF16 forward passes provide mean\-pooled residual representations from all Transformer layers, usingresidual\_mean\. Preprocessing uses a validation ratio of0\.20\.2for SGB\-S\-Eval, SGB\-WildGuard, BeaverTails\-30K, and Public WildGuard\. AEGIS2\.0 uses its existing training and validation splits, retaining examples with valid response labels and nonempty responses; the additional refusal\-training file is not included\.

Layerwise L1\-regularized probes are fitted using binary cross\-entropy, with regularization selected by validation macro\-F1\. Candidate probes are trained for up to100100epochs, followed by refitting for up to500500epochs, with validation\-based early stopping\. Probe training uses seed4242\. Neurons are ranked by absolute probe weights and retained until their cumulative importance reaches90%90\\%\. Layer weights are derived from min–max normalized validation scores with a lower bound of0\.10\.1\. The selected neuron features are weighted and concatenated across layers to form the MLP input\.

#### SIREN \(official\-data\)\.

The official\-data variant uses the same detector construction and training components but fits one detector per backbone on SIREN’s seven\-source data pool: ToxicChat, OpenAI Moderation, AEGIS1\.0, AEGIS2\.0, WildGuard, SafeRLHF, and BeaverTails\-30K\. We retain the source\-specific input construction and label definitions, including prompt\-level labels for AEGIS2\.0 and WildGuard and response\-level labels for SafeRLHF and BeaverTails\. Each fitted detector is evaluated on all five benchmarks without benchmark\-specific retraining\. The*official\-data*designation refers to this training\-data recipe; the detectors are fitted on our backbones rather than loaded as unmodified released classifiers\.

For both variants, neuron selection and layer weights are fixed before MLP hyperparameter search\. We conduct3232Optuna TPE trials with five\-fold cross\-validation on the combined training and validation features, using seed4242for the sampler and fold assignment\. Selection uses validation macro\-F1, averaged across data sources and cross\-validation folds\. The search includes two or three hidden layers, their widths, dropout in\[0\.2,0\.5\]\[0\.2,0\.5\], and a logarithmically sampled learning rate in\[10−4,5×10−3\]\[10^\{\-4\},5\\times 10^\{\-3\}\]\. Each fold is trained for up to100100epochs with early stopping\. The selected MLP is then fitted to the combined training and validation features for512512epochs, and its final checkpoint is used for evaluation\.

Both SIREN variants reuse the fitted neuron selection, layer weights, and MLP during cumulative\-prefix evaluation, following Section[B\.3](https://arxiv.org/html/2610.36574#A2.SS3)\. This evaluation adapts SIREN’s sequence\-level representation to response prefixes without retraining the detector\. For AEGIS2\.0, the response\-data adapter excludes empty responses, leaving813813test examples for both variants\.

### B\.3Evaluation Protocols

#### Baseline decision positions and thresholds\.

Following the original Kelp evaluation protocol\([Li et al\., 2025b](https://arxiv.org/html/2610.36574#bib.bib23)\), Response F1 is determined by the prediction at the final response token, whereas Streaming F1 follows a token\-triggered rule: a response is classified as unsafe if any response token is predicted as unsafe\. ADTGuard adopts the same Response and Streaming evaluation criteria, enabling direct comparison under a unified scoring protocol\.

SIREN\([Jiao et al\., 2026](https://arxiv.org/html/2610.36574#bib.bib18)\)is originally a sequence\-level classifier based on mean\-pooled residual representations rather than a native token\-wise streaming detector\. We therefore preserve its trained probe\-derived neuron selection, fitted layer weights, and final MLP, and adapt only the evaluation procedure to cumulative response prefixes\. Inputs are formatted as the prompt followed by a newline and the response and are truncated to a maximum sequence length of512512\. Consistent with our reproduced SIREN pipeline, each layer is represented byresidual\_mean, i\.e\., the mean residual representation over all valid non\-padding tokens\.

For Streaming evaluation, a single causal backbone pass provides the token\-level residual states\. For each successive response prefix, we compute the cumulative mean representation over the prompt and retained response\-prefix tokens, extract the neurons selected during SIREN training, apply the fitted layer weights, concatenate the resulting features, and evaluate the trained MLP\. This preserves SIREN’s original mean\-pooling representation rather than replacing it with individual\-token features\. The unsafe decision threshold is strictly greater than0\.50\.5\. Response F1 uses the prediction at the final effective response prefix, whereas Streaming F1 treats a response as unsafe if any evaluated prefix exceeds the threshold\. This prefix\-based streaming protocol is an evaluation adapter for SIREN and is not part of the original SIREN evaluation procedure\. The same protocol is applied to both the in\-domain and official\-data variants across all three backbones\.

The dedicated guards use the check schedules reported in Table[2](https://arxiv.org/html/2610.36574#S4.T2)\. On SGB, the evaluation adapter checks cumulative prefixes every ten response tokens and also evaluates the final incomplete interval\. On the public datasets, Qwen3Guard\-Stream processes response\-content tokens through its native streaming interface; bothUnsafeandControversialpredictions trigger an alarm\. SentGuard evaluates cumulative sentence prefixes using its native response\-only instruction, and its parser treatsunsafe,uncertain, and invalid outputs as alarms\. Public\-dataset Response evaluation uses a4,0964\{,\}096\-token input budget with response\-prioritized truncation\. For Streaming evaluation, Qwen3Guard\-Stream uses an8,1928\{,\}192\-token context window, while SentGuard uses a261,632261\{,\}632\-token input budget and reserves an additional512512tokens for its generated verdict\. The native runners raise an error on context overflow rather than silently truncating the input\.

#### Offline evaluation and online intervention\.

The Streaming F1 reported in our experiments is computed by replaying stored benchmark responses and evaluating ADTGuard sequentially over their response tokens\. This provides a standardized offline protocol for measuring whether risk is detected at any point during a response\.

In deployment, ADTGuard operates in an online generate–check–release manner\. Each newly generated token is withheld until its risk is evaluated and is released only if the safety check passes\. Once an alarm is triggered, the current token is withheld and generation is terminated, ensuring that the triggering token is not exposed to the user\.

Streaming F1 therefore measures whether unsafe risk is detected during a response, but does not reflect how early the intervention occurs\. Two responses may both be counted as successfully detected even if their first alarms occur at substantially different positions\.

## Appendix CVisualization Analysis

We visualize the Qwen3\-8B / SGB\-S\-Eval run withK=4K=4, seed4242, and the no\-terminal\-EOS supervision protocol used in the controlled ablations\. The training logger tracks the first256256training examples \(165165safe and9191unsafe\) across all five epochs\. Routing and target panels use these recorded training forwards, including training\-time dropout and parameter updates between examples\. Only the held\-out cases use the frozen fifth\-epoch checkpoint\.

### C\.1Layer Routing

Figure[2](https://arxiv.org/html/2610.36574#A3.F2)\(a\) summarizes the fifth\-epoch routing traces\. We partition each response into2020equal progress intervals, calculate the fraction of positions selecting each layer within an interval, and then average across responses within each class\. Thus, responses receive equal weight regardless of length, and each heatmap column sums toK=4K=4\. Both classes use the same color scale\.

Layers2020–2222account for73\.45%73\.45\\%of selected readout slots under response\-equal weighting, while the remaining choices are more distributed\. The selected set changes between adjacent positions at an average rate of51\.26%51\.26\\%for safe responses and40\.51%40\.51\\%for unsafe responses\. The illustrated unsafe example further exhibits1818distinct Top\-44layer combinations over376376response tokens\. These observations reveal a concentrated but dynamic routing pattern: CDR develops persistent preferences for a small set of model depths while continuing to adjust the exact observation set as the response evolves\.

Importantly, the routing policy does not collapse to a single layer or a fixed Top\-KKsubset in the recorded run\. Compared with a fixed\-layer readout, CDR can retain frequently selected layers that provide useful safety evidence while replacing part of the observation set according to the evolving response prefix\. This behavior supports the motivation of adaptive depth routing: safety information can be concentrated around several informative depths without requiring the detector to rely on the same internal observation pattern throughout generation\. These training\-mode diagnostics nevertheless reflect both learned routing behavior and training\-time stochasticity, and therefore do not isolate the individual effects of prefix content, dropout, or parameter updates\.

![Refer to caption](https://arxiv.org/html/2610.36574v1/fig_c1_layer_routing.png)Figure 2:Recorded layer routing and aligned risk\.\(a\) Response\-equal selection frequencies over the256256logged training examples at epoch55\. Colors represent selection frequency, not risk or attribution strength\. \(b\) Binary top\-44selections for unsafe training sample \#175, with376376valid response positions and1818distinct selected sets\. \(c\) The risk recorded in the same forward pass; the red line marks the first crossing of the0\.50\.5threshold at token174174\. Layer and token positions are one\-based\. The example is the lower\-median\-length member of the1616logged unsafe responses with128128–512512tokens and epoch\-55RTR targets\. No ground\-truth harmful\-onset boundary is available\.
### C\.2Target Refinement

Figure[3](https://arxiv.org/html/2610.36574#A3.F3)\(a–b\) follows the same training example across epochs\. The mean target over its opening quarter changes from1\.0001\.000to0\.5650\.565,0\.4080\.408,0\.1400\.140, and0\.0640\.064\. The figure displays the stored targets directly, together with the preceding\-epoch cache and the current training\-forward prediction\. All825825logged safe\-example trajectories \(165165examples across five epochs\) retain zero targets\.

This evolution illustrates the central effect of RTR\. At the beginning of training, harmful responses inherit coarse response\-level supervision, assigning uniformly high risk targets to all response positions\. As training proceeds, RTR progressively incorporates the preceding\-epoch risk trajectory, reducing supervision on prefixes that are consistently assigned lower risk while preserving stronger targets at positions where risk becomes more pronounced\. For example, the mean target over the opening quarter decreases from1\.0001\.000in the first epoch to0\.0640\.064in the fifth epoch\. Consequently, the model is no longer trained to treat every token in a harmful response as equally risky; instead, it gradually learns to distinguish lower\-risk prefixes from later regions with stronger risk evidence, producing a temporally structured risk trajectory\.

The resulting progression shows how RTR transforms a uniform response\-level label into increasingly differentiated token\-level supervision\. Rather than assuming a predefined harmful onset, the refinement is driven by the risk structure learned in preceding epochs\. This suggests that RTR can extract finer\-grained temporal risk structure from coarse response\-level supervision without requiring explicit token\-level onset annotations\. The visualization should therefore be interpreted as evidence of progressively refined supervision and learned temporal differentiation, rather than recovery of an independently annotated harmful boundary\.

![Refer to caption](https://arxiv.org/html/2610.36574v1/fig_c2_target_refinement.png)Figure 3:RTR target evolution and recorded training predictions\.\(a\) Actual targets for training sample \#175 over all five epochs, usingβ=\(1,0\.5,0\.25,0,0\)\\beta=\(1,0\.5,0\.25,0,0\)\. \(b\) Its epoch\-44cached probabilities \(purple, dashed\), epoch\-55targets \(orange\-red, dash\-dotted\), and epoch\-55training\-forward predictions \(blue, solid\)\. The teacher is the stored training trajectory, not an epoch\-end recomputation\.
### C\.3Latency Evaluation

Experimental Setup\.We evaluate the inference overhead introduced by ADTGuard on Qwen3\-8B Base using the fixed fifth\-epoch guard checkpoint with routing budgetk=4k=4\. Measurements are collected on four independent NVIDIA A800 GPUs \(80 GB, PCIe\), each hosting a complete model instance\. Every request runs on a single GPU with batch size 1, and each base/ADTGuard matched pair is evaluated on the same GPU\. The backbone runs in BF16, while the guard parameters are stored in FP32 and evaluated under BF16 autocasting\. We use PyTorch 2\.10\.0\+cu128, Transformers 5\.5\.0, CUDA 12\.8, and scaled dot\-product attention, withouttorch\.compile, CUDA Graphs, or asynchronous overlap between the backbone and safeguard\.

The workload contains 20 benign prompts with controlled input lengths\. The two primary settings use 1,000 input tokens and either 512 or 1,024 output tokens, with five paired repetitions per prompt\. Three additional settings fix the output length at 1,024 tokens and vary the input length among 128, 512, and 2,048 tokens, with three paired repetitions per prompt\. This results in 380 matched pairs, or 760 timed requests\. Ten warm\-up requests are performed for each method, GPU, and length setting; all warm\-up and diagnostic runs are excluded from the reported results\.

Decoding is greedy with termination tokens suppressed\. ADTGuard checks every generated token at a risk threshold of0\.50\.5in*monitoring\-only*mode: all risk computations and threshold decisions remain active, but alarms do not terminate generation\. This keeps the generated token sequence identical within each matched pair and allows the measured difference to reflect monitoring overhead rather than differences in output length\.

Measurement Protocol\.Total request latency includes prompt processing, cache initialization, autoregressive decoding, hidden\-state extraction, safeguard computation, CPU readback of generated tokens and risk decisions, and synchronization after the final check\. The ADTGuard path includes the additional forward needed to evaluate the final generated token\. Model loading, tokenization, input preparation and transfer, file writing, and network communication are excluded\.

LetT¯base\\overline\{T\}\_\{\\mathrm\{base\}\}andT¯guard\\overline\{T\}\_\{\\mathrm\{guard\}\}denote the mean request latencies of the base and guarded systems, respectively, and letNNdenote the output length\. We report the amortized added latency

1000​\(T¯guard−T¯base\)Nms/token,\\frac\{1000\\left\(\\overline\{T\}\_\{\\mathrm\{guard\}\}\-\\overline\{T\}\_\{\\mathrm\{base\}\}\\right\)\}\{N\}\\quad\\text\{ms/token\},\(20\)together with the relative request\-level overhead

\(T¯guardT¯base−1\)×100%\.\\left\(\\frac\{\\overline\{T\}\_\{\\mathrm\{guard\}\}\}\{\\overline\{T\}\_\{\\mathrm\{base\}\}\}\-1\\right\)\\times 100\\%\.\(21\)These quantities measure the end\-to\-end request overhead introduced by streaming monitoring rather than the isolated execution time of the safeguard module\.

We additionally report first\-token time and time per output token \(TPOT\)\. For the base model, first\-token time ends when the first generated token reaches the host; for ADTGuard, it additionally includes completion of the first risk evaluation and threshold decision\. TPOT excludes the first token and is computed for each request as

TPOT=1000​T−tfirstN−1,\\mathrm\{TPOT\}=\\frac\{1000T\-t\_\{\\mathrm\{first\}\}\}\{N\-1\},\(22\)whereTTis the total request latency in seconds andtfirstt\_\{\\mathrm\{first\}\}is the first\-token time in milliseconds\. We report 95% confidence intervals using 10,000 paired bootstrap resamples over the 20 prompt clusters with seed 42, after averaging repeated measurements within each prompt\.

Results\.Table[8](https://arxiv.org/html/2610.36574#A3.T8)\(a\) shows that ADTGuard introduces a stable amortized monitoring cost across the evaluated sequence lengths\. With a 1,000\-token prompt, the added latency is 2\.3467 ms/token for 512 output tokens and 2\.3320 ms/token for 1,024 output tokens\. In the primary 1,000\-input/1,024\-output setting, the latter estimate has a 95% confidence interval of \[2\.3235, 2\.3410\] ms/token and increases total request time from 19\.3229 s to 21\.7108 s, corresponding to a 12\.36% overhead\.

At a fixed output length of 1,024 tokens, varying the prompt length from 128 to 2,048 tokens yields an added cost of 2\.3103–2\.3477 ms/token\. Thus, the approximately 2\.3 ms/token overhead remains consistent across substantially different input lengths rather than being specific to a single sequence configuration\.

Table[8](https://arxiv.org/html/2610.36574#A3.T8)\(b\) further reports the latency observed at token delivery\. In the primary 1,000\-input/1,024\-output setting, first\-token time increases from 103\.549 to 127\.183 ms, while TPOT increases from 18\.787 to 21\.098 ms\. All measurements retain token\-level monitoring at every decoding step, including the final\-token check\. Overall, these results show that ADTGuard supports per\-token streaming safety monitoring with an additional inference cost of approximately 2\.3 ms per generated token under the evaluated settings\.

Table 8:Model\-side latency of Qwen3\-8B Base with and without ADTGuard\.PPandNNdenote input and output token counts\. Measurements use batch size 1 with all token\-level checks enabled and early termination disabled\. Panel \(a\) reports total request latency and amortized overhead; panel \(b\) reports first\-token time and TPOT\. The first two rows are the primary settings with 100 matched pairs each, while the remaining rows vary the input length with 60 matched pairs each\. Confidence intervals are obtained by paired prompt\-cluster bootstrap\.\(a\) Total request latency and amortized overhead

PPNNTotal latency \(s\)Added latency \(ms/token\)OverheadBase\+ADTGuardMean95% CI\(%\)1,0005129\.647310\.84882\.3467\[2\.3385, 2\.3556\]12\.451,0001,02419\.322921\.71082\.3320\[2\.3235, 2\.3410\]12\.361281,02418\.947821\.35192\.3477\[2\.3390, 2\.3571\]12\.695121,02419\.091721\.45752\.3103\[2\.3017, 2\.3191\]12\.392,0481,02419\.840822\.23092\.3340\[2\.3253, 2\.3434\]12\.05
\(b\) First\-token time and TPOT

Notes\.For ADTGuard, first\-token time includes completion of the first risk decision\. TPOT excludes the first token\. Added latency amortizes the full request\-time difference over all generated tokens and should not be interpreted as the isolated execution time of the safeguard\. All differences and ratios are computed from unrounded measurements\.

### C\.4Case Study

We examine two illustrative SGB\-S\-Eval test prompts using Qwen3\-8B Base and the frozen final \(fifth\-epoch\) ADTGuard checkpoint withK=4K=4\. We use greedy decoding, a 512\-token cap, natural termination, and a risk threshold of0\.50\.5\. Every response token is checked before release\. For each prompt, we separately run the unguarded model, full\-length monitoring, and actual intervention\. The first two produce identical token sequences; intervention reproduces the monitored prefix and its risk scores exactly\. The two examples are selected from six purposively chosen candidate prompts to illustrate successful behavior, rather than estimate its prevalence\.

Table 9:Observed outcomes for the selected cases\.Reference length and maximum risk come from monitoring without early termination; released length comes from the separate intervention run\. Termination tokens are excluded\.![Refer to caption](https://arxiv.org/html/2610.36574v1/fig_c3_case_study_benign.png)Figure 4:Token\-level monitoring preserves benign discussion\.Each cell is one actual Qwen3 tokenizer token, colored directly by ADTGuard’s risk score for the prefix ending at that position\. Tokens11–159159are shown; the complete424424\-token response is released, with maximum risk0\.00360\.0036\. Spaces are hidden; a return\-arrow marker denotes one or more newlines within a token\. Row labels indicate token positions\.#### Preserving benign discussion despite sensitive vocabulary\.

The first query asks about online violence\. The model provides a substantive explanation involving anonymity, social reinforcement, and accountability, including phrases such as*aggressive and violent behavior*and*violent rhetoric*\. ADTGuard assigns low risk throughout: the maximum score is0\.00360\.0036, and all424424tokens are released unchanged \(Figure[4](https://arxiv.org/html/2610.36574#A3.F4)\)\. This example illustrates preservation of a useful discussion of a sensitive topic without an unnecessary interruption\.

![Refer to caption](https://arxiv.org/html/2610.36574v1/fig_c4_case_study_risky.png)Figure 5:Token\-level intervention on euphemistic ridicule\.All236236reference tokens are shown, each with its own recorded prefix\-risk score\. Actual intervention releases tokens11–104104and withholds token105105at the first alarm\. The dashed panel is an unreleased monitoring reference\. The enlarged boundary shows individual scores around the decision; token105105is a Markdown delimiter, not an annotated harmful onset\. The first four suggestions were already released\.
#### Interrupting ridicule wrapped in benign\-sounding language\.

The second query requests euphemistic ridicule of someone’s weight\. The model frames its suggestions as*humorous and light\-hearted*, yet proceeds to supply personalized taunts\. The risk score increases as these suggestions accumulate, first exceeding0\.50\.5at token105105\. Actual intervention withholds that token and releases only the preceding104104tokens\. The remaining132132tokens of the236236\-token reference response, including six further suggestions and the closing reassurance, are not released\. In the monitoring\-only reference, risk eventually reaches0\.96510\.9651, even as the answer describes the ridicule as*without being offensive*\(Figure[5](https://arxiv.org/html/2610.36574#A3.F5)\)\. This case illustrates interruption of further unsafe output despite reassuring surface wording\. The first four suggestions have already been released, so the result demonstrates curtailed continuation, not zero harmful exposure or identification of an annotated harmful onset\.

## Appendix DTheoretical Proof

This appendix provides the theoretical justification for the target interpolation used in Risk\-Onset Target Refinement \(RTR\)\. We show that, for a fixed model\-derived onset profile, the refined target is exactly the minimizer of a weighted forward\-KL objective combining the original response\-level label with the model\-derived token\-level supervision\.

### D\.1Proof of the Forward\-KL Characterization

Letyi∈\{0,1\}y\_\{i\}\\in\\\{0,1\\\}denote the response\-level label of sampleii, and letci,t\(e−1\)∈\[0,1\]c\_\{i,t\}^\{\(e\-1\)\}\\in\[0,1\]denote the model\-derived onset profile at positiontt, constructed from the detached risk trajectory cached during epoche−1e\-1\. During epochee, this profile is treated as fixed supervision\. For benign responses, we setci,t\(e−1\)=0c\_\{i,t\}^\{\(e\-1\)\}=0, consistent with the fixed zero target used by RTR\.

To simplify notation, let

y=yi,c=ci,t\(e−1\),β=βe\.y=y\_\{i\},\\qquad c=c\_\{i,t\}^\{\(e\-1\)\},\\qquad\\beta=\\beta\_\{e\}\.\(23\)
For a Bernoulli candidate targetq∈\(0,1\)q\\in\(0,1\), consider the weighted forward\-KL objective

𝒥\(q\)=βDKL\(Ber\(y\)∥Ber\(q\)\)\+\(1−β\)DKL\(Ber\(c\)∥Ber\(q\)\)\.\\mathcal\{J\}\(q\)=\\beta D\_\{\\mathrm\{KL\}\}\\\!\\left\(\\operatorname\{Ber\}\(y\)\\,\\\|\\,\\operatorname\{Ber\}\(q\)\\right\)\+\(1\-\\beta\)D\_\{\\mathrm\{KL\}\}\\\!\\left\(\\operatorname\{Ber\}\(c\)\\,\\\|\\,\\operatorname\{Ber\}\(q\)\\right\)\.\(24\)
For Bernoulli parametersaaandqq,

DKL\(Ber\(a\)∥Ber\(q\)\)=alogaq\+\(1−a\)log1−a1−q\.D\_\{\\mathrm\{KL\}\}\\\!\\left\(\\operatorname\{Ber\}\(a\)\\,\\\|\\,\\operatorname\{Ber\}\(q\)\\right\)=a\\log\\frac\{a\}\{q\}\+\(1\-a\)\\log\\frac\{1\-a\}\{1\-q\}\.\(25\)
Substituting Eq\. \([25](https://arxiv.org/html/2610.36574#A4.E25)\) into Eq\. \([24](https://arxiv.org/html/2610.36574#A4.E24)\) yields

𝒥⁡\(q\)\\displaystyle\\mathcal\{J\}\(q\)=−\[β​y\+\(1−β\)​c\]​log⁡q\\displaystyle=\-\\bigl\[\\beta y\+\(1\-\\beta\)c\\bigr\]\\log q−\[β⁡\(1−y\)\+\(1−β\)​\(1−c\)\]​log⁡\(1−q\)\+C,\\displaystyle\\quad\-\\bigl\[\\beta\(1\-y\)\+\(1\-\\beta\)\(1\-c\)\\bigr\]\\log\(1\-q\)\+C,\(26\)where

C\\displaystyle C=β⁡\[y​log⁡y\+\(1−y\)​log⁡\(1−y\)\]\\displaystyle=\\beta\\left\[y\\log y\+\(1\-y\)\\log\(1\-y\)\\right\]\+\(1−β\)​\[c​log⁡c\+\(1−c\)​log⁡\(1−c\)\]\\displaystyle\\quad\+\(1\-\\beta\)\\left\[c\\log c\+\(1\-c\)\\log\(1\-c\)\\right\]\(27\)is independent ofqq, using the convention0​log⁡0=00\\log 0=0\.

Define

α=β​y\+\(1−β\)​c\.\\alpha=\\beta y\+\(1\-\\beta\)c\.\(28\)Its complementary coefficient satisfies

1−α\\displaystyle 1\-\\alpha=1−β​y−\(1−β\)​c\\displaystyle=1\-\\beta y\-\(1\-\\beta\)c=β⁡\(1−y\)\+\(1−β\)​\(1−c\)\.\\displaystyle=\\beta\(1\-y\)\+\(1\-\\beta\)\(1\-c\)\.\(29\)
Therefore,

𝒥⁡\(q\)=−α​log⁡q−\(1−α\)​log⁡\(1−q\)\+C\.\\mathcal\{J\}\(q\)=\-\\alpha\\log q\-\(1\-\\alpha\)\\log\(1\-q\)\+C\.\(30\)
Up to the additive constantCC, this is exactly the binary cross\-entropy objective with soft targetα\\alpha\.

For0<α<10<\\alpha<1, differentiating with respect toqqgives

d​𝒥d​q\\displaystyle\\frac\{d\\mathcal\{J\}\}\{dq\}=−αq\+1−α1−q\\displaystyle=\-\\frac\{\\alpha\}\{q\}\+\\frac\{1\-\\alpha\}\{1\-q\}=q−αq⁡\(1−q\)\.\\displaystyle=\\frac\{q\-\\alpha\}\{q\(1\-q\)\}\.\(31\)
Sinceq⁡\(1−q\)\>0q\(1\-q\)\>0forq∈\(0,1\)q\\in\(0,1\), the unique stationary point satisfies

q⋆=α\.q^\{\\star\}=\\alpha\.\(32\)
Moreover,

d2​𝒥d​q2=αq2\+1−α\(1−q\)2\>0,\\frac\{d^\{2\}\\mathcal\{J\}\}\{dq^\{2\}\}=\\frac\{\\alpha\}\{q^\{2\}\}\+\\frac\{1\-\\alpha\}\{\(1\-q\)^\{2\}\}\>0,\(33\)so𝒥⁡\(q\)\\mathcal\{J\}\(q\)is strictly convex on the interior andq⋆=αq^\{\\star\}=\\alphais the unique minimizer for0<α<10<\\alpha<1\.

The boundary cases follow by continuous extension of the objective toq∈\[0,1\]q\\in\[0,1\]\. Whenα=0\\alpha=0, Eq\. \([30](https://arxiv.org/html/2610.36574#A4.E30)\) reduces, up toCC, to−log⁡\(1−q\)\-\\log\(1\-q\), whose unique minimum is attained atq=0q=0\. Whenα=1\\alpha=1, it reduces to−log⁡q\-\\log q, whose unique minimum is attained atq=1q=1\. Therefore, for ally∈\{0,1\}y\\in\\\{0,1\\\}andc,β∈\[0,1\]c,\\beta\\in\[0,1\],

q⋆=β​y\+\(1−β\)​c\.q^\{\\star\}=\\beta y\+\(1\-\\beta\)c\.\(34\)
Restoring the original notation gives

qi,t\(e\)=βe​yi\+\(1−βe\)​ci,t\(e−1\)\.q\_\{i,t\}^\{\(e\)\}=\\beta\_\{e\}y\_\{i\}\+\(1\-\\beta\_\{e\}\)c\_\{i,t\}^\{\(e\-1\)\}\.\(35\)
For harmful responses withyi=1y\_\{i\}=1,

qi,t\(e\)=βe\+\(1−βe\)​ci,t\(e−1\),q\_\{i,t\}^\{\(e\)\}=\\beta\_\{e\}\+\(1\-\\beta\_\{e\}\)c\_\{i,t\}^\{\(e\-1\)\},\(36\)which is exactly the progressive target\-refinement rule used by RTR\. For benign responses,yi=0y\_\{i\}=0andci,t\(e−1\)=0c\_\{i,t\}^\{\(e\-1\)\}=0, yielding

qi,t\(e\)=0\.q\_\{i,t\}^\{\(e\)\}=0\.\(37\)
Thus, RTR admits an exact forward\-KL characterization: conditioned on a fixed model\-derived onset profile, its refined target is the unique forward\-KL optimum between the original response\-level label and the historical token\-level supervision\. This result characterizes the RTR target construction itself and does not assume access to a ground\-truth token\-level harmful\-onset annotation\.

相似文章

自适应互蒸馏实现大语言模型的平衡多任务后训练

arXiv cs.CL

论文提出 Adaptive Mutual Distillation (AMD) 框架,通过两个采用不同任务平衡策略的模型进行协同蒸馏,并利用短训练探针和任务级验证分数自适应调整各任务与传输方向的蒸馏权重,在六个基准和三个 LLM 骨干上取得优于 SFT 与现有任务平衡方法的效果,合并后平均提升 2.91 分。