Iterative Vectors: In-Context Gradient Steering without Backpropagation
Authors: Yiting Liu
Zhi-Hong Deng
Venue: ICML 2025 poster (2025)
Keywords: In-Context Learning
Activation Steering
Backpropagation-Free
Primary area: deep_learning->large_language_models
TL;DR: Iterative Vectors enhance in-context learning by editing activations in language models with simulated gradients, demonstrating significant improvements across tasks without backpropagation.

Abstract: In-context learning has become a standard approach for utilizing language models.
However, selecting and processing suitable demonstration examples can be challenging and time-consuming, especially when dealing with large numbers of them.
We propose Iterative Vectors (IVs), a technique that explores activation space to enhance in-context performance by simulating gradient updates during inference.
IVs extract and iteratively refine activation-based meta-gradients, applying them during inference without requiring backpropagation at any stage.
We evaluate IVs across various tasks using four popular models and observe significant improvements.
Our findings suggest that in-context activation steering is a promising direction, opening new avenues for future research.

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Yiting Liu'
Zhi-Hong Deng'
Abstract
Extraction
spred>
Application
spredo
In-context learning has become standard ap- proach for utilizing language models. However, selecting and processing suitable demonstration examples can be challenging and time-consuming, especially when dealing with large numbers of them. We propose Iterative Vectors (IVs), a tech- nique that explores activation space enhance in-context performance by simulating gradient updates during inference. IVs extract and itera- tively refine activation-bass meta geeta-gradients, ap- plying them during inference without requiring backpropagation at any stage. We evaluate IVs across various tasks using four popular models and observe significant improvements. Our find- ings suggest that in-context activation steering is promising direction, opening new avenues for future research.
Transformer Decoder
Layer n
Vec
Activation Edit
Layer
Veec 2
Layer
Vee 1
nice
movie
In
great
plot
In
Figure I. A general illustration of how activation vectors compared in this work improve ICL performance extracting and editing model activations.
and usability of ICL. Another issue with directly imple- menting many-shot ICL approach for LMs is the inherent constraint of context length. This limitation restricts the amount of information that can be provided to the model in single prompt, potentially hindering its ability to learn ef- fectively from numerous examples. Furthermore, in theory, the inference time increases quadratically as more examples are appended the query. If examples lengthy, it may be infeasible process them within the desired timeframe model context length.
1. Introduction
Few-shot learning has long been a prominent research fo- cus. Recently, language models (LMs) have demonstrated the capability for few-shot learning via in-context learning (ICL) (Brown et al., 2020). In this approach, learning new task involves conditioning on few support examples and predicting suitable tokens complete query input- all without requiring any parameter updates. This method is appealing because relies solely inference, allowing for quick adaptation to various downstream tasks.
In this paper, we introduce Iterative Vectors (IVs). new method for enhancing ICL. As illustrated in Figure 1, rather than staying in the discrete prompt space, IVs delve into the extensive activation space of the model. This exploration reveals a largely uncharted area for developing new methods, with pioneering efforts demonstrate how ICL be enhanced through the model's 's internal representations.
However, it has been noted that despite its potential, the predictions of LMs can be highly volatile when conditioned on prompts. The outcomes depend significantly on the tem- plates, demonstrations, and their permutations, and may even ignore violate the prompt's instructions (Webson & Pavlick, 2022; Min et al., 2022b). Consequently, such vari- ability introduces uncertainty, compromising the reliability
Iterative Vectors are computed by analyzing the difference between the attention activations of query pairs generated with and without preceding examples during inference. This process aims to capture the insights the model acquires from demonstration examples. These IVs are iteratively reinte- grated into the model to produce increasingly stable and effective vectors, progressively incorporating information from additional examples. The refined IVs can subsequently be applied to future inference tasks. This approach preserves the inherent structure of the ICL framework and introduces minimal computational and memory costs, ensuring both
'State Key Laboratory of General Artificial Intelligence, School of Intelligence Science and Technology, Peking University. Corre- spondence to: Zhi- Hong Deng <zhdeng@ pku.edu.cn>.
Proceedings of the ndnd International Conference Machine Learning, Vancouver, Canada. PMLR 267, 2025. Copyright 2025 by the author(s).

---

