Paper commentary
NExT-Guard: Streaming Safeguard without Token-Level Labels
NExT-Guard detects harmful streamed text by reading existing LLM safety features
- Problem Post-hoc safeguards judge only after generation ends, so harmful text can reach users first. Streaming guards need costly per-token labels and retraining whenever the safety policy changes.
- Method NExT-Guard uses sparse autoencoder features already trained on the base LLM. It picks the top 32 features that separate unsafe from safe samples, then sums their weighted activations token by token.
- Results On prompt classification, NExT-Guard averages 90.8 F1, 6.4 points above the strongest streaming baseline.
Why post-hoc checks miss streaming harm
Many deployed LLMs stream their answers token by token, so a harmful span can reach the user before any judge reads the full reply. A post-hoc safeguard only judges after generation ends, so an interception arrives after the unsafe content has already been shown.
The usual fix is a streaming guard trained on per-token safety labels. Those labels are expensive and subjective, because whether a token is harmful depends on context that builds over many tokens. Such training can also overfit, so a guard may react to isolated keywords instead of the surrounding meaning. A change in safety policy then forces relabeling and retraining.
Reading safety signals from hidden states
The authors argue that a safeguard reaching a reliable verdict must already build safety-relevant information token by token inside its hidden states. On this view, streaming detection means reading those existing states rather than teaching the guard a new skill. Sparse autoencoders turn these dense states into sparse features that can be inspected one by one.
An SAE maps a hidden state into a much wider latent vector, and each coordinate reads as how strongly one latent feature is active. NEXT-GUARD uses SAEs already trained on the same base LLM, so it does not train SAEs from scratch. The authors rely on earlier work suggesting that SAE features keep stable directions across checkpoints and model variants.
Finding the safety-relevant features offline
The calibration set is drawn at random from public safety benchmarks, and each item pairs a user prompt with its generated response. The set need not cover every unsafe category, as long as it is large enough to average out background topics.
Labels exist per sample, while SAE activations exist per token, so each sample is first reduced to one feature vector. Max-pooling keeps the largest activation of each feature across the sample's tokens, which suits risks signalled by a few keywords or phrases.
Each dimension gets a discriminative score s_j, the gap between its mean activation on unsafe and safe samples divided by the sum of the two standard deviations. The denominator penalises noisy features, so the score favours stable triggers over single-token spikes. The top K dimensions, typically 32, form the safety-relevant set S. The authors also tried Pearson correlation and mutual information, and report rankings highly consistent with the standardized mean difference.
Scoring each generated token
At step t the safeguard sees only the prompt and the prefix generated so far, together with the current token. The activation of each selected feature is weighted by its discriminative score, and the weighted values are summed into a risk score. Generation stops once this running score passes a threshold, which sets the balance between detection and over-refusal.
The authors also tested Random Forest classifiers as an alternative way to fuse the selected features. They report similar performance, and they read this as evidence that the selected features, rather than the fusion method, carry the robustness.
Detection against post-hoc and streaming baselines
Prompt sets are Aegis, Aegis2.0 and SimpleSafetyTests, and response sets are SafeRLHF, BeaverTails and Aegis2.0, all scored with unsafe-class F1. The post-hoc group includes LlamaGuard, WildGuard, ShieldGemma, NemoGuard and Qwen3Guard-Gen, and the streaming group includes SCM, Kelp and the Qwen3Guard-Stream models.
On prompt classification, NEXT-GUARD averages 90.8 F1, which is 6.4 points above the strongest streaming baseline. On response classification, its average is 84.3, which is 7.3 points above the best streaming baseline. These gaps compare benchmark averages, not single datasets.
Relative to post-hoc safeguards, the prompt average is 2.2 points higher than the best post-hoc prompt average. The authors stress that this holds even though NEXT-GUARD sees only part of each sequence. A starred variant, NExT-Guard*, averages 90.4 on prompts and 82.0 on responses, so it sits below the main method. On the Aegis column the main method scores 88.9.
Where the intervention lands
The authors sampled 300 responses where unsafe spans are easy to localise, and human annotators marked explicit risk-bearing tokens. They take the first unsafe token as the ground-truth onset and compare each streaming safeguard's first-intervention position, normalised by sequence length, with that onset.
In the authors' reading, NEXT-GUARD's intervention distribution follows the ground-truth peak and overall shape. Qwen3Guard-8B-Stream and SCM-7B put more probability mass near the start of the sequence, which the authors link to keyword-driven over-triggering.
Which features are category-specific
Each SAE feature is thresholded as a detector on Aegis2.0, and its precision and recall are plotted for violence, sexual, privacy and criminal planning. Points are coloured by discriminative score. Higher-scored features sit closer to the upper-right of these plots, which the authors read as favouring category-specific detectors over generic keyword triggers.
Token-level examples show features that fire sharply on risk-bearing spans and stay quiet elsewhere.
Layer and backbone sensitivity
The authors take SAEs from layers 9, 18 and 27, and test Qwen3Guard-8B-Gen and Qwen3-8B, a base model without safeguard finetuning. Evaluation covers Aegis2.0, SafeRLHF and BeaverTails.
With middle or late SAEs, Qwen3-8B holds F1 between 80 and 85 across the datasets. The authors read this as safety concept separation being encoded in mid-to-late representations, and the 80 to 85 range refers only to Qwen3-8B.
Limitations
The main experiments centre on the Qwen series, chosen to keep comparisons controlled. NEXT-GUARD has not yet been exhaustively adapted to other prevalent post-hoc guardrails. A finer analysis of why certain module combinations work best is left for future work.
The timing analysis uses 300 sampled responses. The authors' extension to agent systems, blocking unsafe reasoning before tool calls, is stated as a future direction and not tested.
Paper info
- Authors
- Junfeng Fang, Nachuan Chen, Houcheng Jiang, Dan Zhang, Xiangnan He, Tat-Seng Chua, Xiang Wang
- Venue
- International Conference on Machine Learning · Published
- First published
- 2026-9-29
- Added
- 2026-11-25
- Original paper terms
- Check in the original ↗
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Junfeng Fang, Nachuan Chen, Houcheng Jiang, Dan Zhang, Xiangnan He, Tat-Seng Chua, Xiang Wang (2026). NExT-Guard: Streaming Safeguard without Token-Level Labels. International Conference on Machine Learning. https://proceedings.mlr.press/v306/fang26a.html
BibTeX
@article{fang2026next,
title = {{NExT-Guard: Streaming Safeguard without Token-Level Labels}},
author = {Junfeng Fang and Nachuan Chen and Houcheng Jiang and Dan Zhang and Xiangnan He and Tat-Seng Chua and Xiang Wang},
year = {2026},
journal = {International Conference on Machine Learning},
url = {https://proceedings.mlr.press/v306/fang26a.html}
}