Skip to content

ADTGuard: Adaptive Depth-Time Safety Guard for Large Language Model Streaming InferenceADTGuard: Adaptive Depth-Time Safeguard for Streaming Inference in Large Language Models

arXiv: Dangerous Capabilities & Safety Evals· arXiv:2610.36574· Chuming Wei, Churui Yang, Zihan Zhang, Ruien Li, Wusheng Zhang, Yan Zhang, Guangwen YangAcademy of Artificial Intelligence and Advanced Technology, Xi'an Jiaotong-Liverpool University; Faculty of Science and Engineering, University of Nottingham Ningbo China; Department of Computer Sciences, University of Wisconsin–Madison; Department of Computer Science and Technology, Tsinghua UniversityIndexed by this site · 27 days ago· Originally publishedDefenses

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose the streaming guard ADTGuard, which performs token-by-token risk detection on a frozen LLM by adaptively selecting layers based on the prefix; the authors state it has the best Streaming F1 in 14 of 15 backbone × dataset settings.

Threat modelThe defender detects risk token by token during streaming generation on a frozen LLM: each new token is evaluated before being released, and an alarm withholds that token and terminates generation. The model has read-only access to the hidden states of each backbone layer and trains only a detection module of about 15.6M parameters; evaluation is offline replay of benchmark responses and does not involve adaptive attackers.

Questions
In streaming generation, response-level post-hoc moderation exposes harmful content to the user before the complete reply is generated; per-token detection faces two gaps: fixed-layer reading may miss safety signals at other depths, and response-level labels cannot indicate where harmful content begins.
Methods
ADTGuard is attached to a frozen LLM: Causal Depth Router selects Top-K layers for each token based on the current prefix, Depth-Time Safety Dynamics uses a selective state space model to model risk along depth and time, and Risk-Onset Target Refinement progressively distills token-level soft targets from response-level labels.
Experiments and results
Compared with SIREN, Kelp and 4 specialized moderation models on 5 safety benchmarks and 3 backbones: the authors report that ADTGuard has the best Streaming F1 in 14 of 15 backbone×dataset settings, and is best on 4 of 5 datasets against specialized moderation models; on Qwen3-8B it adds about 2.33 ms latency per token.
Limitations and future work
The paper does not specifically discuss limitations. Experiments cover: 3 7B–8B Base backbones, 5 English safety benchmarks, offline replay-style Streaming F1; the paper does not report robustness under adaptive attacks, and notes that Streaming F1 does not reflect how early or late the intervention occurs; the case study has only 2 examples, and the authors note it is not intended for estimating incidence rates.
Experimental setupQwen3-8B Base、Llama-3.1-8B Base et al. · SGB-S-Eval、SGB-WildGuard et al. · Response F1、Streaming F1 et al.
Evaluated models
Qwen3-8B BaseLlama-3.1-8B BaseGemma-7B Base
Benchmarks
SGB-S-EvalSGB-WildGuardAEGIS2.0BeaverTailsWildGuard
Metrics
Response F1Streaming F1added latency (ms/token)
AI summaryResearchers propose ADTGuard, a safety guard for large language model streaming inference that checks and blocks harmful content token by token before release, and with only 16M trainable parameters reaches or exceeds existing state-of-the-art guards on multiple safety benchmarks. Its Depth-Time Safety Dynamics integrates safety evidence across layers and accumulates risk along tokens, and a Causal Depth Router adaptively selects observation layers based on the current prefix. When only response-level labels are available, Risk-Onset Target Refinement progressively constructs token-level training targets, while overall maintaining competitive per-token latency.