Iterative Vectors: In-Context Gradient Stecring without Backpropagation
practical efficiency and methodological scalability.
2.1. Activation Vectors
Our key contributions are summarized as follows:
The term activation vector serves as an umbrella concept encompassing lightweight vectors that manipulate language model within their representation space. Depending on im- plementation specifics, these vectors may interact with FFN layers, attention mechanisms, or both, and their positioning can vary. Task Vectors (Hendel et al., 2023) are extracted from one layer of the model during ICL inference and then applied a zero-shot query to determine whether they can preserve task-relevant information. Function Vectors (Todd et al., 2023), the other hand, select activations from the top attention heads based on their causal effect in generating the correct response. These selected activations are then averaged and introduced into a specific layer of the model.
A systematic framework for activation vectors in ICL. We formalize an evaluation framework tailored to activa- tion vector methods in ICL paradigm. To the best of our knowledge, we are the first to investigate the application of activation vectors on diverse real-world in-context learn- ing tasks. Within this framework, we adapt and rigorously benchmark two foundational activation vector techniques, revealing critical limitations in their direct applicability to ICL.
Iterative Vectors: gradient simulation without backprop- agation. We propose Iterative Vectors, novel activation vector method that uniquely simulates gradient-based opti- mization without backpropagation. We offer thoroughly derived theoretical foundation for our method, including both the formulas and the pseudocode, which are closely aligned with the evaluation framework. By taking this ap- proach, we effectively address a significant problem: en- hancing language model performance without the need for longer prompts.
A lthough these two methods are similar to our approach and objectives, they have primarily been tested on synthetic tasks (e.g., identifying antonyms, naming country capitals, providing plural forms), rather than ICL tasks with demon- strations. Consequently, the practical applicability of these vectors in real-world environments remains uncertain.
In contrast, our objective is to conduct evaluations within a more realistic context by utilizing real-world classification datasets. This approach provides a more thorough frame- work for assessing activation vectors. We have adapted and included these two methods for comparison to facilitate the practical application of activation vectors beyond theoretical constructs.
Empirical Validation and Insights. By iteratively refining task-specific perturbations through aggregation and aver- aging, IVs achieve an average performance gain of 3.2% over standard ICL baselines. Through further experiments on more challenging tasks, we demonstrate that IVs con- sistently excel in terms of accuracy, robustness, scalability and speed. Our analysis further uncovers the role of the interactive dynamies in the hyperparameters, demonstrating that IVs conduct principled simulations for gradient-based fine-tuning.
2.2. Generative Steering
Another research direction focuses on modifying LMs' acti- vations for generation and transfer purposes. Latent Steering Vectors (Subramani et al., 2022) aim at sentence recovery and sentiment transfer. Inference-Tine Intervention (Li et al., 2023) involves probing each attention head and guid- ing the model with the probe vector enhance the truthful- ness of the generated text. Studies by Turner et al. (2023) and Liu et al. (2024) address style and sentiment transfer by employing positive and negative sentence pairs to extract contrastive guidance.
Our code is available on GitHub.
2. Related Work
Several studies have investigated the manipulation of lan- guage models within the representation space by utilizing lightweight vectors, which we refer to activation steering with activation vectors in this paper.
Despite the shared similarities in operating within the rep- resentation space, these methods either necessitate training with backpropagation are restricted to transfer tasks in- volving sentence pairs. Consequently, it is not immediately clear how they should be integrated into the ICL setting, which we leave for future research.
Activation steering methods contrast with existing prompt tuning methods (Li & Liang, 2021; Lester et al., 2021), which operate in continuous parameter space as part of the prompt and which, crucially, require training via back- propagation.
Again, unlike Parameter-Efficient Fine-Tuning (PEFT) methods, e.g. LoRA (Hu et al., 2021), they do not tune model parameters but instead modify the activations during inference.
2.3. Cross-modal Vectors
The success of activation vectors has extended their appli- cation to visual and multimodal fields. Hojel et al. (2024) analyzed the activations of MAE-V VQGAN, identifying acti-
2

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
vations that encode task-specific information. Huang al. (2024) enabled language models perform multimodal, many-shot in-context learning by utilizing Multimodal Task Vectors. Peng et al. (2024) proposed Learnable In Context Vector, which learns task information from demonstrations.
output S2(2) E Rdou by
S2(x) = Wa + Attn( E,,))
(3)
where the parameters of the unnormalized attention operator Attn() (-) are, in order, the key, value, and query.
While the referenced research provides valuable interdisci- plinary perspectives, this study concentrates on linguistic phenomena. By introducing novel type of activation vec- tors, aim to enhance their analytical potential and create new opportunities for advancement across various fields.
It can be shown that S and S2 are equivalent by expanding the attention operation as
Attn(X, E,x) -X
Σ
e 2 T2
x.
(4)
3. Method
This expression elucidates that the forward operation of any linear layer in neural networks, trained via gradient descent, can be interpreted as a key-value-query attention mechanism (Vaswani et al., 2017). In this framework, the training data points act as the keys, the corresponding gradients serve as the values, and the test input generates the query.
In this section, we begin by establishing the theoretical foundation of our method. Following this, we outline the evaluation protocols clearly define the relevant notations. Finally, we present our method in detail.
3.1. Theoretical Foundation
Utilizing the dual form, ICL can be interpreted as a meta- optimization process (Dai al., 2023). This was achieved by reversing the direction of the equivalence and breaking down the attention key and value terms for the ICL. query token into its zero-shot and demonstration components, as formally expressed:
Given the significance of in-context learning, numerous theories have been proposed to explain its underlying mech- anisms, e.g., Xie et al. (2021); Chan et al. (2022); Ye et al. (2023); Oswald et al. (2023). One particularly intriguing hypothesis posits that a pretrained LM operates as a meta- optimizer, generating meta-gradients which it then applies to address ICL tasks. We now present an overview of this concept.
Fq) =ZZsL LitearAttn (WyX', WR X .9)
(5)
First, revisit the dual form of the perceptron and ap- ply it in the modern context of deep neural networks (Irie et al., 2022). Formally, assume a linear layer trained via gra- dient descent on T training inputs (Z1..... æT) and their corresponding (backpropagated) error signals (ei...., er), where 2, E dh and e Rd If standard gradient de- scent is applied, loss function produces the error signal e, (V
=W2sLq + Wyaa (Wwx)))* ()
(6)
-Wzsiq Σ ((Wva)) @ (WKo())
(7)
W + AWicL
(8)
(WzsL + AWICL) q.
(9)
where π) IR is the learning rate, and y: = Wx, is the output of the linear layer. Its weight matrix is given by
Here, WZSL = Wy (Wx is the zero-shot activa- tion from the static parameters of the model, in which X denotes the input representations of query tokens before the current one, q. X' denotes the input representations of the demonstration tokens.
T
W = Wo +
Σ e & Bti
(L)
where Wo E ddaa represents the initial value of the weights. This linear layer transforms an input x E Rd into an output Si (2x) E dha:
In summary, under the relaxed normalization setting, pre- trained LM acts as a meta-optimizer. Through forward computation, the LM generates "meta imeta-gradients" from the demonstration examples, which are then applied to the orig- inal parameters via attention, culminating in the formation of the ICL inference capability.
(z()) = Wx
(2)
Next, consider composite layer S2 that stores T key-value pairs, (I), e1) ..., (IT. eT), represented by key matrix X = (z)...., 2T) E xT and a value matrix = (ei...., eT) E XT along with a weight matrix Wo E ddu This layer transforms an input x E Th into an
This explanation provides an intuitive understanding of how the LM uses in-context examples. However, it also high- lights why ICL performance can be unstable: meta metaingraieetss derived from limited in-context examples may fail to fully capture the task and might not scale appropriately with
3

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Task
Episode E
Few-shol Sequence
A
Sample A
in
MA
sample
Figg
y
Sample B
In
VB
iterate
verbalize
Query
\n
infer
apply
Query
\n
infer
Zero-shot Sequence
apply
Vectors V
Tokens
Figure 2. An illustration of the extraction and application of Iterative Vectors. By subtracting the zero-shot component, we obtain the meta-gradients that represent the ICL adjustments. These are subsequently refined through successive iterations obtain the final vectors.
the original parameters. For this reason, we propose Itera- tive Vectors to extract the eeteegrraninssssiieiie activations induced by in-context examples-frome the lan- guage model's inference process to enhance its accuracy and robustness. This would also allow gradients directly in future inference tasks, eliminating the need to compute them afresh from the examples each time a query is evaluated.
contains two key components: the input-output separator that links question with its answer, and the example sep- arator that joins the given support set. To preserve the simplicity of the template, we choose to use one newline (An) for the input-output separator and three newlines for the example separator, as adopted in Min et al. (2022a).
the
apply these meta-
When the language model LM(-) is provided with an episode E, performs autoregressive inference on each of the tokens within the verbalized episode. The clean pre- diction of the language model is derived by applying the softmax function the logits on the potential labels pro- duced by the model, expressed in the following equation:
Before defining IV, necessary to establish the notations employed evaluate activation vectors.
3.2. Activation Vector Evaluation
adhere to standard few-shot benchmarking protocols (Vinyals et al., 2016; Finn al., 2017; Snell al., 2017) to define the activation vector evaluation setting. To assist read- with key terminology and concepts, comprehensive Glossary is included in Appendix A.
Jetean LM(E).
(11)
In contrast, an edited run involves the use of an activation vector editor fodn- The specific method of editing varies based on the chosen approach, and we express the general form as follows:
For a given split of an n-way k-shot classification task T (Train Tval: Twat. which comprises textual query-answer pairs (x. y), an ICL. episode is sampled as:
Jedit LM(E; Sedin
(12)
which depends on the of vectors V extracted by an acti- vation vector extractor, fex, with hyperparameters P:
= [(x1, "i),,.... (Fnxk, Bnxx), , (Zigs My)]-
(10)
Here, (I yd) represents the query and its label, preceded by the n support examples. To avoid the impact of unbalanced samples, we uniformly sample k examples from each of the classes and shuffle them to mitigate any bias arising from sample permutation. We maintain record of the labels for each example, which can be accessed using (x:) E (1, .,,,..,,,.44
V = (Tmin IP).
(13)
The extractor retrieves its target vectors V from Tuain and identifies the optimal hyperparameters Jp* from Teal by max- imizing the metric M:
F arg max MENTAI (Dodit UE)
(14)
The episode must first be converted into pure text sequence before the language model LM-() can process it. This con- version is handled by verbalizer, which uses a predefined prompt template instantiate the samples. The template
3 feul (Tramn P!)).
(15)
These formulations are presented to illustrate the general principle of activation vector extraction and application, and are therefore intentionally abstract, as their implementation requires flexibility.
The term borrowed from meta-learning, considering the meta-gradients play.

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
For single-token classification tasks, macro-Fl, micro-F1, and weighted-F1 scores serve the metrics. The vectors V and the optimal hyperparameters IP* are then applied to the test set Test to evaluate the final results MEnTTa (Wedn, v4)-
resulting in vectors for each class, plus a vector for the final query:
1
oa
A Acti(
(17)
|c
iEC
of = A Act)(ag) = Act((xg) - (xt)
(18)
3.3. Iterative Vectors
where Cj = {i Class(x;) j}. This process yields the veeta-gaadeent for a single episode
We have demonstrated that attention layers significantly influence ICL, with demonstrations acting as meta-gradients to help the model adapt to the task during inference. We define the extractor fex for Iterative Vectors based on this concept.
vf = {u) of ................................ o/).
(19)
By averaging across the task set under extraction, a prelimi- nary version of activation vectors can be obtained.
Episode Verbalization To extract the gradients, we construct two verbalized versions of a given n-- way k-shot episode E. The first version, E [xx1, vi),...,, (Inxk, Baxk), (xg. Ug]l. is the typical shuf- fled verbalization, which serves as the complete episode. The second version, E = [x }q)], is stripped of all demonstrations, resulting zero-shot query that provides no information about the task.
Iterative Refinement To refine these preliminary vectors, we introduce the concept of Iterative Vectors (IVs) by ap- plying the extracted vectors with the editor (fedi) during the extraction phase itself. This emulates standard batched gradient updates. We divide the training set Tuain into m sequential batches of size b, denoted Bi...., Bm. The it- erative extraction process computes sequence of batch vectors V V!...., V These are defined as sets containing the averaged vectors {v/, of) } for each layer I and class j or query q:
Input-output separators are responsible for generating the label words, which gather information and contribute to forming the final prediction (Wang et al., 2023), making the meta-gradients associated with them particularly important. These separators are integral to each I,, specifically as the last token of each, and the subsequent token, denoted as ys+ generated by the language model at the position of the separator token. Given their significance, to denote the activation from the 1-th attention layer of the i-th input-output separator. This generation process causally considers all preceding tokens, including all prior (z;, M+)
The vectors for the first batch B1 are calculated by averaging the base vectors Vf from each episode E E By:
V
VF
(20)
B
Act((r.) (I:))
EEB
For subsequent batches, the vectors Vi are computed by averaging episode-specific vectors obtained from episodes E E B,, where the language model's activations during extraction are edited by the cumulative average of vectors from all preceding batches, using the extraction strength o1;
demonstration pairs. Therefore, each (x;) has access to the information contained in all preceding pairs ((1))35) j < i} as well as the current ri.
1
Vi =
Wi
Eedic (V)),
(21)
Meta-gradient Extraction During inference on the two verbalized versions, the extractor collects activations, Act((;;) for the input-output separator of the i-th example in the complete episode E. as well as Act/( (Ix) of the query in the zero-shot query F", across each attention layer I of the LM.
B
EEB
1
Σ
V/
(22)
for i E (2...., m]. Here, V, [ (Vi-1 .a)] denotes
Subsequently, we subtract the zero-shot activations from the complete activations to select and extract the eeta-graddents representing the ICL adjustments. Since there are input- output separators for demonstrations in the zero-shot se- quence, all activations from the complete episode use the activations on the onput-output separator of the query as the subtrahend:
the set vectors extracted from episode E at layer when activations are modified according to Definition 25 using wi-1 with strength an, which will be defined below.
Finally, the extractor fea yields the Iterative Vectors by averaging the batch vectors across all iterations:
VI
Vi
(23)
A Actz(a;) = Actr( Act (x.g)
(16)
1=1
fext (Train: :P) = (V, LM}.
(24)
When & > 1, we average the activations for each class,
5

---

Iterative Vectors: In-Contex, Gradient Steering without Backpropagation
Model
Method
abort.
agnews
athei.
clima.
emoti.
femin.
hate
hilla.
irony
offen.
senti.
ss15
troe
Avg.
Clean
32.96
53.53
25.38
27.11
24.07
31.80
49.38
35.74
55.93
51.98
36.94
29.33
64.57
39.90
FV
37.29
51.53
32.86
21.19
17.78
37.87
38.84
30.96
55.09
51.16
41.81
31.91
67.02
39.64
gpt-j-6b
TV
29.83
60.89
20,50
24.62
25.49
31.72
49.74
33.75
48.32
48.
$1.61
38.82
32.94
63.72
39.38
IV (Ours)
36.06
56.13
32.05
19.23
32,70
38.20
47.30
40.68
54.65
46.32
33.17
39.07
67.32
41.76
Clean
27.52
61.94
22.13
28.60
54,45
29.27
53.27
29.42
58.65
$1.86
38.96
28.93
74.93
43.07
FV
25.11
67.56
14.58
23.70
58.66
31.01
52.57
32.26
60.44
$4.89
42.40
30.89
71.29
43.49
1lama-2-7b
TV
27.91
72.11
21.75
31.98
59.37
29.56
50.08
29.54
50.21
52.00
41.64
29.94
74.77
43.91
IV (Ours)
30.33
69.64
28,38
35.67
56.75
30.35
55.97
42.83
52.69
59.38
33.82
30.55
79.29
46.59
Clean
29.71
79.47
13.50
19.62
69.01
34,40
53.45
40.36
52.44
$6.46
38, 96
36.64
74.25
46.02
FV
29.21
83.84
15:27
18.87
68,94
34.65
55.34
34.13
55,34
$6.77
47.73
36.81
72.51
46.88
11ama-3.1-8b
TV
30.14
80.06
13.95
15.20
68.87
28.66
53.45
43.27
52.04
56.47
39.38
36.62
74.53
45.59
IV (Ours)
29.81
87.13
23.49
23.01
69.73
36.84
58.82
40.34
50.21
55,29
42.45
41.50
75.63
48.79
Clean
34,96
76.23
27.11
20.96
61.89
37.13
53.83
45.53
55.17
60.34
38.77
38.66
76.01
48.20
FV
36,55
77.37
27.25
19.71
66,73
43.35
50.57
51.16
51.26
58.94
46.15
42.72
72.57
49.56
1lama-2-13b
TV
34.71
76.28
27.24
30.88
63.27
31.87
52.63
45.03
54.98
60.14
37.82
37.98
77.05
48.45
IV (Ours)
35.32
79.07
27.32
38.19
67.40
46.20
57.18
50.13
66.76
59.09
35.88
44.14
80.93
52.89
Table 1. Main experiment results with macro-FI the metric. "Clean" denotes standard one-shot ICL result. The models GPT-J-6B
(Wang& & Komatsuzaki, 2021), Llama 2 (Touvron et al., 2023) and Llama 3.1 (Dubey et al., 2024). FV refers to Function Vectors (Todd al., 2023), while TV denotes Tasks Vectors (Hendel et al., 2023).
IV Editor We will now formalize the editor, feans for IVs. For the 1-th attention layer Attnr(-), let Vi denote its corresponding set of extracted IVs. During inference, the editing is performed on each of the input-output separators with the IVs from their corresponding classes, across all layers:
4. Experiments
Iterative Vectors can significantly enhance ICL performance, as demonstrated across four models and 13 diverse tasks (Section 4.1). Furthermore, IVs demonstrate significant time savings in achieving boosted one-shot performance (Section 4.2). They also effectively scale with the quantity of demonstration shots preceding the query (Section 4.3), Whether supplied with only a few or numerous examples for extraction, IVs consistently adapt to the given task, main- taining a trajectory of improved performance (Section 4.4), Finally, through ablating the hyperparameters of our method, we discover an optimal interaction among them that maxi- mizes performance, thereby affirming that each is essen- tial component of the methodology (Section 4.5).
(zitedA(tn(zz)) = A1; a x vi
(lass(a))
(25)
This introduces the strength hyperparameter a analogous to learning rates in gradient-based optimization, which con- trols the update magnitude. Given that meta-gradients tend to be less stable during the iterative process, we have differ- entiated a into two parameters: the extraction strength on and the inference strength 0z. These are applied during the iterative extraction and evaluation phases, respectively.
4.1. Main Experiment
The complete IV hyperparameter set is thus
We apply our IVs to four popular models across 13 tasks. The results are presented in Table 1. Details of all the datasets used in this paper can be found in Appendix E, while additional results with the other two metrics are pro- vided in Appendix F.
P = (k. a,,,
(26)
The extraction shot i controls the number of samples in sequence during the extraction process. The extraction batch size b serves to replicate typical batch size used during standard training. The extraction strength on denotes the magnitude with which meta gradienssss are applied during iterative extraction. Similarly, the inference strength 0:2 represents the magnitude with which meta- getaiggrassenss are applied during evaluation. These two parameters share the same notation because they fundamentally represent the same concept, albeit applied in different phases.
To offer further evidence and comparative analysis, we adapt two foundational approaches to activation vectors: Function Vectors (Todd et al., 2023) and Task Vectors (Hen- del et al., 2023). While these methods were not initially developed for the ICL evaluation setting, we modify them to incorporate the training set by averaging the activations. To ensure a fair comparison, we conduct a search over their respective hyperparameters, as well as the extraction shot parameter k. For detailed overview of their designs, please refer to Appendix G.
The pseudocode for the extraction and evaluation process is available in Appendix B. To facilitate understanding, Ap- pendix C includes an example of the processes described. A comprehensive discussion of hyperparameters is provided in Appendix D.
During testing, the model cannot ascertain the true class dis-
6

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Setting
I-shot
2-shot
3-shot
4-shot
1-shot FV
1-shot + TV
1-shot + IV (ours)
Macro-F1
9.13
12,90
12.64
13.11
10.77
10.30
12.90
Inference Time (s)
1374
2434
3426
4506
1389
1384
1452
Extraction Time (min)
438.3
14.58
23.75
Table Clean and activation vector results on the emoji dataset with model Llama-2-7b. Inference time measurements are based on 10,000 episodes, while extractions are based on 200 episodes.
Dataset
2-shot +IV
3-shot +IV
4-shot +IV
5-shot +IV
Clean
Diff
Clean
Diff
Clean
Diff
Clean
Diff'
AG News
76.86
79.94
+3.08
80.55
82,49 90.57
+1.94
82.12
84.82
+2.70
82.47
85.84
+3,37
Rotten Tomatoes
70.28
87.50
+17.22
78.97
+11.60
83.74
90.74
+7.00
87.80
91.48
+3.68
Table Multi-shot clean and IV results using the Llama-2-7b model. The displayed metric is macro-FI.
tribution of the test set due to the few-shot setting, which is often imbalanced. Therefore, we adhere to one-shot during the main experiment, 2 which supplies the model with min- imal yet sufficient information through set of uniformly distributed demonstration examples.
models. This indicates a promising potential for applica- tion to even larger models, as evidenced by our experiments with the Llama-2-70b model, detailed in supplementary experiment introduced in Section 4.3.
Task Vectors simply identifies the optimal layer for the extraction and application of vectors, which can serve as a simple baseline for future research. Although Function Vectors achieve relatively better results than Task Vectors, their high search time presents significant challenges for optimization in practical ICL applications.
We evaluate over 200 episodes for both extraction (Tusin) and hyperparameter search (Tvi). For the hyperparame- ters of IVs, we use a fixed iterative batch size of b = 10 and explore the extraction strength and inference strength 01, 02 E {0.1, 0.3, 0.5, 0.7, }.9} across all tasks. Regard- ing the extraction shot k we test & (1, 4) for both TVs and IVs. However, due to their inherent design, FVs are excessively slow to extract, making it impractical to incorporate additional examples. One significant issue with FV is that it necessitates an extensive search through all attention heads of every layer, posing considerable scaling challenges as the model size grows. Even when limited to k 1, extracting FVs takes approximately 20 times longer than extracting IVs. We present an example of the extraction time required in Table 2.
4.2. IVs Save Inference Time
All the aforementioned experiments require only a sin- gle demonstration example during application, demonstrat- ing that activation vectors can significantly reduce infer- ence time. To highlight this point, we turn to the emoji dataset, a 20-class classification task. Evaluating this dataset with multi-shot demonstrations would be exceedingly time- consuming due to the rapid increase in the length of the demonstration sequence.
All experiments were conducted using a predetermined ran- dom seed (42) to mitigate selection bias. To ensure a ro- bust representation of result distributions, the tests are aver- aged over substantial number of episodes, namely 10,000. All experiments can be performed on single Nvidia RTX A6000 GPU unless stated otherwise.
We apply IV this dataset and further fix the extrac- tion shot at k = rather than exploring the range k {1, 2, 4) to further minimize the time required for hyper- parameter search.
The results, presented in Table 2, clearly show that IVs substantially enhance performance with minimal time ex- penditure, in stark contrast to higher-shot ICL cases, which required significantly more time. In 2-shot and 3-shot set- tings, the inference times are 2,434s and 3,426s, respectively. However, IV achieves the same score of 12.90 as the 2-shot setting in 1,452-41%% faster-and exceeds the 3-shot per- formance (12.64). Crucially, IV reduces feature extraction time by 95% compared to FV (23.75 min vs 438.3 min), while maintaining a 20% performance advantage over TV (12.90 vs 10.30). While TV's naive architecture enables rapid extraction, this approach exhibits catastrophic failure in 50% of the model averages, as previously shown. This
The results indicate that Iterative Vectors successfully achieve the goal, surpassing the baselines in most individual tasks as well as in the overall average. For the overall av- erage, Iterative Vectors maintain robust performance gains in all evaluated scenarios, whereas FV/TV exhibit signifi- cant performance degradation compared to standard ICL in 37% of the cases (3/8) a concerning regression that under- mines their viability despite their computational overhead. Additionally, IVs show particularly strong results in larger
AA discussion regarding the decision not to use zero-shot se- quences is available in Appendix H.
7

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
positions IV the most time-effective solution, balancing accuracy with practical computational demands.
Episodes
Clean
5
Macro-F1
62.15
40.64
54.44
62.72
66.17
64.27
Episodes
20
30
50
100
150
200
4.3. IVs Scale with In-Context Demonstrations
Macro-F1
63.01
65.05
66.77
68.14
69.71
69.62
One might wonder why activation vectors are not applied to higher-shot settings. The primary reason is that key objective of using activation vectors is to reduce the prompt length and the inference time associated with higher-shot scenarios. Nonetheless, we conducted experiments to evalu- ate their performance with longer demonstrations.
Table 4, IV results with different number of extraction episodes, using fixed set of hyperparameters. The model utilized is Llama- 2-7b, and the dataset is AG News.
surpassing the traditional limits of ICL.
For this study, we have chosen the AG News and Rotten Tomatoes datasets. This selection is based on the observa- tion that the language model under evaluation demonstrates progressively improved performance as the number of ex- amples increases, as illustrated in Table 3. Consequently, this poses a more substantial challenge for the IVs to im- prove upon. However, the results demonstrate that IVs scale effectively with the number of demonstration shots preced- ing the query. IV boosts high baselines while maintaining ICL compatibility, delivering +3.37% AG News' near- peak 5-shot (82.47% to 85.84%) and +17.22% on Rotten Tomatoes' 2-shot (70.28% to 87.50%). Consistent gains across all shots (1-5) confirm its compatibility with the ICL framework. This suggests that IVs can offer advantages even when initial performance levels are already high, and they integrate seamlessly with the ICL framework.
4.5. Ablation Study
We conduct an ablation study to analyze the impact of key hyperparameters on our method's performance and dynam- ics. We focus particularly on the extraction batch size b, which was set to 6 = 10 in the experiments presented earlier. We analyze the results on the validation set, which is used to determine the optimal hyperparameters during tuning. The results are visualized in Figure 3.
Varying the extraction batch size reveals insights into the iterative refinement process.
No Iteration (b = 0) When b 0, the iterative update mechanism is effectively disabled. Extracted vectors not reintroduced into the model to influence subsequent ex- tractions. This configuration results in significantly poorer performance compared to any setting where 2 1. Fur- thermore, without editing during extraction, the extraction strength an becomes irrelevant as there no process for to control.
In addition, one could contemplate similar challenge using larger models. The results are comparable; please refer to Table 8, where the improvement of IV's is once again evident with 2-ab.-
Single-Episode Iteration (b = Setting b = 1 means each "batch" consists of single episode. While not true batching, this setting does enable the iterative refinement process where vectors extracted from one episode are used to edit the extraction from the next episode. This results in a substantial performance boost over the underscores the critical importance and contribution of the core Iterative Vectors concept the process of reintroducing and refining vectors across episodes, even without explicit multi-episode batch averaging before application.
4.4. IVs Improve with Increased Extraction Episodes
An important aspect to consider is the number of examples required for IVs to function effectively. We design an exper- iment to test various numbers of extraction episodes, which in turn controls the number of examples used to extract the IVs. Additionally, another critical aspect is the stability of IVs when extracted from different numbers of episodes. To evaluate this, reuse hyperparameters obtained from prior searches in the main experiment (k- = 4, b = 10 fixed, 0i = 0.3, 02 = 0.5), rather than optimizing hyperpa- rameters for each different episode count. The results are presented in Table 4.
case. This
Increasing Batch Size (b > 1) As the extraction batch size b increases beyond 1, we observe a general trend of improved performance. Examining the optimal hyperpa- rameter pairs (a1, a22) found during the validation search, we see that for small batch sizes (b 2 1), optimal solu- tions often involve high extraction strength (az) and relatively low inference strength (a2). This suggests that vectors extracted from smaller batches are less stable and require strong iterative refinement ( but must be applied cautiously during inference (a:2). As b increases, allowing averaging over larger groups of episodes before each itera-
The data shows that, IVs surpass ICL prompt limitations through scalable example utilization, delivering consistent gains with > 3 episodes (+0.57-7.6%% even under fixed, potentially suboptimal hyperparameters. While minor fluc- tuations occur with a smaller number of episodes (< 2), performance consistently improves with an increased vol- ume of examples. This demonstrates the IVs' capability to extract and utilize larger number of examples, thereby
8

---

These observed interactions between the extraction batch Iterative Vectors: In-Context Gradient Steering without Backpropagation
62.5
0-
51.5
46.0
58.4
53.1
-62.7
58.4
53.1
-2.77
58.4
Extraction Stringgth 4::
60.0
65
66
03
57.5
64
64
65
0.9 0.7 05
53.7
51.5
46.0
55.0
57.9
54.0
48.2
58.8
62
52.5
60
62.7
$9.8
53.7
51.5
46.0
64.7
64.9
63.0
-6.3
64.7
65.7
63.9 63.4
60
64.0
64.5
64.7
61.7
62.0
50.0
62.7
59.8
53.7
$1.5
46.0
47.5
66.0
65.5
65.3
57.4
34.7
60
-65.5
63.1
63.3
67.8 69.4
58
65.5
63.4
62.9
66.8
72.8
56
10
b= 50
b 100
Extraction Strength di
62.77
58.4
53.1
49.5
43.9
62.7
58.4
53.1
49.5
43.9
-62.7
58.4
53.7
49.5
43.9
62.7
$8.4
54.3
$1.0
43.9
600
0. 0.3
62.0
57.0
53.3
46,2
42.3
62.0
57.0
54.0
46
42.3
62.0
58.0
54.0
46.2
43.5
64
62.0
58.0
53.7
48
43.4
55
61.9
58.8
54.0
49.3
45.7
662.6
58.8
54.0
49.4
44.3
63
62.0
56.5
53.1
49.0
43.1
63
66.00
55,9
53.7
49.3
43.5
62
50
0.7
64.3
60.8
58.8
60.7
57.6
57.7
53.6
56,2
53.4
0.9
67.0
57.3
58.0
-6.3
54.9
-6.9
56.7
45
60
60
0.1
0.3
0.5
0.7
0.9
0.1
0.3
0.5
0.7
0.9
0.1
0.3
0.5
0.7
0.9
0.1
0.3
0.5
0.7
0.9
Inference Strengtth
Inference Strengtt
Inference Strength
Inference Strength
Figure 3. Ablation study the hyperparameters. The model utilized is Llama-2-7h, and the dataset evaluated is the validation split of AG indicates the absence of iterative refining and batching.
News, with macro-F1 serving as the metric. Note
tive update step, the extracted vectors become more stable. This increased stability is reflected in the optimal ag values, which tend to rise, enabling the method to leverage stronger inference strengths for better performance.
successively refining each batch's 's result with previous ones, IVs achieve greater stability and effectiveness than prior activation steering methods like Funetion Vectors (FV) and Task Vectors (TV).
Comprehensive experiments across four language models and 13 real-world tasks consistently showed IVs outperform standard ICL and existing baselines, with ablation studies confirming the iterative process's importance and the influ- ence of batch size and application strengths. These findings highlight IVs as a resource- efficcient, practical alternative to fine-tuning or prompt engincering, opening promising avenues for improving and adapting large language models by leveraging their rich activation spaces.
Excessively Large Batch Size While increasing batch size generally helps stabilize vectors, Figure also indicates diminishing returns. If the batch size becomes excessively large. performance may plateau or even decrease. We hy- pothesize that very large batches lead fewer total iterative updates over the training data (as m decreases), thereby reducing the opportunities for the vectors to be iteratively refined across different subsets of the training distribution. This suggests a trade-off between the stability gained by av- eraging over a larger batch and the benefits of more frequent iterative refinement steps.
Impact Statement
This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none which feel must be specifically highlighted here.
size (b). the extraction strength (az), and the inference strength (a:)) clearly demonstrate how each hyperparameter
plays crucial role in the overall dynamics and effectiveness of the Iterative Vectors methodology. For more compre- hensive discussion, including guidance on tuning these and other hyperparameters, please refer to Appendix D.
References
Barbieri, F., Camacho-Collede J., Espinosa Anke, L., and Neves, L. TweetEval: Unified Benchmark and Compara- tive Evaluation for Tweet Classification. In Cohn, T., He, Y., and Liu, Y. (eds.), Findings of the Association for Com- putational Linguistics: EMNLP 2020, pp. 1644-1650, Online, November 2020. Association for Computational www.:2....iinns-oooo
5. Conclusion
In this work, introduced Iterative Vectors (IVs), novel method for enhancing In-Context Learning (ICL) by refin- ing task-specific activation differences directly in a language model's ss activation space- space-without without backpropagation or pa- rameter updates. Our key innovation is an iterative refine- ment process: by splitting the extraction into batches and
Linguistics. doi: 10.
Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G.

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Askell, A., Agarwal, S., Herbert-Voss,, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., and Amodei, D. Language Models are Few-Shot Learners. In Advances in Neural Information Processing Systems, volume 33, pp. 1877- 1901. Curran Associates, Inc., 2020.
Dong, Q. Srinivasan, R., Ganapathy, R., Calderer, R., Cabral, R. S., Stojnic, R., Raileanu, R., Girdhar, R., Patel, R., Sauvestre, R., Polidoro, R., Sumbaly, R., Taylor, R., Silva, R., Hou, R., Wang, R., Hosseini, S., Chennabas- appa, S., Singh, S., Bell, S., Kim, S. S., Edunov, S., Nie, S., Narang, S., Raparthy, S., Shen, S., Wan, S., Bhosale, S., Zhang. S., Vandenhende, S., Batra, S., Whitman, S., Sootla, Collot, S., Gururangan, S., Borodinsky, S., Her- man, T., Fowler, T., Sheasha, T., Georgiou, T., Scialom, T., Speckbacher, T., Mihaylov, T., Xiao, T., Kar,, U., Goswami, V., Gupta, V. Ramanathan, V. Kerkez, V., Gonguet, V., Do, V., Vogeti, V., Petrovic, V., Chu, W. Xiong, W., Fu, W., Meers, W., Martinet, X., Wang, X., Tan, X. E., Xie, X., Jia, X., Wang, X., Goldschlag, Y., Gaur, Y., Babaei, Y., Wen, Y., Song. Y., Zhang, Y., Li, Y.. Mao, Y., Coudert, Z. D., Yan, Z., Chen, Z., Papakipos, Z., Singh, A., Grattafiori, A., Jain, A., Kelsey, A.,, Shajnfeld, A., Gangidi, A., Victoria, A., Goldstand, A., Menon, A., Sharma, A., Boesenberg, A., Vaughan, A., Baevski, A., Feinstein, A., Kallet, A., Sangani, A., Yunus, A., Lupu, A., Alvarado, A., Caples, A., Gu, A., Ho, A., Poulton, A., Ryan, A., Ramchandani, A., Franco, A., Saraf, A., Chowdhury, A., Gabriel, A., Bharambe, A., Eisenman, A.. Yazdan, A., James, B., Maurer, B., Leonhardi, B., Huang, B., Loyd, B., Paola, B. D., Paranjape, B., Liu, B., Wu, B., Ni, B., Hancock, B., Wasti, B., Spence, B., Stojkovic, B., Gamido, B., Montalvo, B., Parker, C., Burton, C., Mejia, C., Wang. C., Kim, C., Zhou, C., Hu, C., Chu, C.-H., Cai, C., Tindal, C.,, Feichtenhofer, C., Civin, D., Beaty, D.,, Kreymer, D.,, Li, D.. Wyatt, D., Adkins, D., Xu, D., Testuggine, D., David, D., Parikh, D.,, Liskovich, D., Foss, D., Wang, D., Le, D., Holland, D., Dowling, E., Jamil, E., Montgomery, E., Presani, E., Hahn, E., Wood, E., Brinkman, E., Arcaute, F.,, Dunbar, F.,, Smothers, F., Sun, F., Kreuk, F., Tian, F., Ozgenel, F., Caggioni, F., Guzmán, F., Kanayet, F. Seide, F., Florez, G. M., Schwarz, G., Badeer, G.. Swee, G., Halpem, G., Thattai, G., Herman, G., Sizov, G., Guangyi, Zhang, Lakshminarayanan, G., Shojanazeri, H. Zou, H., Wang, H., Zha, H., Habeeb, H., Rudolph, H., Suk, H., Aspegren, H., Goldman, H., Damlaj. I., Molybog, I., Tufanov, I., Veliche, I.-E., Gat, I., Weissman, J., Geboski, J., Kohli, J., Asher, J., Gaya, J.-B., Marcus, J., Tang. J., Chan, J., Zhen, J., Reizenstein, J., Teboul, J., Zhong, J., Jin, J.. Yang. J., Cummings, J.. Carvill, J., Shepard, J., McPhie, J., Torres, J., Ginsburg, J., Wang. J., Wu, K., U, K. H., Saxena, K., Prasad, K., Khandelwal, K. Zand, K., Matosich, K. Veeraragha- van, K., Michelena, K., Li, K., Huang, K., Chawla, K., Lakhotia, K., Huang. K., Chen, L., Garg, L., A, L., Silva, L., Bell, L., Zhang. L., Guo, L., Yu, L., Moshkovich, L.. Wehrstedt, L.., Khabsa, M., Avalani, M., Bhatt, M., Tsimpoukelli, M., Mankus, M., Hasson, M., Lennie, M., Reso, M., Groshev, M., Naumov, M., Lathi, M.. Keneally, M., Seltzer, M. L., Valko, M., Restrepo, M., Patel, M.,
Chan, S., Santoro, A., Lampinen, A., Wang, J., Singh, A., Richemond, P., McClelland, J., and Hill, F. Data Distri- butional Properties Drive Emergent In-Context Learning in Transformers. Advances in Neural Information Pro- December 2022.
cessing Systems, 1118888888888
Dai, D., Sun, Y., Dong, L., Hao, Y., Ma, S., Sui, Z., and Wei, F. Why Can GPT Learn In-Context? Language Models Secretly Perform Gradient Descent as Meta-Optimizers. In Rogers, A., Boyd-Graber, J., and Okazaki, N. (eds.), Findings of the Association for Computational Linguis- tics: ACI. 2023, pp. 4005-4019, Toronto, Canada, July 2023. Association for Computational Linguistics. doi: 10.18653/v1/2023 hindings-acl.220
Dubey, A., Jauhri, A.. Pandey, A., Kadian, A., Al-Dahle, A., Letman, A., Mathur, A., Schelten, A., Yang, A., Fan, A., Goyal, A., Hartshorn, A., Yang, A., Mitra, A., Sravanku- mar, A., Korenev, A., Hinsvark, A., Rao, A., Zhang, A., Rodriguez, A., Gregerson, A., Spataru, A., Roziere, B., Biron, B., Tang, B., Chern, B., Caucheteux, C., Nayak, C., Bi, C., Marra, C., McConnell, C., Keller, C., Touret, C. Wu, C., Wong. C., Ferrer, C. C., Nikolaidis, C., Al- lonsius, D., Song, D., Pintz, D., Livshits, D., Esiobu, D., Choudhary, D., Mahajan, D., Garcia-Olano, D., Perino, D., Hupkes, D., Lakomkin, F., AlBadawy, F.,, Lobanova, E., Dinan, E., Smith, E. M., Radenovic, F., Zhang, F,, Syn- naeve, G., Lee, G., Anderson, G. L., Nail, G., Mialon, G., Pang, G., Cucurell, G., Nguyen, H., Korevaar, H., Xu, H., Touvron, H., Zarov, I., Ibarra, I. A., Kloumann, I., Misra, I., Evtimov, I., Copet, J., Lee, J., Geffert, J., Vranes, J.. Park, J., Mahadeokar, J., Shah, J., van der Linde, J., Billock, J., Hong, J., Lee, J., Fu, J., Chi, J., Huang, J., Liu, J., Wang, J., Yu, J., Bitton, J.. Spisak, J., Park, J., Rocca, J.. Johnstun, J., Saxe, J., Jia, J., Alwala, K. V., Upasani, K., Plawiak, K., Li, K., Heafield. K., Stone, K., El-Arini, K., Iyer, K., Malik, K., Chiu, K., Bhalla, K., Rantala-Yeary, L., van der Maaten, L., Chen, L., Tan, L.. Jenkins, L., Martin. L., Madaan, L., Malo, L., Blecher, L., Landzaat, L.. de Oliveira, L., Muzzi, M., Pasupuleti, M., Singh, M., Paluri, M., Kardas, M., Oldham, M., Rita, M., Pavlova, M., Kambadur, M., Lewis, M., Si, M., Singh, M. K., Hassan, M., Goyal, N., Torabi, N., Bashlykov. N., Bogoychev, N., Chatterji, N., Duchenne, O., Çelebi, O., Alrassy, P., Zhang, P., Li. Vasic, P., Weng, P., Bhargava,
P., Dubal, P., Krishnan, P., Koura, S., Xu, P., He, Q.
10

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Vyatskov, M., Samvelyan, M., Clark, M., Macey, M.,, Wang, M., Hermoso, M. J., Metanat, M., Rastegari, M., Bansal, M., Santhanam, N., Parks, N., White, N., Bawa, N., Singhal, N., Egebo, N., Usumier, N., Laptev. N. P., Dong, N., Zhang, N., Cheng, N., Chernoguz, O., Hart, O., Salpekar, O., Kalinli, O., Kent, P., Parekh, P., Saab, P. Balaji, P. Rittner, P., Bontrager, P., Roux, P., Dollar, P., Zvyagina, P.. Ratanchandani, P., Yuvraj, P., Liang. Q.. Alao, R., Rodriguez, R., Ayub, R., Murthy, R., Nayani, R., Mitra, R., Li, R., Hogan, R., Battey, R., Wang, R., Maheswari, R., Howes, R., Rinott, R., Bondu, S. J., Datta, S., Chugh, S., Hunt, S., Dhillon, S., Sidorov, S., Pan, S., Verma, S., Yamamoto, S., Ramaswamy, S., Lindsay, S., Lindsay, S., Feng, S., Lin, S., Zha, S. C., Shankar, S., Zhang. S., Zhang, S., Wang. S., Agarwal, S.. Sajuyigbe, S., Chintala, S., Max, S., Chen, S., Kehoe, S., Satter- field, S., Govindaprasad, S., Gupta, S., Cho, S., Virk, S., Subramanian, S., Choudhury, S., Goldman, S., Remez, T., Glaser, T., Best, T., Kohler, T., Robinson, T., Li, T., Zhang. T., Matthews, T., Chou, T., Shaked, T., Vontimitta, V., Ajayi, V., Montanez, V., Mohan, V., Kumar, V. S., Mangla, V., Albiero, V., Ionescu, V., Poenaru, V., Mi- hailescu, V. T., Ivanov, V., Li, W., Wang, W., Jiang. W., Bouaziz, W., Constable, W., Tang, X., Wang, X., Wu, X., Wang, X., Xia, X., Wu, X., Gao, X., Chen, Y., Hu, Y., Jia, Y., Qi, Y., Li, Y., Zhang, Y., Zhang, Y., Adi, Y., Nam, Y., Yu, Wang, Hao, Y., Qian, Y., He, Y., Rait, Z., Veiioo, Z., Rosnbrick, Z., Wen, Z., Yang. Z., and Zhao, Z. The Llama Herd of Models, August 2024.
ceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 7038-7051, On- line and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguisties. doi: 10.1 11886//311/2222 122p:0022.mmmmmmmmm........
Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang. S., Wang, L., and Chen, W. LoRA: Low-Rank Adaptation of Large Language Models. In International Conference on Learning Representations, October 2021.
Huang, B., Mitra, C., Karlinsky, L.,, Arbelle, A., Darrell, T., and Herzig, R. Multimodal Task Vectors Enable Many- Shot Multimodal In-Context Learning. In The Thirty- eighth Annual Conference on Neural Information Pro- cessing Systems, November 2024.
Irie, K., Csordás, R., and Schmidhuber, J. The Dual Form of Neural Networks Revisited: Connecting Test Time Pre- dictions Training Patterns via Spotlights of Attention. In Proceedings of the 39th International Conference on Machine Learning, pp. 9639-9659. PMLR, June 2022.
Lester, B., Al-Rfou, R., and Constant, N. The Power of Scale for Parameter-Efficient Prompt Tuning. In Moens, M.-F., Huang, X., Specia, L., and Yih, S. W.-t. (eds.), Pro- ceedings of the 202/ Conference on Empirical Methods in Natural Language Processing, pp. 3045-3059, On- line and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.1 1...186//112211.mmll
24...243.
Feng, G., Zhang, B., Gu, Y., Ye, H., He, D., and Wang, L. Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspective. Advances in Neural Informa- tion Processing Systems, 36:70757-70798, December 2023.
Lhoest, Q., Villanova del Moral, A., Jernite, Y., Thakur, A., von Platen, P., Patil, S., Chaumond, J., Drame, M., Plu, J., Tunstall, L.,, Davison, J., Šaško, M., Chhablani, G., Malik, B., Brandeis, S., Le Scao, T., Sanh, V., Xu, C., Patry, N., McMillan A., Schmid, P., Gugger, S., Delangue, C., Matussière, T., Debut, I.., Bekman, S., Cis- tac, P., Gochringer, T., Mustar, V., Lagunas, F., Rush, A., and Wolf, T. Datasets: A Community Library for Natural Language Processing. In Adel, H. and Shi, S. (eds.), Pro- ceedings of the 2021 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 175-184, Online and Punta Cana, Dominican Re- public, November 2021. Association for Computational Linguistics. doi: 10. 10.11863/v1/1000 1666:///2222...mmmpddmmmm.2.2 .ennl--deoo221.
Finn, C., Abbeel, P., and Levine, S. Model-Agnostic Meta- Learning for Fast Adaptation of Deep Networks. In Pro- ceedings of the 34th International Conference on Ma- chine Learning. pp. 1126-1135. PMLR, July 2017.
Hendel, R., Geva, M., and Globerson, A. In-Context Learn- ing Creates Task Vectors. In Bouamor, H., Pino, J., and Bali, K. (eds.), Findings of the Association for Compu- tational Linguistics: EMNLP 2023, pp. 9318-9333, Sin- gapore, December 2023. Association for Computational Linguisties. doi: 10. 1055533/112223..ndnng--ss-e
Li, K., Patel. O., Viégas, F., Pfister, H., and Wattenberg, M. Inference-Tine Intervention: Eliciting Truthful Answers from a Language Model. Advances in Neural Information Processing Systems, 36:41451 415300 December 2023.
Hojel, A., Bai, Y., Darrell, T., Globerson, A., and Bar, A. Finding Visual Task Vectors. In ICMI. 2024 Workshop on Mechanistic Interpretabilityy June 2024.
Li, X. L. and Liang, P. Prefix-Tuning: Optimizing Continu- ous Prompts for Generation. In Zong, C., Xia, F., Li, W., and Navigli, R. (eds.), Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the I1 International Joint Conference on Natural
Holtzman, A., West, P., Shwartz, V., Choi, Y., and Zettle- moyer, L. Surface Form Competition: Why the Highest Probability Answer Isn't 't Always Right. In Moens, M.- F, Huang, X., Specia, I.., and Yih, S. W.tt. (eds.). Pro-

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Language Processing (Volume I: Long Papers), pp. 4582- 4597, Online, August 2021. Association for Computa- tional Linguistics. doi: 11116653/w12222..ccooon.....
and Bethard, S. (eds.), Proceedings of the 2013 Confer- ence on Empirical Methods in Natural Language Process- ing, pp. 1631-1642, Seattle, Washington, USA, October 2013. Association for Computational Linguistics.
Liu, S., Ye, H., Xing, L.,, and Zou, J. In-context Vectors: Making In Context Learning More Effective and Con- trollable Through Latent Space Steering. In Forty-First International Conference on Machine Leurning, June 2024.
Subramani, N., Suresh, N., and Peters, M. Extracting La- tent Steering Vectors from Pretrained Language Mod- els. In Muresan, S., Nakov, P., and Villavicencio, A. (eds.), Findings of the Association for Computational Lin- guistics: ACL 2022, pp. 566-581, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10. 86853////20222.nnninnn---- acl.48.
Min, S., Lewis, M., Zettleoyer, L., and Hajishirzi, H. MetaICL: Learning to Learn In Context. In Carpuat, M., de Marneffe, M.-C,, and Meza Ruiz, I. V. (eds.), Pro- ceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 2791-2809, Seattle, United States, July 2022a. Association for Computational Linguistics. doi: 10. 00.11653//1/20222.mrr m0..
Todd, E., Li, M., Sharma, A. S., Mueller, A., Wallace, B. C., and Bau, D. Function Vectors in Large Language Models. In The Twelfth International Conference on Learning Representations, October 2023.
Touvron, H., Martin, L.,, Stone, K., Albert, P., Almahairi, A., Babaci, Y., Bashlykov, N., Batra, S., Bhargava, P., Bhosale, S., Bikel, D., Blecher, L., Ferrer, C. C., Chen, M., Cucurull, G., Esiobu, D., Fernandes, J., Fu, J., Fu, W., Fuller, B., Gao, C.,, Goswami, V., Goyal, N., Hartshorn A., Hosseini, S., Hou, R., Inan, H., Kardas, M., Kerkez, V., Khabsa, M., Kloumann, I., Korenev, A., Koura, P. S., Lachaux, M.-A., Lavril, T., Lee, J., Liskovich, D., Lu, Y., Mao, Y., Martinet, X., Mihaylov, T., Mishra, P., Molybog, I., Nie, Y., Poulton, A., Reizenstein, J., Rungta, R., Saladi, K., Schelten, A., Silva, R., Smith, E. M., Subramanian, R., Tan, X. E., Tang, B., Taylor, R., Williams, A., Kuan, J. X., Xu, P., Yan, Z., Zarov, I., Zhang, Y., Fan, A., Kambadur, M., Narang, S., Rodriguez, A., Stojnic, R., Edunov, S., and Scialom, T. Llama 2: Open Foundation and Fine- Tuned Chat Models, July 2023.
Min. S.. Lyu, X., Holtzman, A., Artetxe, M., Lewis, M., Hajishirzi, H., and Zettlemoyer, L. Rethinking the Role of Demonstrations: What Makes In-Context Learning Work? In Proceedings of the 2022 Conference on Empiri- cal Methods in Natural Language Processing, pp. 11048 11064, Abu Dhabi, United Arab Emirates, December 2022b. Association for Computational Linguistics. doi: 1/666555//222222mmmmmmooo
Oswald, V., Niklasson, E., Randazzo, E., Sacramento, J.. Mordvintsev, A., Zhmoginov, A., and Vladymyrov, M. Transformers Learn In-Context by Gradient Descent. In Proceedings of the 40th International Conference on Machine Learning, pp. 35151-35111 PMLR, July 2023.
Pang. B. and Lee, L. Seeing stars: Exploiting class re- lationships for sentiment categorization with respect to rating scales. In Proceedings of the 43rd Annual Meeting on Association for Computational Linguistics, ACL '05, pp. 115-124, USA, June 2005. Association for Computa- tional Linguistics. doi: 10.31 10..111//219940.122990
Turner, A. M., Thiergart, U., and MacDiarmid, M. Activation Addition: Steer- ing Language Models Without Optimization, November 2023.
L.,, Udell, D., Leech, G., Mini,
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., ukasz Kaiser, L.,, and Polosukhin, I. Attention is All you Need. In Advances in Neural Informa- tion Processing Systems, volume 30. Curran Associates, Inc., 2017.
Peng, Y., Hao, C., Hu, X., Peng, J., Geng, X., and Yang, X. LIVE: Learnable In-Context Vector for Visual Question Answering. In The Thirty-eighth Annual Conference on Neural Information Processing Systems, November 2024.
Snell, J.. Swersky, K., and Zemel, R. Prototypical Networks for Few-shot Learning. In Advances in Neural Informa- tion Processing Systems, volume 30. Curran Associates, Inc., 2017.
Vinyals, O., Blundell, C., Lillicrap. T., kavukcuoglu, k., and Wierstra, D. Matching Networks for One Shot Learning. In Advances in Neural Information Processing Systems, volume 29, Curran Associates, Inc., 2016.
Socher, R., Perelygin, A., Wu, J., Chuang, J., Manning, C. D., Ng. A., and Potts, C. Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank. In Yarowsky, D., Baldwin, T., Korhonen, A., Livescu, K.,
Wang. B. and Komatsuzaki, A.
GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https::/ com/ kingoflolz/ mesh-transformer- jax, May 2021.
12

---

Iterative Vectors:
In-Context Gradient Stecring without Backpropagation
Wang, L., Li, L.,, Dai, D., Chen, D., Zhou, H., Meng, F., Zhou, J., and Sun, X. Label Words Anchors: An Infor- mation Flow Perspective for Understanding In-Context Learning. In Bouamor, H., Pino. J., and Bali, K. (eds.), Proceedings of the 2023 Conference on Empirical Meth- ods in Natural Language Processing, pp. 9840-9855, Sin- gapore, December 2023. Association for Computational main.609.
Linguistics. doi: 10. 1/2553/1/2023..mmmll
Wang, M., Smith, N. A., and Mitamura, T. What is the Jeop- ardy Model? A Quasi-Synchronous Grammar for QA. In Eisner, (ed.), Proceedings of the 2007 Joint Con- ference on Empirical Methods Natural Language Pro- cessing and Computational Natural Language Learning pp. 22-32, Prague, Czech Republic, June 2007. Association for Computational Linguistics.
Webson, A. and Pavlick, Do Prompt-Based Based Models Re- ally Understand the Meaning of Their Prompts? In Pro- ceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 2300-2344 Seattle, United States, July 2022. Association for Computational Linguistics. doi: 10. 10.18633/11/0222 maacl-mainn
Xie, S. M., Raghunathan, A., Liang, P., and Ma, T. An Explanation of In-context Learning as Implicit Bayesian Inference. In International Conference on Learning Rep- resentations, October 2021.
Ye, X., lyer, S., Celikyilmaz, A., Stoyanov, V., Durrett, G., and Pasunuru, R. Complementary Explanations for Ef- fective In-Context Learning. In Rogers, A., Boyd-Graber, J., and Okazaki, N. (eds.), Findings of the Association for Computational Linguistics: ACL 2023, pp. 4469-44444 44444, Toronto, Canada, July 2023. Association for Computa- tional Linguistics. doi: 10. 10.18653/v1/2023 2t055//v1/222...ndnngaeellll 273.
Zhang, X., Zhao, J., and LeCun, Y. Character-level Convo- lutional Networks for Text Classification. In Advances in Neural Information Processing Systems, volume 28. Curran Associates, Inc., 2015.
13

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
A. Glossary
Act(2;) Notation used to represent the activation vector extracted at the position the input-output separator token for the i-th example (z²) within a complete verbalized episode, capturing information from all preceding tokens.
(xg) Notation used to represent the activation vector extracted at the position of the input-output separator token for the query (xx)) within a zero-shot verbalized version of the episode (containing only the query).
Activation Vector(s) (V) A general term encompassing lightweight vectors derived from language model activations that are used to manipulate the model's behavior, typically by adding or modifying activations during inference. Iterative Vectors (IVs) are specific type of activation vector.
Activation Vector Editor (Sedit) A function or mechanism that applies extracted activation vectors to the language model's internal state (e.g., attention activations) during inference steer its behavior.
Activation Vector Extractor (Sext) A function or process that derives activation vectors (V) from a given dataset or set of examples, often involving hyperparameters (P)) The final Iterative Vectors are the output of the extractor (TTraini P).
Batch (B,) In the context of Iterative Vector extraction, a subset of the training episodes used in a single step of the sequential iterative process. The full training set is divided into n sequential batches BI,..., Bn.
Batch Vectors (V)) The set of activation vectors obtained by averaging the spiscfe-ppecifie vectors (VF)) from all episodes within a single batch B, In the iterative process, these batch vectors are computed sequentially, with extraction for batch potentially being edited by the cumulative average of vectors from previous batches.
Clean Prediction (Ueean) The standard output or prediction of the language model when processing an episode or query without any modification by an activation vector editor.
A (x; The difference between the activation at layer / for the input-output separator of the i-th example in the complete episode and the activation at layer for the input-output separator of the query in the zero-shot episode. Represents the ICL-induced activation difference.
Edited Run (jean) An inference pass where an activation vector editor modifies the language model's internal activations based extracted activation vectors.
Episode (E) In the context of activation vector evaluation, a single sample for ICL consisting of a set of support examples (I,, v) followed by a query example zq. arranged in a specific sequence.
Example Separator A token or sequence of tokens used in a verbalizer's 's template to separate individual demonstration examples from each other and from the query example within a prompt.
Extraction Batch Size (i) A hyperparameter in the iterative refinement process specifying the number of episodes included in each batch (B,) used during iterative extraction.
Extraction Episode (k) A hyperparameter specifying the number of support examples used in each episode sampled from the training set during the activation vector extraction process.
Extraction Strength (a,) A hyperparameter controlling the magnitude with which the cumulative average of previously extracted vectors (Vi-1) is applied to edit activations during the iterative extraction process.
Inference Strength (0:2) A hyperparameter controlling the magnitude with which the final, extracted Iterative Vectors (Train PP)) are applied to edit activations during the evaluation phase on the validation or test set.
Input-Output Separator token or sequence of tokens used in a verbalizer's template to link an input (e.g., a question)
with its corresponding output (e.g., an answer) within a demonstration or query example.
EE The set of class-specific (u/) and query (wf) activation vectors derived from a single episode E at layer using the base
subtraction method.
In the iterative extraction process for batch (i 2 2), this refers to the average of the vectors Vi...., Vi-1 computed from all preceding batches. This cumulative average is used to edit activations when extracting vectors from episodes
in batch i.
14

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
fedit (V:
a1)] The set of vectors extracted from single episode E at layer' I, obtained when the language model's activations during the extraction forward pass modified (edited) using the cumulative average of vectors from preceding batches (Vi-)) with the extraction strength (a1).
of The average A Act, vector for all examples belonging class within episode, representing the aggregated meta-gradient for that class at layer
of The Act, vector for the query example, representing the meta-gradient associated with the query itself at layer I.
Verbalizer component that converts structured data (like an ICL episode) into pure text sequence suitable language model, typically using a predefined prompt template with input-output and example separators.
B. Pseudocode
We present the extraction process in Algorithm 1. The evaluation procedures are defined in Algorithm 2. The episodic functions employed in the processes can be found Algorithm 3.
For information on our hyperparameters, please refer to the extraction shot k; batch size b, and strength an detailed in Algorithm 1. The inference strength, denoted as 022, is used in Algorithm 2.
C. Example
For instance, consider a 2-way (Positive/Negative) 2-shot task. verbalized episode (E) might look like this (using newline for input-output separator and triple newline for example separator):
great movie An Positive An\nin terrible book An Negative Anlnin hated it \n Negative AnInin amazing film \n Positive \nin)n loved that movie An
The zero-shot query (F") for the query input "loved that movie" is:
loved that movie An
Here, there are four support examples (two Positive, two Negative), followed by the query "loved that movic During inference on the complete episode E, we collect activations at the input-output separator token (the newline after "Positive". "Negative", "Negative". "Positive", and the newline after "loved that movie"). This done for each attention layer l. In parallel, collect the activation the input-output separator token (the newline after "loved that movie") from the zero-shot version E Let these activations be:
Act,("great movie"): Activation for the separator after the 1st support input (Positive) in E.
Acty Acty("terribbe ("terrible book"): Activation for the separator after the 2nd support input (Negative) E.
Acty("hated it"): Activation for the separator after the 3rd support input (Negative) in E.
Act ("amaziing film"): Activation for the separator after the 4th support input (Positive) in E.
("tlvel that movie"): Activation for the separator after the query input in E.
Act(("lovee that movie"): Activation for the separator after the query input E
Subsequently, we subtract the zero-shot activation Act, ("loved that movie"" from the complete activations to isolate the
15

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
ICL-induced component. For our 2-shot example, this yields five A Act; vectors layer l:
A ("great movie") = Actr("great movie") - Act, ("loved that movie")
A ("amaanng film") Actt ("amazing film") Acty ("loved that movie")
A ("terrree book") ("terriie book") A ("loved that movie")
A A"tz("hated it") = Acl, it") - ("Ilvvedeed that movie")
A ("loved that movic") = AActt""looee that movie") - AActf( ("loved that movie")
These A Act, values represent the change activation space attributable to the presence of the demonstration example(s) compared to the zero-shot baseline, specific to each example the episode.
As k 1, Equation 17 involves averaging the A Act, vectors for all examples within specific class to obtain the class-specife meta- meta-gradies graddiet vector 2/. For our 2-way 2-shot example, have two positive and two negative examples:
1
Positive
(A (c ("great movie") + A Acty("amaazing film"))
1
Negative
2
1
(A Aety("terr book") + A Act, ("hated it"))
The query vector of is simply the A Act, calculated for the query example:
of A Actoo"loved that movie")
This averaging aggregates the meta-gradiene geedienssss from multiple instances of the same class, yielding the set of vectors for this episode: vp- = {u Positive Negative
2i x/).
The iterative refinement process emulates batched gradient updates. Consider a total of 10 extraction episodes and a batch size b- 2, which gives us m 5 batches.
1. We process the first batch of b 2 episodes (B1). Extract V from these episodes without editing. V/ is the average of the v sets derived from the two episodes in B1.
2. We then process the second batch of b episodes (B2). During the extraction pass for each episode in B2, we use the already computed vectors V with strength a edit the model's activations specifically, by adding the relevant class/query vector from V the corresponding separator activations. The extractor then computes V. for each episode in B2 based on these edited runs, and averages them to produce V?.
3.
This continues for batches = 3,..., m. During the extraction pass for each episode in batch i, the model's activations are edited using the cumulative average of the vectors obtained from all preceding batches (Vi-1 7 ビド= V/ with strength a1. The extractor computes vf for each episode in batch i based on these edited runs, and averages them to produce Vj.
4. Finally, the extractor fex averages the vectors obtained from all batches: (V) + V? + V/ + refined set IVs for each layer.
Vi). This yields the
This process allows the vectors to be refined based on previous iterations, analogous to how model weights are updated in batches during training.
D. Hyperparameters of IV
In this paper, we introduce four hyperparameters: the extraction shot k. the extraction batch size b, the extraction strength a1 and the inference strength &2 These notations have been used consistently throughout the paper, including in formulas, pseudocode, and explanations. We now provide a detailed discussion of each hyperparameter and its function, followed by a guide on how to tune them effectively.
16

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
The extraction shot & controls the number of samples in a sequence during the extraction process. This originates from the definition of an n-way k-shot episode (Eq. 10). During extraction, longer support sequence may enhance the model's understanding of the task, thereby producing higher-quality meta-gradients. However, since adding more samples does not guarantee improved performance, and a larger & increases extraction time, we propose optimizing this hyperparameter through a search process.
The extraction batch size serves to replicate a typical batch size used during standard training. As implemented in Algorithm 1, the preliminary vectors extracted are averaged every b episodes to form the Iterative Vectors, which are subsequently incorporated into the extraction process. Unlike previous approaches that defer meta-gradient application, our method introduces them during extraction, enabling immediate feedback to the model's hidden states. This iterative refinement mechanism ensures that meta-gradients actively guide each forward pass of the LM, progressively refining intermediate representations and amplifying their influence on subsequent episodes. The result is a self-reinforcing cycle where meta- meta-gradients sharpen the contrast between zero-shot sequences and iteratively improve their own quality, driving robust representation learning.
In Section 4.5, we empirically validate the critical role of batch size b through ablation studies, demonstrating that optimal b selection yields measurable performance gains.
The extraction strength 0q denotes the magnitude with which meta-gradients are applied during iterative extraction. Similarly, the inference strength 02 represents the magnitude with which meta-gradients are applied during evaluation. These two parameters share the same notation because they fundamentally represent the same concept, albeit applied in different phases.
In the application of vectors, all methods evaluated this paper utilize vector addition. However, the meta-gradients may not scale properly with the original parameters. Therefore, we propose scaling them before incorporating them into the hidden states, consideration not derived from nor addressed in previous methods. During the iterative extraction phase, the scaling constant is at, whereas during evaluation, the constant is ag.
We differentiate the strength into two parameters because meta-gradients are less stable during the iterative process. This instability can accumulate across layers and episodes, so we aim to apply a lower strength during extraction, if necessary, to mitigate this issue.
Guide to tuning the hyperparameters. We recommend higher value of i for tasks in which the LM demonstrates greater proficiency. Exploring the range of (1, 4) is both straightforward and effective, as demonstrated in our experiments.
Concerning batch size, we have demonstrated that it should neither be too large nor too small. We recommend starting with b = 5 or b = 10. Methods for tuning typical batch sizes may also be considered.
Regarding the strength parameters a1 and a2 we performed a comprehensive grid search within the range (0.1, Future research is encouraged to employ more sophisticated search strategies, as these parameters often cluster in low-performance consecutive area (see Figure 3), which can be pruned if properly identified.
E. Datasets
A full list of all datasets utilized in this research, along with their corresponding access labels, is detailed in Table 5. The datasets are obtained from HuggingFace (Lhoest et al., 2021).
AG News (Zhang et al., 2015) is a subdataset of AG's corpus of news articles constructed by assembling titles and description fields of articles from the largest classes ("World"" "Sports", "Business", "Sci/Tech") of AG's Corpus.
TweetEval (Barbieri et al., 2020) introduces evaluation framework consisting of series of Twitter-specific classification tasks. We selected all single-token classification tasks from the dataset.
The Rotten Tomatoes dataset (Pang & Lee, 2005) is a collection of movie reviews and ratings from the Rotten Tomatoes website, often used for sentiment analysis and natural language processing tasks.
The SST5 dataset, derived from the Stanford Sentiment Treebank (Socher al., 2013), is collection of movie reviews
17

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Name
Abbr. Used
Huggingface Label
Abortion
abor.
wweet.eval/stance_abbrtt ag-news
AG News
agnews
Atheism
athe.
tweet eval/stance atheism
Climate
clim.
wweet.eval/stanceecline
Emoji
tweet_eval/emon
Emotion
emot.
swvet_eval/emotion
Feminist
femi.
eveeleeeal//t feminisst
Hate
hate
aweet_eval/hate
Hillary
hill.
tweeet.val/staacce.hille
Irony
irony
tweet eval/irony
Offensive
offe.
weveteevalooffensive
Rotten Tomatoes
rotten tomatoes
Sentiment
sent.
sreet_cvvl/sennmment
SST 5
sst5
SetFit/sst5
TREC
trec
trec
Table 5. The datasets and tasks employed, along with their corresponding abbreviations used in the result tables, and their respective labels as hosted on Hugging Face.
Model
Task
abort.
agnews
athei.
clima.
emoti
femin.
hate
hilla.
irony
offen.
senti.
ss15
Avg.
Clean
39.17
57.97
30.49
30.92
31.91
37.70
49.39
40.33
59.86
63.22
38.73
32.62
68.23
44.66
FV
51.93
55.39
45.81
24.89
29.62
54,20
45.48
58.97
57.30
58.25
41.77
37.37
69.70
48.51
gpt-j-6b
TV
51.52
65.86
23.72
32.84
32.85
37.64
49.74
37.89
48.32
60.05
40.23
35.60
64.75
44.69
IV (Ours)
60.02
61.30
44.59
20.49
37.36
49.05
48.32
55,29
56.30
46.94
34.48
40.08
67.32
47.81
Clean
28.69
63.40
24.90
34.88
$7.31
30.25
53.64
30.05
62.22
$3.67
40.02
43.08
77.33
46.11
FV
30.25
69.56
18.50
25.49
62,91
36.07
57.16
35.29
63.83
63.95
46.44
45.22
75.54
48.48
Ilama-2-7b
TV
29.31
72.97
24.50
62.14
62.52
30.47
50.09
30.14
52.86
$3.53
41.07
43.28
77.10
48.46
IV (Ours)
35.88
72.45
39.17
58.46
58,96
40.03
58.46
48.83
53.01
63,59
36.25
46.67
76.66 83
$2.97
Clean
39.18
80.64
18.14
21.26
74.06
47.17
53.66
48.14
53.96
60.12
39.01
45.25
69 69
50.02
FV
41.93
84.31
21.15
20.47
74.35
51.76
55.45
44.08
56,06
69.89
48.32
42.43
68.20
52.18
11mma-3.18bb
TV
39.07
81.12
18.55
20.21
74.47
40.21
53.47
50.33
53.67
60.35
39.13
43.04
69.62
49.48
IV (Ours)
44,25
87.30
36.33
22.33
77.70
56.57
58.84
56.07
52.23
69,20
42.83
48.85
70.24
$5.60
Clean
52.57
77.96
42.78
20.36
65.42
55.94
54,00
56.83
55.19
63.56
41.41
44.44
78.56
54.54
FV
53.16
78.81
48.92
19.57
69.99
64.96
58.94
62.25
52.32
70.70
47.87
49.19
76.58
57.94
Ilama-2-13b
TV
51.34
78.07
43.22
49.38
67.27
47.60
53.22
56.05
55.05
62.82
39.70
43.86
76.16
55.67
IV (Ours)
55.67
80.33
46.74
65.56
71.03
58.84
58.67
63.13
73.80
36.74
47.90
77.47
61.76
Table 6. Main experiment results with micro-F1 the metric.
"Clean" denotes standard one-shot ICL. result.
annotated with fine-grained sentiment labels, offering a five-class sentiment classification task ranging from very negative to very positive.
Text Retrieval Conference Question Answering (TrecQA) (Wang et al., 2007) is dataset created from the TREC-8 (1999) to 13 (2004) Question Answering tracks.
Our few-shot evaluation methodology employs episodic sampling to regulate the duration of both extraction and inference processes, rather than relying solely on the absolute number of samples. Consequently, not all available samples are utilized during the experimental procedures. This aspect underscores an additional dimension of efficiency inherent activation vectors.
F. Additional results
We present the results of our main experiment on the other two metrics, namely micro-F1 and weighted-F1, derived from our main experiment, in Table 6 and Table 7, respectively.
According to these evaluation criteria, IV outperforms both FV and TV in the majority of tasks, consistently achieving a higher average score. The only exception occurs in the GPT-J-6B and micro-F1 setting (Table 6), where FV demonstrates
18

---

Iterative Vectors: In-Contex, Gradient Steering without Backpropagation
Model
Task
abort.
agnews
athei.
clima.
emoti.
femin.
hate
hilla.
irony
offen.
senti.
sst5
Avg.
Clean
42.61
53.69
34,82
34.83
22.48
40.34
49.46
42.14
58.64
62.47
33.50
31.82
68.12
44.22
FV
52.83
51.62
50.11
31.38
17.29
52.93
35.96
47.47
57.23
59.41
39.82
35.19
69.86
46.24
gpt-j-bb
TV
49.48
61.07
26.01
34.19
22.74
40.30
49.79
39.49
48.21
60.68
34.78
35.52
65.18
43.65
IV (Ours)
56.37
56.16
48.98
15.48
33.59
50.39
46.26
52.34
56.49
48.88
32,98
40.08
68.38
46.64
Clean
30,58
62.03
27.50
38.72
$7.45
31.75
53.83
27.79
61.15
$6.07
35.33
34.46
77.58
45.71
FV
31.40
67.69
16,00
25.62
62.86
38.41
54.68
33.09
62,93
63.85
35.83
36.79
77.29
46.65
1lama-2-7b
TV
31.43
72.23
27.39
60.09
62,70
32.06
50.00
27. 27.66
52.57
55.85
39.36
35.39
77.27
48.00
IV (Ours)
38,90
69.75
44.22
59.10
59.02
41.32
57.46
50.01
51.86
65.18
27.70
36.94
78.22
52.28
Clean
40.92
79.37
15.32
13.97
73.77
47.66
53.04
48 62
50,70
62.16
36.04
40.44
70.66
48.68
FV
43,03
83,91
20.32
10.22
74.01
50,30
55.02
43.71
54.11
67.33
44.67
38.50
70.74
50.45
111mm-3.1-8b
TV
41.06
80.17
16.45
9.35
73.86
41.34
53.33
51.20
50.23
62.30
36.09
39.41
70.65
48.11
IV (Ours)
44,98
87.18
39.73
11.41
76.67
53.66
58,70
54.28
48.05
66.34
38.88
44.27
72.86
53.62
Clean
51.80
76.36
45.57
19.77
65.73
53.00
53.46
55.25
54.99
65.44
33.47
41.63
79.10
53.51
FV
52.92
77.47
49.87
22.99
70.76
60.23
53.47
60.28
49.71
68.68
41.76
46.51
78.98
56.43
1lama-2-13b
TV
51.32
76.43
45.95
51.92
67.44
46.91
51.91
54.67
54.63
64.78
32.12
41.10
77.07
55.10
IV (Ours)
53,93
79.17
48.74
63.85
71.40
59.55
58.32
58.96
67.31
69.96
35.51
46.82
79.27
60.98
Table 7. Main experiment results with weighted-F1 the metrie. "Clean" denotes standard one-shot ICL result.
Dataset
I-shot +IV
2-shot +IV
3-shot +IV
4-shot +IV
Clean
Diff
Clean
DifT
Clean
Difl'
Clean
Diff
AG News
86.96
88.17 17
+1,21
87.99
89.04
+1.05
87.87
88.84
+0.97
89.01
89.32
+0.31
Rotten Tomatoes
82.24
91.52
49.28
91.29
92.38
+1.09
92.39
93.13
+0..74
92.50
92.69
+0.19 19
Table Multi-shot clean and IV results using the Llama-2-70b model. The displayed metric macro-F1. Conducted on 3 Nvidia RTX A6000 GPUs
superior performance. We hypothesize that this result indicates a bias of FV towards the majority classes in this specific model. This bias results in an increased micro-F1 score; however, it causes the macro-F1 score to fall below the clean baseline, which is highly undesirable.
An additional experiment conducted utilizing the Llama-2-706 model. Due our computational budget constraints, it was not feasible to complete all tasks with model of this scale. Therefore, we opted to conduct multi-shot experiment, as described in Section 4.3 (Table 3), to more effectively showcase the efficacy of IV. The results are presented in Table 8.
G. Comparison of Methodologies
We will begin with an introduction to the motivation and functioning of FV and TV. Following this, we will offer comprehensive comparisons from various perspectives.
Function Vectors. Function Vectors (Todd et al., 2023) are inspired by the observation that incorporating activations extracted from few-shot tasks on the last token at specific layers can prompt an LM to execute a task when applied to an unseen zero-shot prompt. To distill a more effective hidden-state representation, the researchers limit their investigation to attention heads. This decision is based on the heuristic that attention heads are the components used by transformers to transfer information across different token positions. The researchers aim to identify attention heads that have a causal influence on predicting the desired label for a given task. The method for calculating this causal effect is outlined follows:
1. Compute the average activation aty of each attention head) j at layer é over task t.
2. Feed the ICL prompt o with shuffled labels into model f, and calculate the probability assigned to the target label f(7)).
3. Use one dt to replace the activation of its corresponding attention head, conducting a separate run for each instance. Subsequently, compute the edited probability for the target label again as f = =
4. The causal indirect effect on task t and the shuffled prompt P is calculated
CTE( I (.) f(pt ags = d'y)) - 1(1)
(27)
19

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
5. The average indirect effect is the average of the CIE across all tasks and prompts:
(a)
CIE(aE) P.).
(28)
LET
6. Gather the attention heads with highest AIE over all layers to serve as the activation source, forming set A.
The researchers represent the contribution of A single vector by taking the sum of their average outputs, over task, which is called a Function Vector for task t:
Σ
aij
(29)
agEA
To utilize FV, add it to the activation of the final token at a designated layer as the model processes a prompt.
One significant issue with FV is that it necessitates an extensive search through all attention heads of every layer, posing considerable scaling challenges as the model size grows. Theoretically, aside from the extraction time attributed to the extraction shot k, the extraction time of FV increases with additional complexity of O L H). Here, E represents the number of extraction episodes, L denotes the layer count of the LM, and H is the number of attention heads in each layer. For example, GPT-J-6B has total of 448 heads, while (-ama-2-131 has 1600. This increase alone more than triples the time required to extract the FVs, not to mention the slower computation resulting from a longer prompt and larger model size.
In contrast, Task Vector and our Iterative Vector do not encounter this issue and scale smoothly with larger models. During our experiments, we had restrict the extraction shot k for FV maintain practical search times and ensure fairness across all evaluated methods, mentioned in Section 4.
Task Vectors. Task Vectors (Hendel et al., 2023) offer a mechanistic perspective on ICL. This approach conceptualizes ICL as two-step process: first, a parameter vector is computed from the training sample, which is subsequently used to apply the "rule" defined by the vector to the query s.
There many possible realizations of the above framework. The researchers presume that a simple way for a transformer to achieve this is for the initial L layers to compute B. The remaining layers would take A and x as inputs to generate an output.
This provides a straightforward method to extract the language model's knowledge of a task and subsequently apply it. The process involves performing forward pass of the transformer and utilizing the previously extracted patch the L-th layer of the final token.
However, the boundary that separates this artificially divided two-stage process in the LM remains unclear and needs to be selected through empirical searching.
Comparison with Iterative Vectors. The theoretical attributes of our methodology, in comparison to the baseline models, are as follows:
FV and TV utilize their experiments to validate their respective hypotheses, rather than basing their methods on theoretical foundations.
Consequently, their editing processes are heuristic and rely on intuition.
Our proposed method is grounded in the meta-gradients derived from the demonstrations through the computation of the attention modules within the model.
This approach not only identifies where to make edits (the attention layers) but also specifies how to perform the edits (by performing meta- geta-gradieet updates via adding to the activations).
The extraction and editing process differs considerably for each method, as illustrated below:
20

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
FV examines all attention heads and aggregates the activations of the top-performing ones obtain the vectors, which is highly time-consuming.
TV simply identifies the optimal layer for the extraction and application of vectors.
IV processes the activations from different classes separately, conducting aggregation and application based on this separation. We also propose iterative updates and batched extraction for meta eeta-gradients, which have been proven to significantly enhance performance.
The hyperparameters specific to each method (instead of the evaluation framework) are as follows:
FV: the count of top heads |A| and the layer to apply the vector.
TV: the layer to apply the vector.
IV: extraction strength ar, inference strength 02, and iterative batch size b.
Please refer to Appendix D for a more detailed discussion on the hyperparameters of IV.
As a side note, we can see from the comparisons above that there is considerable flexibility in the design of activation vectors. We hope that our efforts will serve as a catalyst for further exploration and advancement in this line of inquiry, ultimately unlocking the full potential of activation vectors.
H. Concerning Zero-Shot Sequences
In both the FV and TV papers (Todd et al., 2023; Hendel et al., 2023), the vectors are utilized on zero-shot sequences. This aims to demonstrate the effectiveness of activation vectors in guiding the model as expected. The results confirm this: zero-shot sequences with activation vectors differ significantly from clean zero-shot runs. However, there remains noticeable gap between zero-shot applications and standard few-shot ICL performance, which appears difficult to bridge. For instance, in Figure 4 of the TV paper, all FV runs fall behind the few-shot runs across all models, despite the tasks being simple synthetic ones.
Previous research has suggested reasons that may account for this disparity. Feng et al. (2023) provide fundamental impossibility results, indicating that language models canmot solve increasingly complex tasks in single generation step. we view the demonstration sequence as an extension of the inference steps generated by the LM since the model treats all previous tokens equally, whether generated or provided-then without demonstrations, the LM's capabilities are significantly impaired. zero-shot attempt might not provide adequate computation for the language model address given task. Consequently, it might be overly optimistic to expect activation vectors to circumvent all necessary computations.
Furthermore, Min et al. (2022b) demonstrated the importance of informing the LM about the label space of the current task to enhance ICI. performance. In a zero-shot scenario, the model might struggle to focus its classification ability on the desired label, instead distributing it across the entire vocabulary space, as noted by Holtzman et al. (2021). This adds an extra burden for the model to extract meta meta-gradients and adjust accordingly.
Our early experiments real-world tasks also confirmed that activation vectors do not perform well in zero-shot setting. While there are some improvements, they remain inferior compared to the results achieved with even a one-shot approach. For synthetic experiments, these results may be adequate; however, to make activation vectors effective for practical applications, we must achieve better outcomes.
Table of the FV paper offers an insight: FV is applied not only to zero-shot sequences but also to "uninformative" sequences, which are essentially few-shot sequences with shuffled labels. These shuffled sequences nearly double the performance compared to their zero-shot counterparts on synthetic tasks, prompting us to begin our investigation from this point. However, since using shuffled sequence is not meaningful for our purposes, employ a correct one-shot sequence instead. The advantages of this approach include a basic guarantee of performance, along with the presence of input-output separators in the support samples, which further facilitate the application of the vectors.
Taking all of the above into account, we have decided to focus on enhancing few-shot performance rather than zero-shot. Nonetheless, we hope our research will enhance future studies on activation vectors, enabling them to more effectively address the shro scenario. This would represent a significant, albeit challenging, advancement.
21

---

Convert to prompt Iterative Vectors: In-Context Gradient Steering without Backpropagation
Algorithm Extraction Iterative Vectors
Require: extraction shot: k, extraction batch size: b, extraction strength: or)
Ensure: extracted Iterative Vector: V
V 2
Initialize the variable store the IV An empty list to store IV for each episode
2: IVs <
3: for the i-th episode do
4: Support, Query < RANDOMEPISODEEA)
Sample a k-shot episode > Shuffle and remember the classes
5: Order, Support + SHUFFLE(Support)
6: SupportAndQuerySSqquenee < VERRBALIZE(Support ( Query)
D Convert to few-shot prompt Convert to zero-shot prompt V,)))
7: QuerySequence + VERBALIZZE(uerr))
8: SupportAnn(Quurryeeccorrr + htwp::/wwww..pppaoaaaaeeeeerorne
9: Query Vector E
See Algorithm 3 for the episodic functions
10:
for each class of the task do
11:
the position(s) where order is equal to class
Collect by each class Average over shots
12:
o[class] < MEEANSSppprrAndQuueyyvettttt
Vector)
13:
end for
14:
u[QUERY] - SupporAuudQueryyecoor(UUUER Query Vector
D Collect the query as well Append the current episode's IV to the list Check the current episode multiple of batch size Update the IV to apply the average over episodes
15:
IVs - IVs U (w)
i mod 0 then
17:
V MEAN(IVS)
18:
end if
19: end for
Algorithm Evaluation
Require: evaluation shot R', extracted Iterative Vector: V, inference strength: classification labels: Results
Ensure:
1: Results + Ø
D> An empty list to store results for each episode
2: for the i-th episode do
3: Support, Query < RANDOMEPISODECE
& Sample an episode, typically with Shuffle to avoid patterned few-shot sequence
4: Support SHUFFLL(Supporr)
5: SupportAnnQQuerrSSquennee VEREAALIZESupport @ Query)
6: Logits +- APPLYSSuprrAAmnQueyySSqeuuuu a2)
Run the LM with editing
7: Results + Results U {ARGMAX(Logits)
> Calculate the classification result
8: end for
22

---

Iterative Vectors: In-Context Gradient Steering without Backpropagation
Algorithm Episodic Functions
1: function EXTRACT(sequencc)
Extracts activations from the LM
2: U+
3: run LM(squuecce with
Hook into the LM with the following operations
4:
for each layer in LM do
5:
p - the position of the input-output separator after the query - U u [Attn[p]}
6:
Store the activation of each attention layer
7: end for
8: end run
9: return
10:
end function
11: function APPLY(sequence, V, a:)
Apply IV to LM inference process
12:
run logits +- LM(sequence) with
for each layer in LM do
14:
for each support sample in sequence do
15:
p the position of the input-output separator after the sample
16:
c + the class of the sample
17:
Attn[p] <- Attn|p] + x V(c]
b Edit the separators the support sequence...
18:
end for
19:
p f the position of the input-output separator after the query
Attm/p] Attn[p] + V[QUERY]
> ...as well as the query
21:
end for
22:
end run
23: return logits
24:
end function
25: function APPLYANDEEXTRACCTTSqqenn, V, a)
b Apply the IV during extraction
4-6
run LM(sqquenc) with for each layer in LM do
28:
29:
if's V * Ø then
The first batch does not have V for editing
30:
for each support sample in sequence do
31:
p +- position of the input-output separator after the sample
c the class of the sample
33:
Attn jp] Attn[p]
V[c]
Edit (support)
34:
end for
35:
p +- the position of the input-output separator separatto after the query Attl|p] + Attn|p] + a x V[QUERY]
36:
Edit (query)
37:
end
38:
p - the position of the input-output separator after the query v [Aut[pp])
Extract and append list
40:
end for
41:
end run
42:
return
43: end function
23


