Organizations: State Key Laboratory of General Artificial Intelligence, School of Intelligence Science and Technology, Peking University · College of Artificial Intelligence, Tsinghua University · University of Chinese Academy of Sciences · China United Network Communications Group Co., Ltd.
A content-safe response can still promote priorities that conflict with its task: an assistant may demand compliance when asked to preserve autonomy. We study contextual value drift as a task-relative decoding problem with an explicit allowance for change. LaVGuard separates an authorized ten-dimensional profile from a frozen estimate of the values expressed in the visible prefix. A profile-relative density gate selects when to evaluate candidate continuations; their signed progress determines a logit tilt constrained by both changed-position and cumulative-KL budgets. We establish local surrogate improvement, pathwise budget feasibility, and a bound on response-distribution change. Profile conditioning raises boundary TPR at 5% FPR from .58 to .72. At the same .12 mean intervention ratio, the selection study reports risk-safety scores of .88 for LaVGuard and .72 for position-matched edits. The resulting interface makes task priorities actionable while keeping the extent of intervention explicit and bounded.
Figures & tables
Figure 1: Task-relative selective decoding. The authorized profile and the frozen probe’s visible-prefix state meet in the residual; the two-dimensional region illustrates the fitted geometry. Boundary exceedance and remaining position and KL allowances enable candidate evaluation. The paired continuations express contrasting priorities under a shared content guard. Along the decoding ribbon, cinnabar marks a changed sampling kernel, counted by It ; Kt is that step’s conditional KL cost. Unchanged kernels consume neither allowance. The task, trajectory, responses, and ribbon are constructed illustrations; profile and state cells indicate dimensions.
Figure 2: One guarded decoding step. Four layer taps and a frozen probe yield the visible-prefix state. The external profile enters the residual; the mixture provides a gate and a posterior residual mean (star), translated and clipped into the scoring prototype. Boundary exceedance and remaining allowances enable evaluation of the top 32 candidate prefixes. Signed progress is scaled and clipped before a KL search selects the feasible tilt. Edited and unchanged kernels share one sampling path. The ledger records the kernel-change indicator It and conditional cost Kt=DKL(p~tH∥ptH) before the sampled-prefix guard; a sample that triggers the guard retains its cost. Pre-step balances feed eligibility and KL search. Objects, bars, and geometry are schematic.
Method
AUPRC ↑
AUROC ↑
Macro-F1 ↑
Risk recall ↑
Benign FPR ↓
TPR@5% ↑
FPR@95% ↓
Content/output guard
.86 ± .025
.82 ± .025
.62 ± .03
.68 ± .03
.04 ± .01
.45 ± .04
.38 ± .04
Global boundary
.90 ± .02
.87 ± .02
.68 ± .025
.74 ± .025
.05 ± .01
.58 ± .035
.28 ± .035
Context-conditioned
.95 ± .015
.92 ± .015
.76 ± .025
.83 ± .02
.04 ± .01
.72 ± .03
.18 ± .03
LaVGuard
.96 ± .015
.93 ± .015
.79 ± .02
.86 ± .02
.04 ± .01
.76 ± .03
.15 ± .025
Table 1: Profile-relative boundary detection. TPR@5% and FPR@95% are ROC operating points; risk recall and benign FPR use the study’s deployed threshold. Entries are mean ± s.d.
Method
Single F1 ↑
Risk F1 ↑
Risk safety ↑
Risk pass ↑
Benign safety ↑
Over-refusal ↓
Token ratio ↓
Latency (ms) ↓
Base
.76 ± .03
.55 ± .025
.55 ± .03
.62 ± .035
.84 ± .015
.03 ± .008
.00 ± .00
720 ± 20
SafeInfer
.82 ± .025
.58 ± .025
.76 ± .025
.82 ± .025
.79 ± .02
.18 ± .015
.00 ± .00 †
760 ± 30
LaVGuard
.87 ± .02
.84 ± .02
.88 ± .02
.91 ± .02
.81 ± .018
.08 ± .01
.12 ± .012
830 ± 40
Table 2: Response outcomes and cost within the matched-decoding study (mean ± s.d.). † Token ratios retain the source reporting convention; SafeInfer’s zero does not establish an unchanged sampling kernel under Equation ( 2 ).
Method
Token prec. ↑
Token rec. ↑
Gain/token ↑
Risk safety ↑
Benign utility ↑
Token ratio ↓
Mean KL ↓
Random token
.18 ± .04
.20 ± .04
.015 ± .005
.70 ± .03
.79 ± .02
.12 ± .015
.04 ± .006
Position-matched
.22 ± .04
.24 ± .04
.020 ± .006
.72 ± .03
.79 ± .02
.12 ± .015
.04 ± .006
All-token
1.00 ± .00
1.00 ± .00
.035 ± .007
.89 ± .02
.68 ± .025
1.00 ± .00
.18 ± .015
Boundary only
.00 ± .00
.00 ± .00
.000 ± .000
.76 ± .025
.82 ± .02
.00 ± .00
.00 ± .00
Current key token
.45 ± .05
.52 ± .05
.060 ± .010
.82 ± .025
.80 ± .02
.15 ± .015
.05 ± .008
LaVGuard
.62 ± .04
.70 ± .04
.105 ± .012
.88 ± .02
.81 ± .018
.12 ± .012
.04 ± .006
Table 3: Complete token-selection comparison (mean ± s.d.). Random, position-matched, and LaVGuard share a reported mean token ratio of .12 . Benign utility and mean KL expose the cost of all-token intervention alongside risk safety and localization quality.
Method
Risk F1 ↑
Risk safety ↑
Benign safety ↑
Benign FPR ↓
Token ratio ↓
Mean KL ↓
No boundary
.58 ± .03
.72 ± .03
.79 ± .02
.12 ± .015
.16 ± .015
.06 ± .008
Global boundary
.70 ± .025
.78 ± .025
.80 ± .02
.08 ± .012
.14 ± .015
.05 ± .008
No uncertainty
.76 ± .025
.81 ± .025
.78 ± .02
.07 ± .010
.15 ± .015
.06 ± .008
No token budget
.83 ± .02
.89 ± .02
.73 ± .025
.06 ± .010
.34 ± .030
.10 ± .012
No KL budget
.83 ± .02
.88 ± .02
.74 ± .025
.06 ± .010
.18 ± .020
.13 ± .015
Fixed target
.77 ± .025
.80 ± .025
.78 ± .02
.08 ± .012
.14 ± .015
.06 ± .008
Table 4: Complete component ablations (mean ± s.d.). Token ratio and mean KL are study-level readouts. No-uncertainty and fast-scoring rows retain the source evaluation configurations; the reference specification uses a single frozen probe.
Figure 3: Selection and budget comparisons. (a) Safety–utility outcomes for six selection rules. (b) Precision versus gain for Random, Position-matched, and LaVGuard, matched on reported mean token ratio .12 and mean KL .04 . (c) Full control versus removal of either budget; lines compare configuration means, not trajectories. Whiskers show each coordinate’s reported standard deviation. Short method names follow Tables 3 and 4 .
Figure 4: Transfer, dialogue, and runtime in their respective studies. (a) Transfer risk F1 and worst-group score. (b) Earlier detection and lower cumulative risk lie toward the lower left; points are five method aggregates, not a trajectory. (c) Mean and P95 latency from the independent efficiency study, in seconds on a logarithmic axis. Lines join the two latency statistics; error bars throughout show reported standard deviations. “Full”/“Fast” denote LaVGuard/LaVGuard-fast; “Key token”/“Lookahead” abbreviate the methods in Tables 14 – 15 .
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Symbol
Definition and role
x,cobs,c
Request, visible task context, and complete application contract.
y<t,T,V
Generated prefix, padded generation horizon, and vocabulary.
π(c)∈[0,1]D
Authorized reference profile; D=10 in the documented configuration.
q<t,vˉ<t
Normalized intensity annotation and predicted prefix state.
L,W,Pℓ
Probe tap layers, pooling window, and learned layer projections.
r<t
Profile-relative residual vˉ<t−π(c) .
Appendix
Table 5: Symbol index. A state, an annotation, a task profile, and a sampling distribution are separate objects throughout the derivations.
Component
Setting
Execution role
Backbone
Qwen2.5-7B-Instruct, frozen
Base logits and hidden states.
Probe taps
25, 50, 75, 100% depth; W=16
Pool the visible prefix.
Probe projections
Width 64 per tap; sigmoid output
Ten simultaneous intensity estimates.
Probe optimization
AdamW; 2×10−4 ; batch 16; patience 10
Fit before boundary estimation.
Boundary
K=2 ; diagonal shrinkage .10
Density of admissible residuals.
Threshold
Maximum recall subject to validation benign FPR ≤.05
Select the activation rule.
Appendix
Table 6: Controller configuration. Probe fitting precedes boundary fitting, and both precede threshold selection and decoding.
Figure 5: Two exact mathematical examples. Left: the mixture in Proposition C.2 admits states near .2 and .8 at density threshold 1 , while its posterior-mean prototype at .5 lies outside the set. Right: for p=(.45,.40,.15) and d=(1,−1,.2) , KL increases with the tilt scale. The marked endpoint is returned by 20 feasible-bracket bisections with cap .02 . Curves are analytically computed functions, not empirical fits.
Token
Base p
Signed q.2
Positive q.2
w1
.400
.360
.449
w2
.200
.199
.184
w3
.250
.275
.230
w4
.150
.165
.138
Tail mass
.400
.440
.367
Tail odds
5:3
5:3
5:3
Appendix
Table 7: Constructed tail redistribution with qi∝pie.2di . Signed: d=(−1,−21,0,0) ; positive: d=(1,0,0,0) , as in Appendix H . Tokens w3,w4 are unscored. Values and totals are rounded independently; these are analytical probabilities.
Method
Accuracy ↑
Macro-F1 ↑
Risk recall ↑
Benign FPR ↓
ECE ↓
Spearman ↑
Prompt
.72 ± .03
.58 ± .03
.62 ± .035
.18 ± .015
.14 ± .01
.72 ± .025
SafeDecoding
.74 ± .03
.60 ± .03
.66 ± .035
.16 ± .015
.13 ± .01
.74 ± .025
Latent detector only
.82 ± .025
.74 ± .025
.80 ± .025
.09 ± .01
.08 ± .008
.86 ± .02
LaVGuard
.85 ± .02
.78 ± .02
.84 ± .02
.07 ± .008
.06 ± .006
.89 ± .015
Appendix
Table 8: Prefix prediction and calibration. Risk recall, benign FPR, ECE, and ordinal ranking retain their separate readouts. Cells show mean ± standard deviation.
Method
AUPRC ↑
AUROC ↑
Macro-F1 ↑
Risk recall ↑
Benign FPR ↓
TPR@5 ↑
FPR@95 ↓
Content/output guard
.86 ± .025
.82 ± .025
.62 ± .03
.68 ± .03
.04 ± .01
.45 ± .04
.38 ± .04
Global boundary
.90 ± .02
.87 ± .02
.68 ± .025
.74 ± .025
.05 ± .01
.58 ± .035
.28 ± .035
Context-conditioned boundary
.95 ± .015
.92 ± .015
.76 ± .025
.83 ± .02
.04 ± .01
.72 ± .03
.18 ± .03
LaVGuard
.96 ± .015
.93 ± .015
.79 ± .02
.86 ± .02
.04 ± .01
.76 ± .03
.15 ± .025
Appendix
Table 9: Boundary discrimination and operating points. TPR@5 denotes TPR at 5% FPR; FPR@95 denotes FPR at 95% TPR. These curve-derived values are distinct from the deployed-threshold recall. Cells show mean ± standard deviation.
Method
Single F1 ↑
Risk F1 ↑
Risk safety ↑
Risk pass ↑
Benign safety ↑
Over- refusal ↓
Token ratio ↓
Latency (ms) ↓
Base
.76 ± .03
.55 ± .025
.55 ± .03
.62 ± .035
.84 ± .015
.03 ± .008
.00 ± .00
720 ± 20
SafeInfer
.82 ± .025
.58 ± .025
.76 ± .025
.82 ± .025
.79 ± .02
.18 ± .015
.00 ± .00 †
760 ± 30
LaVGuard
.87 ± .02
.84 ± .02
.88 ± .02
.91 ± .02
.81 ± .018
.08 ± .01
.12 ± .012
830 ± 40
Appendix
Table 10: Matched decoding comparison. Response-safety scores, risk pass rate, over-refusal, and intervention ratio retain their study readouts. Cells show mean ± standard deviation. † SafeInfer’s source-reported zero token ratio cannot be interpreted as zero changed-kernel intervention under Equation ( 2 ).
Method
Token prec. ↑
Token rec. ↑
Gain/ token ↑
Risk safety ↑
Benign utility ↑
Token ratio ↓
Mean KL ↓
Random token
.18 ± .04
.20 ± .04
.015 ± .005
.70 ± .03
.79 ± .02
.12 ± .015
.04 ± .006
Position-matched
.22 ± .04
.24 ± .04
.020 ± .006
.72 ± .03
.79 ± .02
.12 ± .015
.04 ± .006
All-token
1.00 ± .00
1.00 ± .00
.035 ± .007
.89 ± .02
.68 ± .025
1.00 ± .00
.18 ± .015
Boundary only
.00 ± .00
.00 ± .00
.000 ± .000
.76 ± .025
.82 ± .02
.00 ± .00
.00 ± .00
Current key token
.45 ± .05
.52 ± .05
.060 ± .010
.82 ± .025
.80 ± .02
.15 ± .015
.05 ± .008
LaVGuard
.62 ± .04
.70 ± .04
.105 ± .012
.88 ± .02
.81 ± .018
.12 ± .012
.04 ± .006
Appendix
Table 11: Token-localization controls. Token precision/recall and gain per token use the original reporting labels; Section F states the measurement conventions. Cells show mean ± standard deviation.
Method
Risk F1 ↑
Risk safety ↑
Benign safety ↑
Benign FPR ↓
Token ratio ↓
Mean KL ↓
No boundary
.58 ± .03
.72 ± .03
.79 ± .02
.12 ± .015
.16 ± .015
.06 ± .008
Global boundary
.70 ± .025
.78 ± .025
.80 ± .02
.08 ± .012
.14 ± .015
.05 ± .008
No uncertainty
.76 ± .025
.81 ± .025
.78 ± .02
.07 ± .010
.15 ± .015
.06 ± .008
No token budget
.83 ± .02
.89 ± .02
.73 ± .025
.06 ± .010
.34 ± .030
.10 ± .012
No KL budget
.83 ± .02
.88 ± .02
.74 ± .025
.06 ± .010
.18 ± .020
.13 ± .015
Fixed target
.77 ± .025
.80 ± .025
.78 ± .02
.08 ± .012
.14 ± .015
.06 ± .008
Appendix
Table 12: Component ablations. The uncertainty and fast-scoring variants are evaluation configurations distinct from the single-probe reference specification. Cells show mean ± standard deviation.
Method
Single F1 ↑
Risk F1 ↑
Risk safety ↑
Benign safety ↑
Worst group ↑
OOD drop ↓
Base
.74 ± .03
.52 ± .035
.50 ± .035
.82 ± .02
.45 ± .035
.05 ± .010
SafeInfer
.78 ± .03
.55 ± .035
.72 ± .03
.77 ± .025
.62 ± .035
.06 ± .012
LaVGuard
.82 ± .03
.78 ± .03
.83 ± .03
.79 ± .025
.74 ± .035
.05 ± .012
Appendix
Table 13: Transfer evaluation. OOD drop is the reported in-domain-relative difference; worst-group score preserves the original group-level summary. Cells show mean ± standard deviation.
Method
First detect. ↓
Cumul. risk ↓
Turn recall ↑
Risk safety ↑
Benign utility ↑
Over- refusal ↓
Base
4.2 ± .50
.46 ± .04
.48 ± .04
.52 ± .035
.84 ± .015
.03 ± .008
SafeInfer
3.1 ± .45
.30 ± .03
.68 ± .03
.75 ± .025
.76 ± .025
.20 ± .015
Current key token
2.8 ± .40
.26 ± .03
.72 ± .03
.78 ± .025
.78 ± .025
.14 ± .015
LaVGuard-fast
2.3 ± .35
.21 ± .025
.79 ± .025
.83 ± .022
.80 ± .020
.10 ± .010
LaVGuard
2.0 ± .35
.18 ± .025
.83 ± .022
.86 ± .020
.80 ± .020
.08 ± .010
Appendix
Table 14: Multi-turn dialogue. First detection is expressed in turns; cumulative risk and turn recall retain their source aggregation labels. Cells show mean ± standard deviation.
Method
Mean ms ↓
P95 ms ↓
Δ MB ↓
Extra passes ↓
Token ratio ↓
Δ utility ↑
Base
720 ± 20
900 ± 50
0 ± 0
0.0 ± 0.0
.00 ± .00
.00 ± .00
SafeInfer
760 ± 30
950 ± 60
200 ± 50
.2 ± .05
.00 ± .00 †
-.03 ± .008
All-token
1120 ± 80
1450 ± 100
1800 ± 200
1.0 ± .0
1.00 ± .00
-.10 ± .015
One-step lookahead
2800 ± 300
4200 ± 400
2500 ± 250
3.0 ± .20
.12 ± .012
-.02 ± .008
LaVGuard
920 ± 50
1200 ± 80
1200 ± 150
.8 ± .10
.12 ± .012
-.02 ± .008
LaVGuard-fast
820 ± 40
1050 ± 70
800 ± 120
.4 ± .05
.10 ± .012
-.01 ± .006
Appendix
Table 15: Runtime and resource efficiency. Memory is reported as a delta. These study-specific latency values are not substituted for those in the matched-decoding comparison. Cells show mean ± standard deviation. † The SafeInfer zero is the source-reported token ratio, not a measurement of unchanged sampling kernels under Equation ( 2 ).
Decision quantity
Workshop
Replication
Squared residual norm
.02
.50
Boundary excess
−.53125
5.46875
Candidate evaluation
no
yes
Selected scale
0
.838114
Probability of w1
.450000
.389721
Probability of w2
.400000
.468422
Appendix
Table 16: Constructed paired decision trace. All displayed quantities follow from the assigned profiles, states, and probabilities. The final KL entry is rounded; the feasible value before rounding is .0299999848 .
LLM agents act on real-world environments through tool calls, and a single misjudged action can cause irreversible harm. The standard safeguard is a guard model that labels each proposed action as safe or unsafe, but this binary view conflates two distinct decisions: whether the action is harmful in itself, and whether it is appropriate given the user's context. It also operates at the granularity of action categories rather than individual instances, producing routine interruptions that erode autonomy and train users to wave through the most consequential alerts. We reframe the problem as a per-instance three-way routing decision over {EXECUTE, ASK, REFUSE} and instantiate it with Safety Sentry, a lightweight guard model whose inference reduces to a single decoding call. A single decoding-time threshold lets one fixed checkpoint be re-positioned across deployments of differing risk tolerance without retraining. Safety Sentry outperforms a broad set of open-weight and frontier closed-source baselines on overall accuracy and safety-related recall, while controlling both directional error rates simultaneously.Code and data are available at https://github.com/safesentry/SAFETY-SENTRY
While large language models (LLMs) are trained to align with human values, their generations may still violate safety constraints. A growing line of work addresses this problem by modifying the model's sampling policy at decoding time using a safety reward. However, existing decoding-time steering methods often intervene unnecessarily, modifying generations that would have been safe under the base model. Such unnecessary interventions are undesirable, as they can distort key properties of the base model such as helpfulness, fluency, style, and coherence. We propose a new test-time steering method designed to reduce such unnecessary interventions while improving the safety of unsafe responses. Our approach filters tokens using a value-based safety criterion and provides an explicit bound on the probability of false interventions. A single threshold hyperparameter controls this bound, allowing practitioners to trade off higher rates of unnecessary intervention for better output safety. Across multiple datasets and experiments, we show that our value-filtered decoding method outperforms existing baselines, achieving better trade-offs between safety, helpfulness, and similarity to the base model.
Bat-Sheva Einbinder, Hen Davidov, Yee Whye Teh +2
Department of Electrical and Computer Engineering, Technion IIT, Israel · Department of Statistics, University of Oxford, Oxford, UK · OATML, Department of Computer Science, University of Oxford, Oxford, UK +1
When an LLM agent reads a confidential file, then writes a summary, then emails it externally, no single step is unsafe, but the sequence is a data leak. We call this safety drift: individually safe actions compounding into violations. Prior work has measured this problem; we predict it. SafetyDrift models agent safety trajectories as absorbing Markov chains, computing the probability that a trajectory will reach a violation within a given number of steps via closed form absorption analysis. A consequence of the monotonic state design is that every agent will eventually violate safety if left unsupervised (absorption probability 1.0 from all states), making the practical question not if but when, and motivating our focus on finite horizon prediction. Across 357 traces spanning 40 realistic tasks in four categories, we discover that "points of no return" are sharply task dependent: in communication tasks, agents that reach even a mild risk state have an 85% chance of violating safety within five steps, while in technical tasks the probability stays below 5% from any state. A lightweight monitor built on these models detects 94.7% of violations with 3.7 steps of advance warning at negligible computational cost, outperforming both keyword matching (44.7% detection, 55.9% false positive rate) and per step LLM judges (52.6% detection, 38.2% false positive rate) while running over 60,000x faster.
Aditya Dhodapkar, Farhaan Pishori
Rensselaer Polytechnic Institute Department of Computer Science · Santa Clara University Department of Engineering