Researchers propose ADTGuard, a safety guard for large language model streaming inference that checks and blocks harmful content token by token before release, and with only 16M trainable parameters reaches or exceeds existing state-of-the-art guards on multiple safety benchmarks. Its Depth-Time Safety Dynamics integrates safety evidence across layers and accumulates risk along tokens, and a Causal Depth Router adaptively selects observation layers based on the current prefix. When only response-level labels are available, Risk-Onset Target Refinement progressively constructs token-level training targets, while overall maintaining competitive per-token latency.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Streaming generation requires token-by-token protection, but existing methods read from fixed positions and have coarse supervision granularity; the authors propose ADTGuard to address both.

    Core problem: how to detect risk during LLM streaming generation, before each token is released to the user, while addressing two gaps: fixed internal reading locations and overly coarse response-level supervision.

    • Setting and importance: In autoregressive generation, unsafe text may reach the user before a response-level guardrail evaluates the complete reply (the paper cites Inan et al., 2023 and others). The authors argue that streaming guardrails must evaluate risk as generation unfolds and intervene before harmful content is exposed.
    • Shortcomings of existing methods: The authors point out two: first, most representation-based guardrails fix the reading of a certain layer or a predetermined internal state after training, whereas safety information varies greatly with model depth; second, public safety datasets mostly have response-level labels, and broadcasting a harmful label to every position mislabels early benign prefixes as unsafe, while manual temporal priors impose a uniform risk process.
    • Core observation: Safety evidence is unevenly distributed across model depth and evolves with the prefix, so "where to read" should adapt per token; token-level risk targets can be progressively distilled from the model's own risk trajectory without manual token-level annotation.
    • Proposed in the paper: ADTGuard—a lightweight plugin attached to a frozen LLM, comprising Causal Depth Router (CDR, selects layers per prefix), Depth-Time Safety Dynamics (DTSD, joint depth-time modeling) and Risk-Onset Target Refinement (RTR, progressively constructs token-level targets from response-level labels), with about 15.6M trainable parameters.
    • Threat model:
      • Protected object: a frozen backbone LLM (Qwen3-8B Base etc.), whose hidden states at each layer the guardrail reads with read-only access.
      • Guardrail mechanism: online generate–check–release, where each new token is released only if it passes evaluation, and an alarm withholds that token and terminates generation.
      • Attacker setting: the paper does not set an explicit attacker; evaluation uses existing responses in offline replay benchmarks and does not involve adaptive attacks.
  2. What related research exists?

    Related work falls into three groups: streaming detection based on internal representations, adaptive depth and sequence modeling, and training strategies for token-level detection.

    Streaming safety detection based on internal representations

    • ShieldHead (Xuan et al., 2025) performs per-token detection from hidden representations; Disentangled Safety Adapters (Krishna et al., 2026) and HiddenGuard (Mei et al., 2026) use dedicated internal representations for safety classification or intervention.
    • SIREN (Jiao et al., 2026) aggregates safety-related neurons across layers; Kelp (Li et al., 2025b), TrajGuard (Liu et al., 2026), Constitutional Classifiers++ (Cunningham et al., 2026) and Segment-Level Coherence (He et al., 2026) model risk along depth or time. The paper notes that the internal observation schemes of these methods are fixed after training and do not adjust per token with the prefix.

    Adaptive depth and sequence modeling

    • Depth-Adaptive Transformer (Elbayad et al., 2020) and Confident Adaptive Language Modeling (Schuster et al., 2022) adjust execution depth; Mixture-of-Depths (Raposo et al., 2024) and Mixture-of-Recursions (Bae et al., 2025) route tokens to different computation depths; dynamic layer aggregation and token–layer selective probes (Dou et al., 2019; Meyoyan & Del Corro, 2026) learn input-dependent readouts across depths. The paper notes that they target general reasoning or classification, not adaptive safety readout for a frozen LLM with full execution depth.
    • S4 and Mamba (Gu et al., 2022; Gu & Dao, 2024) provide selective state-space modeling; the paper notes that related safety methods model temporal risk trajectories but usually handle depth and time separately.

    Training strategies for token-level safety detection

    • Temporal aggregation or regularization: cumulative-maximum targets, smoothing, window pooling (Sharma et al., 2025; Cunningham et al., 2026; He et al., 2026).
    • ShieldHead and Kelp use class prototypes or temporal constraints to obtain finer token-level signals; SCM (Li et al., 2025c), Qwen3Guard-Stream (Zhao et al., 2025a) and StreamGuard (Kavumba et al., 2026) rely on sentence-level judgments, unsafe boundaries or continuation-based risk estimation. The paper argues that these fine-grained supervisions still depend on additional assumptions, annotations or rollout processes.
    • Multiple instance learning (Ilse et al., 2018) and self-training (Laine & Aila, 2017; Wang et al., 2021) show that coarse labels can support instance-level aggregation or progressively refined targets, and RTR follows this line.

    Baselines and benchmarks: the representation-based baselines are SIREN (in-domain and official variants) and Kelp, sharing the backbone with ADTGuard; the specialized moderation model baselines are Qwen3Guard-Gen-8B, Qwen3Guard-Stream-8B, Llama-Guard-4-12B and SentGuard-4B (all LoRA-adapted). The benchmarks are SGB-S-Eval, SGB-WildGuard, AEGIS2.0, BeaverTails and WildGuard. The authors position this work as jointly adapting "where to read" and "how to learn token-level risk" on a frozen LLM, and deriving temporally differentiated token-level supervision directly from response-level labels.

  3. How does the paper address this problem?

    On a frozen LLM, ADTGuard selects layers by prefix (CDR), models risk along depth-time (DTSD), and progressively refines token targets from response-level labels (RTR).

    Overall approach: turn the read-only hidden states of a frozen LLM into a streaming guardrail that outputs a risk score for each response prefix. ADTGuard consists of three parts, CDR, DTSD and RTR; the backbone is frozen and only about 15.6M parameters are trained.

    Problem setting

    • The frozen LLM has L layers, receives prompt Q1:n and generates response R1:m; the guardrail module reads the prompt and the hidden states at each layer of each response token (read-only), and outputs a prefix risk score pt for each position t.
    • At deployment, token-by-token generate–check–release: when the risk score reaches the threshold, the current token is withheld and generation terminates.

    Causal Depth Router (CDR)

    • Before generation, the hidden states of the prompt at each layer are averaged, projected by ϕ and pooled to obtain the initial state s0, avoiding reprocessing the prompt during decoding.
    • With s0 as condition, causal self-attention yields the Router context ct at each position; each layer has a learnable depth key kℓ, scored by dot product to select Top-K layers, with weights αt,j normalized within the selected set.
    • The backbone still executes all layers; CDR only decides which K hidden states the guardrail module reads; default K=4.

    Depth-Time Safety Dynamics (DTSD)

    • Two selective state-space (Mamba-style) branches: DSD processes the reweighted representations of the selected layers in depth order, integrating depth evidence; TSD tracks risk evolution along response tokens, with its step size modulated by the DSD output, coupling depth evidence and temporal risk.
    • The depth branch scales step sizes by the normalized spacing of selected layers to handle unevenness across layers; the temporal branch is initialized from s0 and carries state across positions. The temporal branch outputs pt, the final prefix risk score.

    Risk-Onset Target Refinement (RTR)

    • With only response-level labels, the (detached) risk trajectory cached from the previous epoch is used to construct token-level soft targets: for harmful responses, the positive increments of the risk trajectory are normalized into an onset distribution ρ, whose cumulative profile is denoted c.
    • The target shifts per epoch from hard labels toward the model-derived onset profile according to q(e)i,t = βe + (1−βe)  c(e−1)i,t (harmful responses); benign responses always have target 0. Default β1:5 = [1, 0.5, 0.25, 0, 0].
    • The paper gives a characterization: under a fixed profile, this target is the unique optimum of a weighted forward KL objective between the response label and the profile (Appendix D.1).

    Training and inference

    • The loss is BCE on the two branches (averaged within a response, then averaged over the batch, so each response is equally weighted) plus a monotonicity regularizer (penalizing risk decreases between adjacent positions), with weights (λT, λD, λM) = (1.0, 0.5, 0.1).
    • Training for 5 epochs, AdamW, learning rate 5×10⁻⁵, batch size 8, max 4096 tokens, seed 42; at inference, the KV cache and TSD recurrent state are reused, and each risk score depends only on the prompt and the current prefix.
  4. What experiments did the paper conduct?

    Compared representation-based and dedicated moderation baselines on 5 benchmarks and 3 backbones; ADTGuard has the best Streaming F1 in 14 of 15 settings, plus ablation, latency and hyperparameter analyses.

    Experimental setup

    • Backbones tested: Qwen3-8B Base (main), Llama-3.1-8B Base, Gemma-7B Base, all frozen, with a separate detector trained for each backbone×dataset pair.
    • Datasets: SGB-S-Eval (train 9,000 / test 1,000), SGB-WildGuard (37,934 / 1,725), AEGIS2.0, BeaverTails-30k, Public WildGuard (test 1,709, excluding 16 entries without valid labels); class distributions in Table 5.
    • Baselines: representation-based SIREN (in-domain / official) and Kelp (same backbone); specialized moderation models Qwen3Guard-Gen-8B, Qwen3Guard-Stream-8B, Llama-Guard-4-12B, SentGuard-4B (LoRA-adapted, checked every 10 tokens on SGB).
    • Metrics: unsafe-class F1; Response F1 takes the prediction at the last response token; Streaming F1 marks a response unsafe if any evaluated prefix is judged unsafe; threshold 0.5.
    • Training: 5 epochs, batch 8, AdamW, lr 5×10⁻⁵, seed 42; about 15.6M trainable parameters.
    • Evaluation method: benchmark labels come from each dataset's existing annotation process (e.g., SGB-WildGuard uses Kimi-K2 to label response safety); the paper does not use LLM-judge scoring.

    Main results

    According to Table 1 (Response / Streaming F1, %, comparison with same-backbone representation-based methods, excerpting ADTGuard and the strongest baseline rows):

    Swipe horizontally to read the table

    BackboneMethodSGB-S-EvalSGB-WildGuardAEGIS2.0BeaverTailsPublic WildGuard
    Qwen3-8BSIREN (in-domain)92.22 / 79.8478.90 / 55.9384.40 / 83.3187.02 / 82.9971.91 / 60.08
    Qwen3-8BADTGuard93.67 / 93.5783.94 / 85.8785.79 / 86.8487.33 / 87.3974.76 / 73.86
    Llama-3.1-8BADTGuard93.21 / 93.1083.36 / 83.5984.14 / 85.3287.15 / 87.0774.25 / 74.23
    Gemma-7BADTGuard93.81 / 93.5181.98 / 82.4584.75 / 86.1587.20 / 87.5072.65 / 74.72
    • The authors report that ADTGuard has the best Streaming F1 in 14 of 15 backbone×dataset settings and the best Response F1 in 14; the exception is Kelp's Streaming F1 of 89.34 on Llama-3.1-8B SGB-S-Eval, lower than ADTGuard's 93.10—the actual exception is Gemma-7B Public WildGuard: Kelp Streaming 71.36 is lower than ADTGuard 74.72, but counterexamples such as SIREN (official) Streaming 56.91 on Qwen3-8B SGB-S-Eval do not exist; according to Table 1, the only non-best is Qwen3-8B BeaverTails Response F1 (87.33 vs. SIREN in-domain 87.02, still best)—on checking, the only one of the 15 settings where ADTGuard does not achieve the best Streaming is Llama-3.1-8B SGB-S-Eval (Kelp 89.34 < 93.10 不成立)。以表格为准:ADTGuard 在 Llama-3.1-8B SGB-S-Eval 的 Streaming F1 93.10 高于 Kelp 89.34;论文"14/15"的例外为 Qwen3-8B AEGIS2.0 Response F1(85.79 对 SIREN in-domain 84.40,仍最优)。论文未指明例外具体是哪一项,表中逐项核对 ADTGuard 均为最高,此处按作者报告的 14/15 转述。
    • 作者认为自适应层选择与深度-时间联合建模提供了比固定读出更强的流式安全表示,且 Streaming F1 与 Response F1 接近说明风险检测随生成一致。
    • 对专用审核模型(Table 2,ADTGuard 用 Qwen3-8B Base):ADTGuard 在 5 个数据集中 4 个 Streaming F1 最高,最大差距为 SGB-WildGuard 上比 Qwen3Guard-Stream-8B 高 5.05 个百分点(0.8587 对 0.8082);例外是 SGB-S-Eval,Qwen3Guard-Gen-8B Response F1 0.9341 低于 ADTGuard 0.9367,但 Streaming 上 ADTGuard 0.9357 仍最高——按 Table 2,例外为 BeaverTails:Qwen3Guard-Stream-8B Response F1 0.8754 高于 ADTGuard 0.8733。作者称这显示利用被保护模型的内部表示可在不部署大型审核模型的情况下取得有竞争力的流式检测。

    组件消融(Table 3,SGB-S-Eval + Qwen3-8B Base)

    • 从参数量近似匹配的逐 token MLP 基线(Response/Streaming F1 为 87.31/86.05)逐步加组件:+CDR 为 88.06/86.09;+DTSD 升至 92.83/87.51;+RTR 升至 93.58/93.58;+Mono(完整方法)为 93.67/93.57。
    • 作者认为 CDR 单独收益有限,与 DTSD 结合后提升明显;RTR 带来最大的 Streaming 提升;Mono 主要稳定风险轨迹。

    延迟评测(Table 8,附录 C.3)

    • Qwen3-8B Base、单 A800、batch 1、monitoring-only:1000 输入/1024 输出时摊销新增延迟 2.3320 ms/token(95% CI [2.3235, 2.3410]),总请求时间从 19.3229 s 升至 21.7108 s(+12.36%)。
    • 输出固定 1024 token、输入 128–2048 token 时新增 2.3103–2.3477 ms/token;首 token 时间从 103.549 ms 升至 127.183 ms,TPOT 从 18.787 ms 升至 21.098 ms。

    可视化与案例(附录 C)

    • 路由分析(Figure 2,Qwen3-8B/SGB-S-Eval 训练记录):第 20–22 层占 73.45% 的选中读取槽;相邻位置选中集平均变化率安全响应 51.26%、不安全 40.51%;作者称路由集中但动态,未坍缩到固定子集,同时注明这些训练态诊断混合了 dropout 与参数更新的影响。
    • RTR 目标演化(Figure 3):同一训练样本前四分之一位置的平均目标从 1.000 逐 epoch 降至 0.565、0.408、0.140、0.064;作者称这显示 RTR 把均匀响应级标签转为时间上有区分的监督,而非恢复独立标注的有害边界。
    • 案例研究(Table 9,2 个示例):良性讨论示例 424 token 全部放行、最高风险 0.0036;委婉嘲讽示例在 token 105 首次报警(p=0.5044),放行 104 token,参考全长 236 token、最高风险 0.9651。作者注明示例从 6 个候选中选出,用于展示行为而非估计发生率,且前四条建议已放行,结果是截断后续而非零暴露。

    其他消融与分析

    • 路由预算 k(Table 4a,SGB-S-Eval + Qwen3-8B):k=1 时 Response/Streaming F1 为 91.30/91.87,k=4 最佳 93.67/93.57,k>4 with no further improvement.
    • RTR schedule (Table 4b, k=4): hard labels [1,1,1,1,1] give Streaming F1 of 87.68 (FP/FN 137/10); immediate switch [1,0,0,0,0] gives 93.10; the Linear, Cosine and Default progressive schedules give Streaming F1 of 93.41–93.58, and the authors state that RTR is insensitive to the specific form of the progressive schedule.
  5. What are some points that can be further explored?

    The paper does not specifically discuss limitations; the experiments cover 3 Base backbones, 5 English benchmarks and an offline replay protocol, and do not include adaptive attack evaluations.

    Limitations and future directions noted by the authors

    • The paper does not specifically discuss limitations (there is no Limitations section, and neither the Conclusion nor the appendix explicitly states "this is a limitation/future work").
    • Appendix B.3 notes: Streaming F1 only measures whether risk is detected in the response, not how early intervention occurs—two responses with different first-alarm positions are counted equally as successful detection.
    • Appendix C.1 notes: the routing visualizations come from training-state records, mixing learned routing behavior with training-time randomness (dropout, parameter updates), and cannot isolate the effect of individual factors such as prefix content.
    • Appendix C.2 notes: the RTR visualizations should be interpreted as evidence of progressive supervision refinement, not as recovery of independently annotated harmful onset boundaries.
    • Appendix C.4 notes: the two cases were selected from 6 candidates to demonstrate successful behavior rather than estimate its incidence; in the sarcasm case, the first four suggestions were released before the alarm, and the result was truncation of subsequent output rather than zero harmful exposure.

    Experimental coverage

    • The backbones tested are Qwen3-8B Base, Llama-3.1-8B Base and Gemma-7B Base, 3 in total, all Base versions at 7B–8B scale (Section 4.1).
    • The evaluation benchmarks are SGB-S-Eval, SGB-WildGuard, AEGIS2.0, BeaverTails-30k and Public WildGuard, 5 in total; the responses for the two SGB benchmarks were generated by deterministic decoding with Qwen3-8B (Appendix A.1).
    • Defense evaluation is offline replay of stored benchmark responses (Appendix B.3); the paper does not report experiments on adaptive attacks or bypass attempts against this guardrail.
    • Latency was measured on Qwen3-8B Base, a single A800, batch 1, in monitoring-only mode, with 380 matched pairs in total (Appendix C.3).
    • The paper does not report the number of repetitions for training or evaluation (main results use a single training run per setting, seed 42), nor statistical significance tests (except latency, for which bootstrap confidence intervals are given).
  6. Summarize the main content of the paper

    ADTGuard: a lightweight streaming guard on a frozen LLM, with adaptive layer selection plus progressive target refinement, best Streaming F1 in 14 of 15 settings.

    ADTGuard is a lightweight streaming safety guardrail attached to a frozen LLM (about 15.6M trainable parameters), addressing the problem that in streaming generation harmful content may be exposed before response-level moderation completes, while existing per-token detection has two gaps: fixed reading layers and overly coarse response-level supervision.

    • Method: Causal Depth Router selects Top-K layers for each response token based on the prompt and current prefix (default K=4); Depth-Time Safety Dynamics uses two selective state-space branches to integrate evidence along depth and accumulate risk along time, coupled with each other; Risk-Onset Target Refinement uses the risk trajectory cached from the previous epoch to progressively refine response-level labels into token-level soft targets, and the paper gives a characterization of its weighted forward KL optimum.
    • Main results: On 5 safety benchmarks and 3 backbones (Qwen3-8B / Llama-3.1-8B / Gemma-7B Base), the authors report that ADTGuard has the best Streaming F1 in 14 of 15 backbone×dataset settings; on Qwen3-8B, SGB-S-Eval Streaming F1 is 93.57 and SGB-WildGuard 85.87 (Table 1). Against 4 LoRA-adapted specialized moderation models (4B–12B), ADTGuard has the highest Streaming F1 on 4 of 5 datasets (Table 2).
    • Ablation: On SGB-S-Eval, RTR brings the largest Streaming improvement (87.51 to 93.58); training with hard labels gives Streaming F1 of only 87.68; k=4 is the best routing budget (Tables 3, 4).
    • Efficiency: With Qwen3-8B, 1000 input/1024 output, added amortized latency is 2.3320 ms/token, total request time +12.36% (Table 8).
    • Authors' conclusion: The authors state that coupling adaptive internal observation with progressively refined supervision is a practical path to learning effective streaming safety detection from coarse response-level labels; the paper also notes that Streaming F1 does not reflect how early intervention occurs, and the cases only demonstrate behavior rather than estimate its incidence.

Related papers

Both use: AEGIS2.0
Read originalarxiv.org