Abstract
Traditional methods for adapting Large Language Models (LLMs) to specific tasks, such as In-Context Learning (ICL) or fine-tuning, often face challenges regarding sample efficiency, context window constraints, or computational costs. We present a task-driven layerwise additive activation intervention that optimizes a single intervention vector added to internal activations. This approach achieves superior performance in low-data regimes and enables "task calculus"—the algebraic composition of task-specific vectors.
Introduction
Adapting LLMs in real-time is typically achieved via ICL, which is sensitive to prompt phrasing and consumes context space. Activation intervention offers an alternative by manipulating internal hidden states. However, prior work often relied on heuristics or required large datasets. We propose an optimization-based framework that identifies a sparse intervention vector ($\Delta$) to be added at a specific layer, significantly improving task steering with as few as 10 examples.
Methodology
The core of our approach is the optimization of an additive vector $\Delta$ applied to the activations of the input's final token at a target layer.
Optimization and Regularization
Unlike heuristic steering, we treat vector discovery as a mathematical optimization problem, minimizing the loss between model output and target labels. To prevent overfitting in low-data scenarios, we employ a joint regularization strategy using Lasso ($\ell_1$) and Group Lasso. This sparsity constraint ensures the intervention targets only the most relevant neurons and attention heads, preserving the model's general capabilities.
Task Calculus
A unique advantage of this localized, additive approach is modularity. Because interventions are applied at the same layer, vectors for distinct tasks (e.g., "Translation" and "Antonym") can be added algebraically to perform composed tasks without additional training.
Experimental Results
We evaluated our method on rule-following tasks (translation, linguistic transformations) and opinion alignment (OpinionQA).
Comparative Performance
Our method consistently outperforms standard prompting and existing intervention baselines like Function Vectors (FV). For instance, on the English-to-French task, our approach achieves an Exact Match score of 0.795, a significant lead over 10-shot prompting with FV (0.241).
Analysis
Layer Sensitivity
A critical finding is the existence of a "sweet spot" for intervention. Performance is maximized when intervening at early-to-mid layers (e.g., layer 4 for Llama3-8b). Intervening too early or too late results in a sharp decline in task-steering effectiveness.
Efficiency and Sparsity
The use of Group Lasso confirms that task-specific behaviors are often localized to a small subset of attention heads. This sparsity makes the intervention more robust than dense methods like LoRA when training data is extremely limited. In opinion alignment tasks, the method reduced KL divergence to 0.273, whereas 10-shot prompting only reached 2.074.
Conclusion
Task-driven layerwise additive intervention provides a powerful, data-efficient mechanism for steering LLMs. While requiring white-box access, the method's ability to compose tasks algebraically and its high performance in low-shot settings mark a significant advancement in model steering. Future work will explore scaling to larger models and mitigating potential risks of malicious steering.
Summary updated