Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Task Vectors, Learned Not Extracted: Performance Gains and Mechanistic Insight

About

Large Language Models (LLMs) can perform new tasks from in-context demonstrations, a phenomenon known as in-context learning (ICL). Recent work suggests that these demonstrations are compressed into task vectors (TVs), compact task representations that LLMs exploit for predictions. However, prior studies typically extract TVs from model outputs or hidden states using cumbersome and opaque methods, and they rarely elucidate the mechanisms by which TVs influence computation. In this work, we address both limitations. First, we propose directly training Learned Task Vectors (LTVs), which surpass extracted TVs in accuracy and exhibit superior flexibility-acting effectively at arbitrary layers, positions, and even with ICL prompts. Second, through systematic analysis, we investigate the mechanistic role of TVs, showing that at the low level they steer predictions primarily through attention-head OV circuits, with a small subset of "key heads" most decisive. At a higher level, we find that despite Transformer nonlinearities, TV propagation is largely linear: early TVs are rotated toward task-relevant subspaces to improve logits of relevant labels, while later TVs are predominantly scaled in magnitude. Taken together, LTVs not only provide a practical approach for obtaining effective TVs but also offer a principled lens into the mechanistic foundations of ICL.

Haolin Yang, Hakaze Cho, Kaize Ding, Naoya Inoue• 2025

Related benchmarks

TaskDatasetResultRank
Myopic choice evaluationComplex generation settings
Accuracy86.43
18
Representation Injection PerformanceLlama2-7B evaluation scenarios (test)
Accuracy85.16
18
Task Representation AccuracyTask Vector Evaluation Suite Llama2-13B (test)
Accuracy87.69
18
Language Model Accuracy EvaluationLLM Evaluation Scenarios
Accuracy81.37
9
Task Vector PerformanceLlama Baseline 3.2-3B
Accuracy78.65
6
In-Context LearningLlama3-8B Baseline (P={-1}, L={14})
Accuracy78.65
3
In-Context LearningLlama3-8B Scenario 1: Diff. Pos. (P={4})
Accuracy74.1
3
In-Context LearningLlama3-8B Scenario 2: More Pos. (P={-5,...,-1})
Accuracy78.18
3
In-Context LearningLlama3-8B Scenario 3: More layers (L={0,4,8,...})
Accuracy80.43
3
In-Context LearningLlama3-8B Scenario 4: More layers & Pos. (P={-5,...}, L={0,4,...})
Accuracy46.38
3
Showing 10 of 15 rows

Other info

Follow for update