Steered Generation via Gradient-Based Optimization on Sparse Query Features
Sumanta Bhattacharyya [email protected], Pedram Rooshenas [email protected] · 2026
Read Steered Generation via Gradient-Based Optimization on Sparse Query Features by Sumanta Bhattacharyya [email protected], Pedram Rooshenas [email protected] (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-23040.txt.
Introduction
Bhattacharyya and Rooshenas test attention query activations as a precise site for steering language model generation. Dense-state meddling tangles distinct semantic features. So they apply sparse autoencoders to query activations, split them into clear features, and tune gradients at inference to match sparse patterns with class prototypes of target behaviors. In a textual gridworld, sparse query tuning navigates rigid planning rules such as safe versus short paths. In a school domain, the same method steers the cognitive complexity of feedback along Bloom's Taxonomy.
Catalog record
| CREATOR | Sumanta Bhattacharyya [email protected], Pedram Rooshenas [email protected] |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 89919 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2605.23040
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Steered Generation via Gradient-Based Optimization on Sparse Query Features Sumanta Bhattacharyya [email protected], Pedram Rooshenas [email protected] Abstract Latent steering exploits internal representations of Large Language Models (LLMs) to guide generation, yet interventions on dense states can entangle distinct semantic features. In this paper, we investigate attention query activations as a high-fidelity site for precise control, hypothesizing that manipulating the attention mechanism itself offers sharper steerability than general state interventions. We introduce Prototype-Based Sparse Steering, a framework that applies Sparse Autoencoders (SAEs) specifically to query activations, to decompose them into interpretable features, then apply gradient-based optimization during inference to align the sparse representation with class prototypes of target behaviors. To validate this architectural insight, we first analyze the mechanism in Textualized Gridworld, a controlled environment for verifiable planning constraints. We demonstrate that optimizing sparse query features enables effective navigation of rigid planning requirements (i.e., safe vs. short paths), confirming the method’s ability to satisfy objective rules. We then demonstrate the framework’s versatility by training SAEs on a high-dimensional educational domain, where the framework steers the cognitive complexity of feedback (i.e., Bloom’s Taxonomy). Our experiments establish that sparse query representations provide the necessary disentanglement for unified, interpretable control over both logical planning and stylistic nuance. 1 Introduction LLMs have emerged as the de facto natural language interface for modern AI systems. However, deploying these models in real-world scenarios requires more than fluent generation; it necessitates precise adherence to user-defined requirements regarding style, safety, and logical consistency. Consequently, research on controlled text generation in LLMs has been extensively explored for general-purpose applications (see the comprehensive survey by 106 ). Unlike standard text generation, controlled text generation ( 63 ) guides LLMs to generate outputs that adhere to specific constraints. To achieve this control, prompt engineering has become a prevalent strategy. However, controlling text generation solely through prompting can be ineffective ( 101 ) , as prompts often require extensive contextual information to generate relevant responses. When additional instructions for controlling style and nuance are included, they may be diluted or ignored within long prompt contexts ( 55 ) . Moreover, open-source and smaller LLMs provide limited control over generated text when relying solely on prompt-based methods ( 77 ) . In practice, this gap is most visible in smaller open-source models: the same instruction that yields stable stylistic adherence in frontier models can produce inconsistent or diluted control in smaller models. A common mitigation is to include a few labeled demonstrations in the prompt (in-context learning) to anchor the desired attribute ( 10 ) . However, increasing the number of demonstrations leads to significant memory consumption and computational overhead, particularly with the larger context windows needed for complex tasks ( 94 ; 50 ) . These limitations motivate approaches that do not rely on expanding the prompt, but instead intervene directly in the model’s internal representations at inference time. Latent-space steering methods, often referred to as activation engineering, enable controlled text generation by intervening directly in the internal activations of large language models during inference ( 17 ; 53 ; 40 ) . These methods typically use steering vectors, which are directions in activation space associated with semantic, behavioral, or stylistic attributes, to shift model behavior in predictable ways ( 34 ; 84 ) . Compared with in-context prompting, activation engineering provides a more direct mechanism for controlling attributes such as style, tone, formality, or factuality, without expanding the prompt context. However, dense activation spaces can entangle multiple latent factors, consistent with the superposition hypothesis ( 24 ) , making interventions less precise and more prone to unintended side effects. Sparse representations, including those learned by Sparse Auto-Encoders (SAEs; 57 ), offer a natural way to factorize control directions by encouraging updates to concentrate on a smaller set of features ( 16 ; 9 ) . This sparsity can support more isolated and independent latent updates, enabling more precise and reliable control over target attributes during generation. Prior steering largely adds static vectors to the residual stream or attention-head outputs, which can overwrite context and entangle attributes; we instead ask whether a more local site, optimized rather than fixed, yields cleaner control. In this paper, we hypothesize that attention query activations serve as a high-fidelity control surface for generation, as they encode the model’s intent to retrieve information from context. Because queries parameterize how tokens attend to and retrieve information, small and localized query perturbations can modify what the model uses while substantially reducing global distortion of the residual stream. We propose an approach for controlled generation that combines SAEs with gradient-based latent search. Inspired by prototypical networks ( 80 ) , originally designed for few-shot learning, we represent target attributes as prototype distributions in the sparse latent space. Instead of adding a static steering vector, we treat control as an optimization problem, steering encoded features to increase alignment with the desired prototype distribution. We validate our approach across complementary control settings. For hard, verifiable control, we evaluate on Textualized Gridworld (TGW; 42 ), adapted from classic RL planning setups ( 104 ) , where generated paths must satisfy explicit safety and length constraints. This setting enables exact, rule-based evaluation: we can directly measure whether the generated path remains valid while satisfying the target objective, such as producing a safe, short, or long path. For soft semantic control, we transfer our method to an educational feedback setting and steer Bloom-level cognitive complexity ( 3 ) , demonstrating control over nuanced pedagogical and stylistic attributes. Finally, we evaluate on TruthfulQA ( 52 ) as an external benchmark to assess whether gradient-based steering improves truthfulness and informativeness while reducing distributional distortion compared with static vector-addition baselines. Our primary contributions and findings are the following: 1) Prototype-Based Sparse Query Optimization: We formulate inference-time control as gradient-based optimization over sparse query latents, using a prototype-distribution objective defined by a softmax over negative distances to target attribute prototypes. This enables adaptive steering toward semantic or behavioral targets while keeping the base model weights fixed. 2) Query-Level Control Fidelity: We provide quantitative evidence that attention query activations offer a more local and lower-distortion intervention site than the residual stream. Specifically, query-level interventions exhibit bounded cross-layer activation deviation and lower next-token Jensen–Shannon divergence at matched steering strength, supporting their use for both planning and stylistic control. Recent independent work on query-level steering ( 88 ) provides complementary evidence for the same broader observation. 3) Steering-Oriented Evaluation Data: We construct a new Bloom’s Taxonomy dataset for cognitive style steering ( 3 ) and derive a filtered Gridworld steering subset from Textualized Gridworld ( 42 ) . The Gridworld subset is designed to contain mutually distinct safe, short, and long paths, enabling rule-based evaluation of hard steering constraints. 4) Experimental Validation Across Steering Regimes: We evaluate our method on hard planning constraints, soft cognitive-style control, and TruthfulQA truthfulness steering. Across TGW experiments on three open-weight models, Bloom-level steering, and TruthfulQA, our method matches or exceeds prompting, residual-stream steering, attention-head steering, dense query steering, and static sparse steering baselines, while often inducing substantially lower distributional cost. 2 Proposed Steering Framework Figure 1 : Quantifiable steering in TGW. We steer generation to short, safe (lower wall-adjacency score), and long targets; success is verifiable via path