Reviews:
[{"review_id": "xqpSyh5Hfq", "reviewer": "Reviewer_qbmE", "summary": "The paper addresses the challenges of selecting suitable demonstration examples in in-context learning (ICL) for language models. It proposes a novel technique called Iterative Vectors (IVs) to enhance ICL performance. IVs operate by extracting and iteratively refining gradients within a language model, which are then applied during inference, without requiring backpropagation. This approach improves the model's ability to learn from demonstrations. The authors ground their method in a theoretical framework derived from meta-optimization. The proposed method is verified through experiments on various tasks using four popular language models. The novelty of IVs lies in their ability to work within the activation space of language models to refine meta-gradients without backpropagation, offering a scalable solution to enhance language model performance.", "questions": "", "limitations": "", "rating": 4, "confidence": null, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "The claims made in this work were well supported.", "methods_and_evaluation_criteria": "Yes. The proposed method is well aligned with the research problem and solves the problem to some extent.", "theoretical_claims": "There is not much novelty in the theoretical analysis, as most of the work (e.g., meta-optimization process) is from prior work. But, I believe it is correct.", "experimental_designs_or_analyses": "The experiment design is comprehensive -- four models with 13 datasets. On most of the setups, the results show the effectiveness of the proposed method.", "relation_to_broader_scientific_literature": "Example selection, especially with a large pool of demonstrations, is a critical challenge for ICL. As pointed out by this paper, it can be connected to man", "essential_references_not_discussed": "NA", "other_strengths_and_weaknesses": "NA", "other_comments_or_suggestions": "NA", "questions_for_authors": "NA", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "vTov1CsxmZ", "reviewer": "Reviewer_ykmk", "summary": "The paper introduces Iterative Vectors, a technique that enhances in-context learning by simulating gradient updates during inference without backpropagation. IVs address the key ICL challenges: prompt sensitivity, context length limitations, and increased inference time by leveraging activation space rather than discrete prompts. By extracting and refining simulated gradients from attention activations, IVs improve model performance with minimal computational overhead.", "questions": "", "limitations": "", "rating": 3, "confidence": null, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "1. Thank you for your thoughtful review and engagement with our work. We acknowledge that certain technical aspects may require further clarification to ensure our contributions are clearly communicated. We will strive to refine our explanation by addressing the points raised.\n2. The term “activation vector” serves as an umbrella concept encompassing lightweight vectors that manipulate language model within their representation space (Lines 91–94). Depending on implementation specifics, these vectors may interact with FFN layers, attention mechanisms, or both, and their positioning can vary.\nFormulas 12 and 13 are presented to illustrate the general principle of activation vector extraction and application. These formulations are intentionally abstract, as their instantiations necessitate flexibility.\n**For IV, we have provided explicit explanations of all these concepts.** IVs are clearly defined in Formulas 21 (preliminary version) and 24 (final version) as a set of vectors. The position is specified in Line 262 for extraction (\"each attention layer $l$ of the LM\") and Line 306 for application (\"the $l$-th attention layer $\\text{Attn}_l(\\cdot)$\"). This is also directly deducible from the theoretical foundations.\n4. **We clarify that Figure 1 is not intended to demonstrate the proposed methodology.** As stated in its caption (“A general illustration of [...] activation vectors”, instead of IV), its purpose is solely to provide conceptual grounding for readers less familiar with activation vectors.\n**We explored incorporating the iterative aspect into Figure 2 during development.** However, this introduced significant visual complexity that risked obscuring the core concept, which the reviewer already find challenging to grasp. We reasoned that readers familiar with gradient-based training processes—where iterative steps are inherently extrapolated from single-step mechanics—would find the progression to an iterative framework intuitive. For full transparency, the iterative procedure has been relocated and is rigorously detailed in Algorithm 1.\nThat said, we thank the reviewer for this feedback and acknowledge the value of visual documentation. We will revise the figure to include the iterative process in the final version.\n5. **This subtraction becomes readily apparent through the theoretical development in Section 3.1.** As demonstrated in Formula 9, in-context demonstrations function analogously to meta-gradients, decomposing the activation during inference into two components:\na) Zero-shot activation: The baseline behavior inherently generated by the language model for a given query.\nb) ICL-derived meta-gradients: Task-specific updates learned from in-context demonstrations.\nBy isolating and subtracting the zero-shot component (which is constant across inference passes for the same query), we select and extract the meta-gradients representing the ICL adjustments. This ensures that only the refined updates—not the baseline behavior—are applied to subsequent inferences.\nFurthermore, consider the activation's magnitude. Our approach involves adjusting it in our desired direction using potentially small amounts of meta-gradients. Without the subtraction, the process reduces to simply adding raw activations from one run to another, which could confuse or potentially overwhelm the model.\n6. As defined in Line 259, $\\text{Act}(x_i)$ represents the activation for the $i$-th input-output separator. These separators are integral to each $x_i$, specifically as the last token of each, and the subsequent token, denoted as $y_i$, is generated by the language model at the position of the separator token. This generation process causally considers all preceding tokens, including all prior $(x_i, y_i)$ demonstration pairs. **Therefore, by definition, each $\\text{Act}(x_i)$ has access to the information contained in all preceding pairs $\\{(x_j, y_j) \\mid j < i\\}$ as well as the current $x_i$.**\nNext, regarding \"different demonstrations,\" we assume the reviewer intended to refer to either:\na) distinct $(x_i, y_i)$ pairs within a single prompt, as discussed previously, or\nb) separate prompts with various sets of example prefixes. This is pertinent to the iterative refinement process, where additional demonstrations are integrated.\n7. **The proposed method is applicable to generative tasks.** However, incorporating it would further complicate the evaluation framework and comprehension. Therefore, we have decided to address this in future work.\n8. To address this issue, we conducted an additional experiment, testing Llama-3.1-8b on `ag_news` with a near-upper-bound few-shot selection baseline (200 selections $\\times$ 200 validations = 40,000 episodes, twice as many as IV's setup). **Its macro-F1 score of +6.87 still underperformed compared to IV’s +7.66 by 10%**, demonstrating IV’s superiority even against extensive demonstration tuning.\n\nWe value your expertise and look forward to addressing any remaining questions.", "claims_and_evidence": "Yes.", "methods_and_evaluation_criteria": "The evaluation datasets are limited to classification tasks, which is not general for current scenarios under LLM-era.", "theoretical_claims": "Not fully applicable.", "experimental_designs_or_analyses": "Yes.", "relation_to_broader_scientific_literature": "This paper proposes to leverage the activation vectors to enhance text-classification tasks of LLM.", "essential_references_not_discussed": "Probably no.", "other_strengths_and_weaknesses": "Strengths:\n1. The motivation is intuitive to use IVs to extract and iteratively refine the gradients within a language model, which can enhance LLM ICL capability.\n\nWeaknesses:\n1. The paper's writing is unclear and difficult to understand, making it challenging to follow the main ideas.\n\n2. Several crucial terms are not well-defined. For example, the concept of the activation vector is ambiguous—what exactly does it refer to? Is it related to the FFN activation or the attention activation? Does it appear before or after layer normalization (LN)? Additionally, the paper lacks explicit formulations for these concepts.\n\n3. Figure1 and Figure2, which are meant to illustrate the proposed method, but it does not capture the iterative nature of the approach. Given that iteration is central to the method, this omission is significant.\n\n4. In line 264, the paper does not provide a clear explanation for why the zero-shot activation is subtracted. This omission makes it difficult to understand the motivation behind this step.\n\n5. The notation Act(x_i) appears multiple times throughout the paper, but it is unclear whether it considers only x_i or also incorporates y_i. Additionally, when computing activation values for different demonstrations, does the method take into account activations from other demonstrations? This needs clarification.\n\n6. The proposed method is only applicable to classification tasks, whereas in the current LLM era, generative capabilities are more crucial. This limitation significantly reduces its practical relevance.\n\n7. Since the proposed method requires selecting optimal hyperparameter (P), a fair few-shot baseline comparison should be considered,  where selecting the relatively better few-shot demonstrations.", "other_comments_or_suggestions": "No.", "questions_for_authors": "No.", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "939DnKGIy7", "reviewer": "Reviewer_u1JW", "summary": "This paper introduces Iterative Vectors (IV), a method for steering in-context learning (ICL) by modifying model activations without requiring parameter updates.\nWhile activation steering has been explored in various contexts, its application to ICL appears novel.\nIV consists of two key steps: first, \"activation vectors\" are extracted by computing differences in activations between few-shot and zero-shot scenarios in an iterative process similar to batched gradient descent.\nThen, these activation vectors are used to modify the model's attention values during test-time evaluation.\nExperiments demonstrate the effectiveness of IV on multiple ICL tasks.", "questions": "", "limitations": "", "rating": 4, "confidence": null, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "We are delighted that the reviewer described our method as \"conceptually simple\" and \"useful for practical use.\" We are committed to improving clarity in line with their suggestions.\n\nWe will condense Section 3.1 and utilize the space to introduce the verbalizer, while relocating some of the discussion on hyperparameters to the main body of the manuscript in the final version. We appreciate the suggestion to incorporate some examples in relevant parts and agree that it would be advantageous.\n\nRegarding the results, we note that the term \"impressive\" does not appear in our manuscript. We interpret this quotation as a positive indication of the reviewer’s assessment and sincerely thank their acknowledgment. Nevertheless, we will elaborate on the significance of our results while **also addressing Reviewer KR8h's concerns**, particularly their issues regarding Claim 2.\n\nThe averaged metrics in Table 1 represent rigorous evaluation across 13 distinct benchmark tasks, systematically demonstrating IV's cross-task proficiency. To enhance interpretability, we now focus our presentation on the mean relative performance gains compared to the fundamental ICL baseline, intentionally omitting exhaustive task-specific data to highlight core comparative insights.\n\n| Model | gpt-j-6b | llama-2-7b | llama-3.1-8b | llama-2-13b | Average |\n|---|---|---|---|---|---|\n| FV | *-0.26* | 0.42 | 0.86 | 1.36 | 0.60 |\n| TV | *-0.52* | 0.84 | *-0.43* | 0.25 | 0.04 |\n| IV (Ours) | **1.86** | **3.52** | **2.77** | **4.69** | **3.21** |\n\n1. **The improvements in IV are significant, whereas FV and TV lag considerably behind.** Our method demonstrates superior performance across all models, achieving an average relative score of 3.21—5.4x higher than FV (0.60) and 80x greater than TV (0.04).\n2. **The performance of IV scales with increased model capacity.** IV consistently outperforms baseline methods in every model configuration, with particularly strong results in larger models (4.69 vs 1.36/0.25 for llama-2-13b). This indicates a promising potential for application to even larger models, as evidenced by our experiments with the Llama-2-70b model, detailed in the supplementary experiment in Table 8.\n3. **While FV/TV demonstrate limitations in practical applications, IV consistently excels across real-world tasks.** IV maintains robust performance gains in all evaluated scenarios, whereas FV/TV exhibit significant performance degradation compared to standard ICL in 37% of the cases (3/8)—a concerning regression that undermines their viability despite their computational overhead. This empirical evidence directly refutes Reviewer KR8h's skepticism by demonstrating that FV/TV's shortcomings extend beyond synthetic environments to critically impact real-world effectiveness.\n4. **Table 2: IV achieves optimal efficiency without compromising performance.** In 2-shot and 3-shot settings, the inference times are 2,434s and 3,426s, respectively. However, IV achieves the same score of 12.90 as the 2-shot setting in 1,452s—41% faster—and exceeds the 3-shot performance (12.64). Crucially, IV reduces feature extraction time by 95% compared to FV (23.75 min vs 438.3 min), while maintaining a 20% performance advantage over TV (12.90 vs 10.30). While TV's naive architecture enables rapid extraction, this approach exhibits catastrophic failure in 50% of the model averages, as previously shown. This positions IV as the most time-effective solution, balancing accuracy with practical computational demands.\n5. **Table 3: IV boosts high baselines while maintaining ICL compatibility**, delivering +3.37% on AG News’ near-peak 5-shot (82.47%→85.84%) and +17.22% on Rotten Tomatoes’ 2-shot (70.28%→87.50%). Consistent gains across all shots (1-5) confirm its compatibility with the ICL framework.\n6. **Table 4: IVs surpass ICL prompt limitations through scalable example utilization**, delivering consistent gains with ≥3 episodes (+0.57–7.6%) even under fixed hyperparameters. While minor fluctuations occur with fewer episodes (≤2), performance robustly scales with example volume, proving IVs extract value beyond conventional ICL ceilings.\n7. **Figure 3: The hyperparameter interactions enable adaptive optimization.** Larger batches enable the utilization of refined vectors through increased inference strength ($\\alpha_2$). Incorporating iterative refinements yields significant gains, demonstrating their essential role in our contribution.\n\n**In summary, IV demonstrates consistent superiority** across three critical dimensions: (1) **performance** (3.21 average gain vs 0.60/0.04 for FV/TV), (2) **efficiency** (95% faster extraction than FV, near-ICL inference speeds), and (3) **scalability** (robust gains from higher-shot settings and more demonstrations). We affirm that IV represents a practical, theoretically grounded advance for activation vectors, with broader implications for resource-efficient NLP.", "claims_and_evidence": "Yes", "methods_and_evaluation_criteria": "Yes", "theoretical_claims": "Yes", "experimental_designs_or_analyses": "Yes", "relation_to_broader_scientific_literature": "This would help improve in-context learning via steering.", "essential_references_not_discussed": "Not that I'm aware of.", "other_strengths_and_weaknesses": "Strengths:\n* IV appears conceptually simple, which would be useful for practical use.\n* IV has a consistent improvement over the evaluated baselines.\n\nWeaknesses:\n* Section 3.1 is a summary of what is generally believed in the ICL community. While some discussion is important, I suggest keeping it compact.\n* Because I find IV \"conceptually simple\", I expect it to perform much better compared to the baselines. To that end, I encourage the authors to clearly describe why the results in Table 1, Table 2, Table 3, etc are \"impressive\".\n* My primary reservation is technical clarity, and I will point out some areas for improvement in the Other Comments section.", "other_comments_or_suggestions": "Below, I list some areas where clarity could be improved. I do not expect (nor encourage!) the authors to respond to each point. Rather, these are things to keep in mind for future manuscript revisions.\n* I found Figure 2 hard to understand.\n* Section 3.1 could be significantly shortened. I am confident (with some creativity) that one or two figures with possibly some very carefully chosen equations could effectively communicate the same message.\n* Better introduce what a \"verbalizer\" is (Line 205).\n* Section 3.2 and Section 3.3 would both benefit from having more examples. I am also suspicious about the value of a big \"Algorithm 1\" in the main paper. It may be more instructive to have this algorithm \"defined by example\", such as through smaller figures + examples.\n* Would be good to mention what \"FV\" and \"TV\" are in the Table 1 caption.\n* Line 270: it took me a long time to figure out how the activation vector is computed.\n* Line 318: The relation between $\\alpha$, $\\alpha_1$, and $\\alpha_2$ are not immediately clear. The authors could consider briefly discussing how both hyperparameters are used mathematically.", "questions_for_authors": "N/A", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "MXl7rZRbOc", "reviewer": "Reviewer_KR8h", "summary": "The paper proposes Iterative Vectors, inspired by the framing of in context learning as simulated gradient updates. The method extracts activations derived from in-context learning examples and adds the activations to unseen queries. The method also refines these updates by averaging the activations from many sets of examples. Finally, the paper compares the proposed method with prior work in activation vectors on real-world language tasks, including tweet classification.", "questions": "", "limitations": "", "rating": 2, "confidence": null, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "We thank the reviewer for their feedback and the opportunity to reflect. We believe the concerns raised warrant clarification to ensure a balanced perspective.\n\n## Claim 1\n\n1. We do not intend to assert that \"gradient simulation\" is, in itself, a novel concept. We respectfully request the reviewer to consider the following points. Reviewer u1JW observed that \"while activation steering has been explored in various contexts, **its application to ICL appears novel**.\" Additionally, Reviewer qbmE summarized that \"the novelty of IVs lies in their ability to work within the activation space of language models to refine meta-gradients without backpropagation, **offering a scalable solution to enhance language model performance**.\"\n2. We do not present the theory from Dai et al. [1] as our own contribution (stated in Lines 58, 68, and 78). Rather, we use it as **inspiration and a foundation** for developing our method (see Line 71).\n3. **A comprehensive and equitable evaluation framework, which represents one of our key contributions, is absent in both FV and TV.** These studies utilize diverse designs for extraction rationale, hyperparameter selection, and editing strategies. It is essential to quantify these elements fairly while maintaining flexibility within a new, unified framework. **Establishing such an evaluation framework is a significant undertaking and cannot be accomplished merely by \"rewriting the formalism.\"**\n4. The reviewer observed that Dai et al. have already validated their theories concerning gradient simulation. As established by the derivation of IV in our work, **our approach builds upon their concept of meta-gradients, which is tautological to our claim being \"grounded in the idea of meta-gradients\".** As IV aligns with and builds upon this foundation, replicating such validated theoretical groundwork would be a duplication rather than a meaningful contribution to the field.\nOur focus is on demonstrating that IV’s effectiveness in practical settings does not hinge on replicating idealized or approximated scenarios, e.g., unnormalized attention approximation employed in Dai et al. It is important to highlight that strict adherence to simulation-based validation risks conflating theoretical approximations with the robustness of our method in real-world deployments. Our framework’s success in tackling complex tasks—validated empirically—underscores that IV’s utility transcends the need for such simulations.\n\n## Claim 2\n\nOn real-world tasks, FV shows only marginal improvements and requires an excessive amount of time (up to 20x longer), making it impractical. TV performs inadequately, failing 50% of the models on average. In contrast, IV consistently excels in performance, efficiency, and scalability. **Please refer to our response to Reviewer u1JW for details.**\n\n## Weaknesses\n\n1. It is common practice to assume the theoretical foundation established in previous work to be valid, and our experimentation partly serves to further validate these hypotheses. Given that IV and the two baselines belong to the same family of methods—namely, activation vectors—**one would naturally expect similarities in form**.\nIn Appendix E, we have thoroughly distinguished how **IV differs from the methodologies introduced by Todd et al. [2] and Hendel et al. [3] in terms of theoretical support, extraction and editing processes, scaling efficacy, and other aspects**. We are perplexed by the reviewer's comment, particularly given their claim to have read Appendix E, and we find it difficult to understand why the new insights we provided have been overlooked.\n2. Please refer to the discussion of Claim 1 above.\n3. With all due respect, we cannot concur with this assessment. The fact that the iterative updates and batched extraction incorporate an averaging operator **does not render them \"similar\" to basic averaging**, nor does it diminish their novelty and significance as part of our method. First, they naturally derive from the gradient simulation, and second, they play a crucial role in the dynamics of our method, validated through ablative studies (Section 4.5 and Figure 3). **This is not observed in Todd et al.**, where the activation of certain attention heads is merely averaged without being reintegrated into the model for refinement, thus completely lacking the iterative and batched update elements.\n4. Our analysis of scaling in Sections 4.3 (IVs Scale with In-Context Demonstrations) and 4.4 (IVs Improve with Increased Extraction Episodes) is not intended as a novel contribution or exploration. Instead, it serves as part of our validation process to rigorously assess the robustness and consistency of our method, as indicated by the section titles. **The similarity in the validation process is not a weakness; rather, it demonstrates alignment with established methods [4].**\n\nWe hope this clarification underscores the methodological and empirical significance of our contributions to enhancing LM capabilities.", "claims_and_evidence": "- Claim 1. The method simulates gradient updates.\n    - This claim is not novel, nor is it justified with appropriate evidence.\n    - The paper reiterates the argument from Dai et. al., 2023 that in-context learning can be perceived as a meta-optimization process (the application of the original weight matrix and a delta on top, derived from the demonstrations).\n    - The new contribution re-writes the formalism of activation vectors (from Hendel et. al., 2023 and Todd et. al., 2023) with the notation of meta-learning (see Sec. 3.2).\n    - The paper is missing a supervised fine-tuning baseline. To prove that IVs indeed simulate gradient updates, the paper would need to show that the internal behavior is very similar to fine-tuning (for example Dai et. al., 2023 shows similarities in the attention weights).\n- Claim 2. The analysis evaluates on diverse real-world in-context learning tasks.\n    - While this claim is supported in Table 1, the contribution is not sufficiently significant.\n    - It is unclear why evaluating on real world tasks are more informative or provide some new insight, when compared with the previous synthetic tasks. If anything, both function and task vectors perform competitively on the real world tasks in Table 1. It would have been more convincing if the paper showed a strong divergence in performance, for example a case where a method performs very well on a synthetic task yet poorly on a real world task.", "methods_and_evaluation_criteria": "Please see “Claims And Evidence” above.", "theoretical_claims": "N/A", "experimental_designs_or_analyses": "Please see “Claims And Evidence” above.", "relation_to_broader_scientific_literature": "Please see “Claims And Evidence” above.", "essential_references_not_discussed": "N/A", "other_strengths_and_weaknesses": "Strengths\n\n- The paper evaluates on real-world tasks, extending beyond the synthetic tasks investigated in prior work.\n\nWeaknesses\n\n- The method does not convey a sufficiently new insight compared with prior work. The paper assumes the theoretical foundation already established by Dai et. al., 2023 to be true with no further experimentation, and shares many conceptual similarities with the methodology introduced by Hendel. et. al., 2023 and Todd et. al., 2023. I make this comment even after reviewing \"Comparison of Methodologies\" in Appendix E.\n- The idea that the method is “grounded in the idea of meta-gradients” (L902) is not adequately justified; see the discussion of Claim 1 above.\n- The “iterative updates and batched extraction” (L917) is similar to the common practice of activation averaging (also see L268), which also appears in Todd et. al. 2023.\n- The investigation of scaling the number of demonstrations in Sec. 4.3 and Sec. 4.4 was also the primary focus of Huang et. al., 2024, which looks at activation vector averaging for many-shot in-context learning.\n\nReferences  \n[1] Dai. et. al. Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizers. ACL Findings 2023.  \n[2] Todd et. al. Function Vectors in Large Language Models. ICLR 2023.  \n[3] Hendel et. al. In-Context Learning Creates Task Vectors. EMNLP Findings 2023.  \n[4] Huang et. al. Multimodal Task Vectors Enable ManyShot Multimodal In-Context Learning. NeurIPS 2024.", "other_comments_or_suggestions": "N/A", "questions_for_authors": "N/A", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}]

