DeCoVec: Building Decoding Space based Task Vector for Large Language Models via In-Context Learning
Organizations: College of Computer Science and Software Engineering, Shenzhen University
Abstract
Task vectors, representing directions in model or activation spaces that encode task-specific behaviors, have emerged as a promising tool for steering large language models (LLMs). However, existing approaches typically require fine-tuning or invasive manipulation of internal states, limiting their flexibility and scalability. We propose DeCoVec (Decoding Space based Task Vector), a training-free and non-invasive framework that constructs task vectors directly in the decoding space by leveraging in-context learning (ICL). Specifically, DeCoVec captures the task essence as the difference between the output logit distributions of few-shot and zero-shot prompts, then steers generation by injecting this vector into the decoding process. Experiments across seven LLMs (0.5B--9B) on TruthfulQA, Math-500, and AQUA-RAT show that DeCoVec consistently outperforms standard few-shot baselines, with gains up to +5.50 average accuracy. Further analysis demonstrates that DeCoVec effectively suppresses generation degeneration and logical flaws while exhibiting strong robustness to demonstration ordering, all without incurring additional input token costs. Our method offers a training-free and non-invasive solution for LLM steering without requiring weight updates or auxiliary models.
Figures & tables
| Types of Task Vector | Non-Invasive | Training-Free | Operational Space | Vector Representation |
| Arithmetical Task Vector ( Ilharco et al., 2023 ) | ✗ | ✗ | Model Weights | |
| Chat Vector ( Huang et al., 2024 ) | ||||
| Emotional Vector ( Kalyan et al., 2024 ) | ||||
| Contrastive Vector ( Fierro and Roger, 2025 ) | ||||
| Rule Task Vector ( Hendel et al., 2023 ) | ✗ | ✓ | Activation States | |
| Function Vector ( Todd et al., 2024 ) |
| Methods | TruthfulQA | Avg. | Math-500 | AQUA-RAT | Avg. | |||
| MC1 | MC2 | MC3 | Acc. | Acc. | ||||
| Qwen2-0.5B | Zero-Shot | 25.18 | 40.78 | 19.55 | - | 1.17 | 20.87 | - |
| Few-Shot (Rand. Std.) | 32.35 ( 1.97 ) | 47.54 ( 2.51 ) | 23.46 ( 1.38 ) | 1.95 | 0 8.59 ( 0.39) | 23.23 ( 5.12 ) | 2.37 | |
| Few-Shot (Rand. Ext.) | 32.21 ( 0.70 ) | 48.01 ( 2.55 ) | 23.73 ( 1.42 ) | 1.56 | 0 7.03 ( 0.78 ) | 21.65 ( 3.55 ) | 2.17 | |
| Few-Shot (KATE) | 34.60 ( 0.42 ) | 50.43 ( 2.12 ) | 24.98 ( 1.57 ) | 1.37 | 0 8.59 ( 3.52 ) | 18.11 ( 5.91 ) | 4.72 | |
| Few-Shot (BM25) | 32.35 ( 0.28 ) | 47.83 ( 2.64 ) | 23.09 ( 1.36 ) | 1.43 | 10.55 ( 0.39) | 20.87 ( 1.96 ) | 0.79 | |
| Methods | TruthfulQA | Math-500 | AQUA-RAT |
| Avg. MC | Acc. | Acc. | |
| Sequential Order | |||
| KATE | 45.52 | 43.36 | 49.21 |
| w/ DeCoVec | 46.87 ↑1.35 | 50.00 ↑6.64 | 53.54 ↑4.33 |
| BM25 | 44.37 | 48.83 | 53.54 |
| w/ DeCoVec | 45.47 ↑1.10 | 49.61 ↑0.78 | 53.94 ↑0.40 |
| Methods | LR | DG | CA | CM | Total Err. |
| KATE | 35.4% | 9.4% | 6.5% | 5.3% | 56.6% |
| w / DeCoVec | 27.0% | 7.3% | 8.8% | 6.9% | 50.0% |
| 8.4% | 2.1% | 2.3% | 1.6% | 6.6% |
| Methods | Rand. Std. | Rand. Ext. | KATE | BM25 |
| Few-Shot ICL | 354.8 | 344.2 | 326.1 | 324.6 |
| w / DeCoVec | 314.5 | 333.6 | 312.3 | 300.1 |
| 40.3 | 10.6 | 13.8 | 24.5 |
| Math-500 | AQUA-RAT | |||||||
| Model | Rand. Std. | Rand. Ext. | KATE | BM25 | Rand. Std. | Rand. Ext. | KATE | BM25 |
| Qwen2-0.5B | 1.0 | 0.8 | 1.0 | 0.8 | 1.0 | 1.0 | 1.0 | 0.4 |
| Qwen2-1.5B | 0.8 | 0.8 | 0.6 | 0.8 | 0.2 | 1.0 | 0.8 | 1.0 |
| Qwen2-7B | 1.0 | 0.2 | 0.6 | 0.4 | 0.2 | 0.2 | 0.2 | 1.0 |
| Yi-6B | 0.2 | 0.2 | 0.2 | 0.2 | 0.6 | 1.0 | 0.6 | 0.2 |
| Llama-2-7B | 1.0 | 0.8 | 0.4 | 0.4 | 0.6 | 1.0 | 0.4 | 0.8 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Rand. Std. | DeCoVec (Ours) | Overhead |
| AQUA-RAT | 4.03s | 6.70s | 1.6 |
| MATH-500 | 8.39s | 14.54s | 1.7 |
Language Model Steering
Language model steering controls a model’s behavior at inference time by intervening in its representations, components, or decoding process.
See all 279 papers