Author rebuttal:

Meta-review: This paper tackles the problem of selecting effective demonstration examples in in-context learning (ICL) for language models. It does that by introducing Iterative Vectors (IVs), a technique that enhances ICL performance by extracting and iteratively refining gradients but by then applying them indirectly by acting on the language model's activation space, i.e. without requiring backpropagation or parameter change. The paper validates this method by showing that IVs improve the model's learning from demonstrations, and experiments across multiple language models demonstrate its scalability and effectiveness.

The main concerns raised by reviewers are related to a certain lack of clarity in the technical exposition, concerns about the empirical verification being limited to classification tasks, and failing to cite and contextualize some relevant literature. The authors countered the first concern by stating their commitment to providing explicit clarifications in the revised version of the paper. Moreover, they argued that their method is applicable to generation tasks in addition to classification tasks, although they reserve to provide empirical evidence of this claim for future work.

The strengths of the paper highlighted by reviewers are the novelty of the proposed method, its simplicity (which makes it highly applicable to a potentially wide range of tasks), and the consistent improvement demonstrated by the method across evaluated baselines and models.
Given these strengths, the paper is recommended for acceptance, but in the revised version of the paper the authors are requested to address the reviewers' concerns about clarity of exposition (as they committed to do), and include proper references and contextualization within the relevant literature, in particular the mentioned works on Function Vectors and Task Vectors pointed out by reviewers.
Decision: Accept (poster)