Understanding the Generalization of In-Context Learning in Transformers: An Empirical Study
Authors: Xingxuan Zhang
Haoran Wang
Jiansheng Li
Yuan Xue
Shikai Guan
Renzhe Xu
Hao Zou
Han Yu
Peng Cui
Venue: ICLR 2025 Poster (2025)
Keywords: generalization
in-context learning
transformer
Primary area: alignment, fairness, safety, privacy, and societal considerations

Abstract: Large language models (LLMs) like GPT-4 and LLaMA-3 utilize the powerful in-context learning (ICL) capability of Transformer architecture to learn on the fly from limited examples. While ICL underpins many LLM applications, its full potential remains hindered by a limited understanding of its generalization boundaries and vulnerabilities. We present a systematic investigation of transformers' generalization capability with ICL relative to training data coverage by defining a task-centric framework along three dimensions: inter-problem, intra-problem, and intra-task generalization. Through extensive simulation and real-world experiments, encompassing tasks such as function fitting, API calling, and translation, we find that transformers lack inter-problem generalization with ICL, but excel in intra-task and intra-problem generalization. When the training data includes a greater variety of mixed tasks, it significantly enhances the generalization ability of ICL on unseen tasks and even on known simple tasks. This guides us in designing training data to maximize the diversity of tasks covered and to combine different tasks whenever possible, rather than solely focusing on the target task for testing.

Published as a conference paper at ICLR 2025
UNDERSTANDING THE GENERALIZATION OF IN- CONTEXT LEARNING IN TRANSFORMERS: AN EMPIRI- CAL STUDY
Xingxuan Zhang', Haoran Wang', Jiansheng Li, Yuan Xue, Shikai Guan, Renzhe Xu Hao Zou, Han Yu, Peng Cui Tsinghua University, 'Equal Contribution, *Corresponding Author xingxuanzhang@hotmaa. com, wang-hr22@mail tsinguua edu cn, Ellpptssighuu edu.cn
ABSTRACT
Large language models (LLMs) like GPT-4 and LLaMA-3 utilize the powerful in-context learning (ICL) capability of Transformer architecture to learn the fly from limited examples. While ICL underpins many LLM applications, its full potential remains hindered by limited understanding of its generalization bound- aries and vulnerabilities. We present a systematic investigation of transformers' generalization capability with ICL relative training data coverage by defining a task-centric framework along three dimensions: inter-problem, intra intra-problem, and intra-task generalization []] Through extensive simulation and real-world experi- ments, encompassing tasks such as function fitting. API calling, and translation, we find that transformers lack inter- inter-problem generalization with ICL, but excel in intra-task and intra-problem generalization. When the training data includes a greater variety of mixed tasks, it significantly enhances the generalization ability ICL unseen tasks and even known simple tasks. This guides us in designing training data to maximize the diversity of tasks covered and to combine different tasks whenever possible, rather than solely focusing the target task for testing.
INTRODUCTION
Transformers Vaswann et al. 2017) have become foundational architecture for most modern large language models (LLMs), such as GPT-3 (Brown et al., 2020), GPT-4 (Achiam et al. (023), Gem- ini (Team al. 2023) and LLaMA (Dubey al. 2024). One of transformer's impressive capabilities, in-context learning (ICL), empowers LLMs with the remarkable ability to learn on the fly from limited test-time examples. While in-context learning forms the bedrock of numerous LLM capabilities and applications, a key obstacle to harnessing ICL safely and reliably lies in our limited understanding of its origins, limitations, and generalizability.
The intricate interplay ICL with the immense and unstructured nature of raw text data in LLMs poses substantial analytical hurdle. To elucidate the mechanisms and capabilities of in-context learning, researchers have explored its potential beyond the confines of language domains and transcended the raw nature of text data. For example, Garg et al. (2022) proposes novel training paradigm where GPT-2 family models are trained on prompts enriched with both input and label demonstrations. which empowers the models to emulate the behavior of the ordinary Icast squares (OLS) algorithm. [Ahuja & Lopez-Pazi (2023) investigate the generality and limitations of transformers' in-context learning for linear regression by contrasting them with set-based MLPs under distribution shift, revealing stronger resilience and OLS- performance for transformers while highlighting vulnerabilities at extremes. Yadlowsky et al. (2023) exhibit vulnerabilities and suffer generalization limitations for functions outside training domains, suggesting ICL capabilities are heavily reliant on training data coverage rather than generalizable inductive biases.
Although strides have been made in elucidating the mechanisms of in-context learning, key knowledge gaps still remain. Notably, a systematic investigation into the relationship between the boundary of
Code available http://gghhiiicoom/m//cc/ctttatt Transfommmsssss

---

Published as a conference paper at ICLR 2025
in-context learning's generalization capabilities and its training data is lacking. Furthermore, the robustness of in-context learning within the generalization boundary under distribution shift has yet to be thoroughly explored. Addressing these critical gaps is essential for comprchensively understanding the potential and limitations of this powerful learning paradigm.
We use framework that abstracts training data into distinct problems with nested tasks. By leveraging this task-centric representation, we aim to systematically investigate the generalization of in-context learning along 3 dimensions: (1) inter-problem generalization, the ability learn and perform on entirely new problems not encountered during training, (2) intra-problem generalization, the capacity fully grasp familiar tasks after receiving minimal, targeted knowledge training as guidance, and (3) intra-task generalization, the ability to perform on the trained tasks with similar test samples. We design a series of experiments to investigate generalization along these 3 dimensions. To ensure the consistency of experimental conclusions with the dimension distinctions and the validity of comparisons, we conduct function- fitting experiments on models including GPT-2 (Radford et al.) 2019) and LLaMA-3 (Dubey et al. 2024), as well as real-world experiments involving Tool calling and translation tasks on LLaMA-2 Touvron et al. 2023 and Qwen-2 (Yang et al. 2024
Our findings are follows.
Transformers fail to show inter-problem generalization yet succeed achieving strong intra- problem generalization during ICL, Even with minimal, targeted knowledge in training guidance, the model learns to generalize to other tasks within the problem.
2. Contrary to expectations, an abundance of pretraining data does not necessarily confer upon model the capacity of inter-problem generalization. Our experiments with LLaMA-3 reveal that similar to randomly initialized GPT-2 model, the model struggles to generalize across problems despite demonstrating exceptional intra-problem and intra-task generalization capabilities with ICL.
3. In real-world experiments, incorporating combination of different tasks into the training data not only improves the generalization ability of the model's ICL on unseen tasks, but in some scenarios, can even enhance performance on known, simple tasks.
4. In real-world experiments, the inclusion of a wider variety of tasks in the training data can amplify the improvement achieved by ICL complex or hard tasks. Even if the target task is not present in the training data, model exposed to greater diversity of tasks during training can quickly learn novel tasks through ICL and achieve better performance.
2
PRELIMINARIES
2.1 NOTATIONS
Define f(æ; Φ) as mapping from R to R, parameterized by 6. A function class F, is specified as a tuple (f, +), encompassing all functions parameterized by elements from the set t. that is, F= (f. +) (f Ø) & E Φ). Let G denote the set comprising all such function classes F. Definition 2.1 (In-context Learning Task). For a given function class F G, in-context learning tasks involve presenting a model such that for any f(x; E and 24 E IR, = 1,2,...,.. n 1. given a prompt sequence
(I1, ((.f 22, x2, fx2; o),..., Zn, f(Eni Φ), In41), the model could accurately predict ÿ. an estimate of f(
Definition 2.2 (In-context Learning Problem). For a given set of function classes T C G, in-context learning problem requires model, such as a transformer, successfully address all in-context learning tasks corresponding to each Fe T.
Furthermore, define Those and Teom intuitively in order of increasing complexity. We define Those as the set of base functions, and Teom as the set of combinations of multiple base functions from Thase- Subsequently, we present the generalization task and problem defined by F and T.
2.2 RESEARCH QUESTIONS ON IN-CONTEXT LEARNING GENERALIZATION
Our objective is to investigate the generalization capability of models in-context learning at various levels. To this end, pose the following specific research questions.
2

---

Published as a conference paper at ICLR 2025
Inter-problem Generalization
attra-problem General cineralization ization
51 (0) (1)in(
T+ com
F F2 yy = 11 sin(x)) + (2cns(())
F201 y (2)ns(x)
P2 + F33 (0) y = 42 cx)(x) + 43 (2x)
0 (25in(2x)
s Jn Mny sin (2) x)
casl "o c
Tase
F4 y (2x)s(2x)
(0)
Generalization
Intra-task
T com
(0) xP2 (0) Φi sin(x)) (x)
J2 x (0) :y = $2 cos(x) xxpss))xxsssn))))
0 y Pho cos
Jop x5 y Pay- sin 7 X cust
7
generalization problem
generalization lask
Figure 1: Illustration of inter-problem, intra-problem, and intra-task generalization. Here single function fitting as the base problem Thase, and addition and multiplication as the combination problems Teom for example.
Research Question 2.1 (Inter-problem Generalization). Given two distinct in-context learning problems Thase: Toom C G, where Thase j Teom. can a model trained on tasks from Thase generalize tasks in Teom?
Research Question 2.2 cntra-problem Generalization). Given two different in-context learning problems Toase, Teom C G. where Thuse * Teom. and subset of tasks F1, Fg...., Fr E Teoms if the model is trained on tasks from both Thase and this subset F2, Fr) of Teoms can it generalize to all the tasks in Teom? ?
Research Question 2.3 (Intra-task Generalization). Given an in-context learning task F and a set of functions {2; & fz; Φ2)..... f(; (n)) E F, if model is trained on these specific tasks, can generalize to encompass all the functions in FF
To facilitate understanding of the aforementioned definitions and research questions, we provide concrete definitions of generalization problem and generalization task based on function fitting tasks below for example.
2.3 CONSTRUCTING SPECIFIC IN-CONTEXT LEARNING TASKS AND PROBLEMS
As shown in Figure D. to evaluate models' capability concerning Research Questions 2. 2.2 and 2.3 we devise specific in-context learning tasks and problems based on function fitting tasks.
An Example of Base Function In-context Learning Problem We select a set of non base function classes (T(()) [ (..)....... F ), constituting the base function in-context learning problem Thase-
,,..,,
These function classes are defined as:
t = (ósin(z) RE.
F = {o cos (x) : E R}, F(( {o cos (2x) : E).
F ()) (dsin(2x) : :de
We use sinusoidal functions as base functions and leverage the inherent advantage of orthogonality possessed by them to verify the model's ability to accurately fit them. This orthogonality property ensures that sinusoidal functions of different frequencies are mutually perpendicular in function space, minimizing interference and preventing inaccurate evaluation due to function overlap.
Combination In-context Learning Problems From Thases we generate more complex problems using combination operations on functions. Specifically, for any in-context learning tasks F, and F2, we define the additive, multiplicative, and compositional
Additive/ Aadttii//Mllippleeti/CCmmiiiiii
3

---

Published as a conference paper at ICLR 2025
Table I:
SE of models tested on the convex combinations of base functions. Random indicates the SE of random sampling within the function's 's codomain and serves as measurement of SE. Range indicates the range in each sequence to calculate SE. s(-) and c(-) represent sin(.) and cos( (-) respectively. Meann and Meanc indicate the mean SE of base functions and combinations of base functions, respectively. ComAn indicates the combination of all base functions.
Model
o12x)
(0088522)
c008c(22)
Meatc
1-10
Basclin:
CRL
4,8ee3
520033
3,50=3
243e-3
36te3
5.34-3
6.4k-1
4,55-3
4.6c-1
4.26-3
601e-3
1.32-22
6.18-2
7,37e-3
8.9c-2
1.5h-2
4.9k=2
k.96-2
2.86-2
4.39-2
1A562
1.25-2
3.9r-2
2,18-1
2.21e22
7.96=22
11:29
Baseline
CRL
1.3e.5
2.7855
9.77e6
1.1e-5
3.%e.5
7316-5
5.58e5
8:13-5
2.5e:5
483--5
2.30.3
5.90-5
6.65+
1.76-4
8.4kc
9.22-4
5.45
1.30-2
4.41e-1
5.65e
1.86-3
2,0g
4.88--
6,71e
4,9p-1
21:30
Baselise
CFL
7,96-66
2.138.5
6.82e66
6.78e
3.4e-5
7.4e
4.0k-5
6.70e 5
236e55
4.36655
3.1363
1866-3
4,258
1.29p-
6.00622
3.4c-4
5.9962
6.30e-
9,5723
1.4663
492c-3
7.4e44
2.07-11
1.26-3
5,5862
1,8633
Basclino
6:00-5
342--
4.32e8
2.39-8
1.71e3
1.000-2
60k-1
4.00=-
7,50-3
47he-1
184e-1
4,90-7
CFL
1.76-5
6.0366
1326-5
6.396.5
4.22.5
2,66.3
1.1664
227c4
5.2663
9.4644
53%-4
6.9c4
1,663
Kontom
400e-
4.3e2
433e2
4.4e-
4.7e2
9.7e-2
M.tel
100el
9.10e2
1.6g-1
operations on tasks as:
F2 = (x
: E
x (x+ (1;;01) (2(1;2)) : h E Fi, E F2), F2 {x (2)): E F2).
For an operator o 6 {+, 0) the respective in-context learning problem is formulated as:
Teu (Fi o F2 Fi, E Thase).
(4)
The problems Totm Teom and Trom are thus termed as additive, multiplicative, and compositional combination in-context learning problems, respectively.
3 GENERALIZATION OF ICL ON FUNCTION FITTING
In this section, we investigate the generalization ability of ICL on function-fitting tasks and study the research questions raised the previous section.
Previous studies (Garg et al. 2022 Akyürek et al. 2022) have demonstrated the ability of transform- ers select the correct function from one or two function classes based on in-context examples. However, their ability to generalize to convex combinations of these learned functions within the training data remains limited (Yadlowsky al.) 2023). This difficulty arises because convex combi- nations constitute new function class, requiring additional knowledge beyond solely the constituent functions. Moreover, real-world applications rarely involve separate training and test regimes with distinct function composition patterns. Instead, models typically trained and deployed data containing diverse, intermingled function (task) combinations. Hence, our investigation focuses on the practical and generalizable scenario: the ability of transformers to extrapolate from specific function combinations to new, unseen combinations.
In Sections and 3.3 We use randomly initialized UPT-2-Standart a relatively small model enough to reveal the results. In Section 3.4, we utilize pretrained LLaMA-3 model for finetuning function fitting investigate whether large-scale pretraining influences the generalization of ICI. Since inputs are not limited by natural language, we directly perform function fitting on GPT-2 at the embedding level enable floating- maainng-pointeoe calculations. Large language models map tokenized sentences into embeddings and then perform computations at the same level. Therefore, the underlying principle of function fitting is naturally consistent with the behavior of large language models. Our empirical results further confirm this connection.
base model, which is
3.1 GENERALIZATION TO CONVEX COMBINATIONS OF LEARNED FUNCTIONS
In the context of function approximation, convex combinations serve as the basis for representing functions. Here we explore Question 2.1 2.2 and 2.3 with additive combination ICL problems, i.e., Team- In our base setting, we use four base functions, i.e., ny = 4 unless otherwise stated.
We denote the model trained the convex combination of functions the ComFuncLearner, while the model trained without convex combinations serves as the Baseline. The ComFuneL model leverages all base functions in its training alongside specific convex combination of F(()) and F(
4

---

Published as a conference paper at ICLR 2025
six)=sin(X)
+0.5"sin(22)00332eeeo22
0,5
2.0
2.0
1.5
1.5
0.0
1.5
1.0
0.5
-0.5
1.0
0.5
0.0
0.0
-0.5
-1.0
-0.5
-1.0
-1.5
-0.5
-1.0
-1.5
-1
0
-3 2
2
-3 2
-1
0
3
X
O GT
ComFunelleerre
Baseline
Figure 2: Function curves the convex combinations of base functions fitted by the Baseline and ComFuncLearne models after ICL. Com stands for combination and the weights of base functions randomly sampled and labeled on the figure.
Le., F3. To maintain parity in the training set size and the number of seen functions, the Baseline
model is trained all base function classes and an additional one, F { (ixx) o E R).
Thus the Baseline model is trained on samples generated by functions sampled from (F(()) F((
- F F while the ComruneLeamerr on (- F Fo F F F(() ]. The
performance of the Baseline model on base function classes answers the Question [2.3 2.33 intra-task
generalization, while its performance on combinations of base function classes with 74 answers the Question 2.1 inter-problem generalization. The performance of the ComFunce Fennee on combinations of base function classes with T_ answers the Question 2.2 intra-task generalization.
We report the average squared error (SE) of the predicted values compared to ground-truth labels and averaged across 128 independent runs. Each data point thus represents the average SE computed over 128 test samples. As shown in Table when tested with functions sampled from familiar classes seen in the training data, both models attain low squared error (SE) after 10 in-context examples. However, when presented with unseen convex combinations, the ComFuncLearne' model exhibits remarkable improvement in generalization ability within the ICL paradigm, even with only a single exposure to convex combination pattern during training- Specifically, the ComFuncl Leanner consistently outperforms the Baseline model across all convex combinations, except for the combination of
R]. In this combination, both models achieve low SEs (less than 0.002 after 20 in-context examples). This observed convergence could potentially be due the close functional similarity between the two base functions, making their individual contributions subtle within the convex mixture.
F fo (ossnn))) (x) Ø R and F {o cos(z)
To gain deeper insights into the model's internal function representation, we employ a progressive visualization method. Following each exposure to N in-context examples (i.e., samples), we fully traverse the X-axis space, feeding each the input for the N+1st sample and recording the predicted This approach effectively captures the model's 's evolving understanding of the underlying function as it accumulates training data. Figure 2 presents the function curves learned after 39 examples, revealing the gradual refinement of the model's ds predictions as it progressively learns function. Please see Appendix [.] for more visualization results.
For the individual basis functions, both models closely approximate the true curves across the entire X-axis range. However, for the convex combinations, the Baseline model exhibits significantly poorer performance compared to the ComFuneLearner model. While the ComFuncLeanme accurately approximates almost all convex combinations, the Baseline model's 's fits are often suboptimal. Please note that the ComFuncLeerner model does not learn the combination of F = (dssin (2x) & R}
and FO! ( (2x)) & E ]R], and the combination of base functions. Thus this indicates that when select convex combination as the operation on base functions, the transformers show intra- aatra--roblem generalization (the ComFunclearnrr model fits the combinations it never learned in the training data) yet fail to achieve inter-problem generalization (the Baseline model fails fit most combinations of base functions).
For detailed experimental setup, please refer to Appendix B.I Except for convex combinations, we also observe remarkably similar conclusions regarding the model's ability to learn multiplicative combinations of functions shown in the following section.
5

---

Published as a conference paper at ICLR 2025
Table 2: SE of the ComFuncLearne and Baseline model tested on the product combinations of base functions. CFLI, CFL2 and CFL4 indicate ComFuncLeanee trained with 1, 2, and 4 combinations during training, respectively.
Rang:
Modd
013)
o(2g)
Mrany
Cumt
Mon:
Buscline
3.50g
3.55=
5.34e3
5.29e:3
4.45c
2.87622
1
2.956-2
2.10s:2
2.85x22
1446-2
4.34:22
3.21s
1:10
CRL3
CFL]
4,002 3
4.85-3
2.71e:3
3/46-3
4.0
2.36-3
3.25-3
4,576
3.91e
3,476-3
2.33 2
4.6r-3
1.31o-2
5.90c-3
4.26e11
1.83--
1.572-2
1.45::
2/42-22
2.08:
488c-3
1.9c
1.77-2
3,598 2
2.68:
1/84--
CFL4
3.42-3
2.63-3
4.33-3
4.10-3
3.59o-
5.95--3
5.940-
2616-2
1.36e-2
6.0le3
7.16e-
2,70--2
1.31e2
Baseline
4.54
1.37e
2.13e
6,66 5
3.66
281e
9,002
2616-
1
1
7.85e3
4.87
2.52+
2.7
0.16-5
5.66-5
3.3368
8.76-3
5.780-3
1.0022
33561
2.16:-2
1.10-2
CRL3
3.53.55
5.33-6
1.36-5
8:230-5
3.61.-
4.4%v55
Li5e2
8.446-3
1.902
130c4
1.3r-22
5.850-3
1.36
4.30e-5
4.13e-5
5
6M2e-3
5.76-3
1,76-3
2.5e-4
1.56-2
A11e-3
3.16-5
1.58-5
4.18a-5
2.45-5
2.66-2
326-
8885-1
5.16222
2.13-22
21:30
CH1.
CFL1
2.4ke-
3.36e4
1.17e:5
3.25e
0,96e
2.38e
4.45e
3.47e-
981e-3
KMeel1
6.21233
305e-3
1.48
9.7k-5
1.0ke-2
7.18e33
CFL4
2.3p-5
6,5966
1.56e-5
3.36e5
2.83e-5
1766-5
1
29%c3
3,39:-
4.336-5
L.8e-4
1,58:-2
2,96-3
Baseline
25365
7.36e
L8te5
3.76.
2.17
2,0e
7,760
22562
5.866
5.536
5.1e
5,00 2
1
31-40
CHL)
CFL2
2
1.3e5
0.75--
3.2666
165e-
1.13-5
6.1e.5
1076-5
261e-
231e-5
271c-5
116e-3
8.786-3
4.99-5
6.5663
7
5.526-3
2.84+22
1.33-2
1:160-2
7.36-5
1.te-1
9.002-3
933e-3
6.21c3
5.3e-
CH14
1.9
5.46-5
1:26-5
2,49-5
1.5768
1026-8
9.790-
22263
2.773-
3
877e-3
7.00e-3
1.34-3
Rundon
4356-2
4.1402
466e-
431e2
4.7622
4.87622
5.0p2
4.6622
4.99
5.1482
528e-2
4.80c-2
1.98g1
sixx))
f(x)=
(x))ss)()))emm(s))
(o0s(2)))
0.5
2.0
0.0
1.5
1.0
-0.5
-1.0
-0.5
-1.5
-1.0
3
-2
-1
0
-3
-2
-1
0
-3
2
-1
-2
-1
0
2
O
GT
Baseline
CFL1
CFL2
CFL.
Figure 3: Function curves on the product combinations of base functions fitted by the Baseline and ComFuncLearner models after ICL.
3.2 GENERALIZATION TO PRODUCTS OF LEARNED FUNCTIONS
Moving beyond convex combinations, we explore the generalization of transformers when select- ing product combinations (i.e., Te%m) as the operation on base function classes. Unlike convex combinations, where the model typically aligns with one constituent function to maintain control over squared error (SE), product multiplication allows more freedom in fitting individual function classes, potentially leading to greater divergence from the product true curve. We also consider the combinations of z(O)) {6 sin ø e }R and F=( {Ø sin((()))) E IR, as the extra function classes to train the ComFuncLcarner model here.
Table 2 reveals the Baseline model's persistent struggle to accurately predict product combinations within the ICL. Despite having witnessed only one combinatorial pattern, the ComFuncLeanm model consistently surpasses the Baseline in the combination problem. However, compared the substantial improvement observed in convex combination experiments, the ComFuncl Learner's advantage in product combinations is less pronounced. We hypothesize that this disparity arises from the inherent difficulty of fitting product combinations compared convex combinations.
To investigate this further, we progressively increase the number of product combinations presented to the ComFuncLearner model in subsequent experiments (1, 2, 3, and 4). Specifically, we report the results of the ComFuncLeent
model combinational function classes including (F(O) x F
F(") F/(: (0) F=(O) , FF( )( Please note that we only add more patterns of combinations to the training yet the number of all training samples and training steps are fixed the same for the Baseline model, the ComFuncLearne model with 1, 2. and 4 combinations in its training.
This manipulation aims to determine whether exposure to a wider range of combinatorial patterns during training could enhance the model's generalization ability to unseen product combinations. As shown in Table 2 we observe a consistent decrease of SE as the number of product combina- tion patterns presented the ComFuncLearne model in the training increases. For example, observe the mean SE among 21-30 points drop from 0.0213 (the Baseline model) to 0.00294 (the ComFuncl.eame Leamer with 4 combination patterns in its training data). Figure 3 presents the function

---

Published as a conference paper at ICLR 2025
Table 3: SE of the ComFuueLearner and Baseline model tested on the compositional combinations of base functions.
Model
4X1
033
Mesto
024065120
Xexse
Basdiie
3.96622
1:30
CFLI
2.50p-
1.16-1
2.0p-3
2:53-1
2.85x-3
3877-3
1,1633
1.25e-3
1.30-3
2.5ee11
3.1622
299k-1
3.9c-2
158a-1
3.56-2
1,0e-
3.89-2
175p-1
4.06-1
4.36-1
1.50-2
1.290-2
4,22c 2
4/17a-2
3.43022
3:40e1
CRR.4
2.50e11
2716-1
3.5k.8
3.30-5
3.80--
114-7
2.Ne-
3.867
X.M6-2
3M6e-
1.3962
3.8k-2
X.1e-2
11:30
CHL1
CFL
1.33e-5
1,5k--
4.0k-
2.88-6
3.21e-5
2.972-5
3.1lch
5.3e6
143e5
3.90022
370e2
3,5622
3.06-
4.0k-2
4.72-1
4.0
4
4.26c22
3.68-2
3
CPL4
2.36-4
2296-6
9/63-6
2,1966
475p4
2.26-4
2.446-2
28064
2.36-2
3.4662
4.756-
2.94-2
231e-2
Basdine
5.58e6
1.Ne.5
6.00-5
2.5e-
2.1622
4.0ie
6.00-3
4.4rs22
21:30
CP1
1.5ke5
135e:5
2,46e6
1.5e-5
3.3ke1
3
48le2
6,34e3
4.50e2
3.42-2
CPEA
1.51e4
18305
6
1,49-6
4.8e4
1.7e-]
194e-
1,97e2
1.76e2
2,0163
3.85e-3
1.4e-2
1.Mle]
Basiiie
5.886
4.82-5
1.72e-5
6.8e5
243e-5
3.4b
3
2
3.56-2
4:33-2
7.56e3
4.35
3
CTL.1
1:365
185e-5
6.ienn
1.36-3
1.2611
300p2
48461
6.60-3
4.36622
CPL4
166-
1.76e2
2.762
4.6e-3
1.6c2
1.86-3
Randon
4.36-2
4236-
4.462
6.5p2
6.261
6.66-2
6.2622
5
6.57p2
6.5662
[())<os(x))
(())sin(33)
((0x
six)
1.0
1.0
1.0
1.0
0.5
0.5
01.5
0.5
0.0
0.0
0.0
0.0
-0.5
-0.5
-0.5
-1.0
-1.0
-1.0
-3
-2
-1
-3
-2
-1
2
3
-2
-1
2
3
-2
-1
0
2 3
GT
Baseline
CELI
CFL2
CFL4
Figure 4: Function curves on the compositional combinations of base functions fitted by the Baseline and ComFuncLearner models after ICL.
curves learned after 39 examples and reveals a distinct trend: as the number of seen combinations in training increases, the model's fit the objective function steadily improves. With 4 combinations observed, the ComFuncleeamn model's fit closely approximates the function's 's true curve. This suggests that transformers fail to achieve inter-problen generalization but show intra-problem generalization, which can be improved as the number of learned combinations increases.
3.3 GENERALIZATION TO COMPOSITIONS OF LEARNED FUNCTIONS
We then investigate the generalization of transformers when selecting composition combinations as the operation on base functions. Compared to convex combinations and products of functions, compositional combinations (i.e..Tcom) ) present a significantly greater challenge due to a critical distinction: the distribution of input to the outer function is dynamically transformed by the inner function, creating additional complexity for analysis and optimization.
To further investigate the relationship between generalization capabilities and training patterns, progressively increase the number (1, 2, 3, and 4) of compositional combinations presented to the ComFuncl earner model from combinational function classes including (-(()) F(()) ((()) (0)
J. Fo) (0) F((0)
F( in subsequent experiments. CFL1 has seen the combination F F
CFL2 has seen F F
(0) and F(() F( While CFLA has seen all four function pairs. As shown MonFunnLLeanerr improvement on compositional combinations is convex or product combinations compared to the Baseline, its SE decreases
in Table ] Figure
4 While
not significant notably as the number of encountered combinations increases. We believe this is due to the nature of compositional combinations. Since the output of the inner function in a composite function serves as the input for the outer function, the input distribution for the outer function changes significantly compared to the non-composite case, making it difficult for the model to fit the composite function well. We discuss the impact of input distribution shifts on ICL. generalization in Appendix
3.4 GENERALIZATION OF PRETRAINED LLAMA-3 ON FUNCTION FITTING
To investigate the impact of extensive pretraining data on model generalization, we finetune the pretrained ILLMA-3 model for function-fitting fitting and evaluate its performance with the composition
7

---

Published as a conference paper at ICLR 2025
[(x)=-72jxl
Rx) 11"x"2
f(x)= )1
f(y -2
1.00
-500
15000
0.75
-0.2
10000
0.50
10000
-0.4
-1000
5000
0.00
-0.6
2000
-0.25
-1.8
-2500
-5000
-0.50
-3000
-10000
-0.75
-1.2
-40
-20
20
44
-20
20
40
O GT
ComI'uncl.cn Lenclereerr
Baseline
Figure 5: The fitted curves of LLaMa-3 on composition combinations of learned functions (absolute value functions - | and quadratic function x²).
combination of functions following the setting in Section 3.3 Detailed experimental procedures are
shown in Appendix B.2
As shown in Figure 5 and Appendix D.2 our findings provide compelling evidence that while finetuned L-M exhibits exceptional proficiency intra-problem and intra-task generalization, it notably struggles with inter-problem generalization. In more precise terms, the model's ability to learn via ICL is contingent upon prior exposure during finetuning and novel combinations of functions that are absent in the finetuning data cannot be acquired through ICL. However, if the model has been exposed to a limited number of combinatorial forms during finetuning, it demonstrates the capacity generalize and learn other types of combinatorial forms via ICL. This implies that despite its extensive pretraining on massive datasets, the model has not fully acquired the ability to transfer knowledge and apply learned patterns to dissimilar problem domains, i.e., from question-answw answering problems to function function-fitting. However, incorporating a small amount of function composition data into the finetuning dataset can stimulate the model's ability to handle new problems. This suggests that the diversity of finetuning data and its representativeness for application tasks crucial for activating the knowledge acquired by the model during pretraining.
GENERALIZATION OF ICL ON WORLD EXPERITMENS
To ensure the real-world relevance of our findings, we investigate the generalization capabilities of transformers with ICL on complex, real-world tasks. Our primary focus is on tool-calling tasks for pretrained models and translation tasks for models trained from scratch. Unless otherwise stated, the results reported in this section are the average of three independent runs.
4.1 TOOL-CALLING
is challenging to assess the generalization ability of LLMs on novel tasks, as they are typically pretrained and supervised finetuned (SFT) massive text corpora. To address this, selected tool- calling tasks, which differ significantly from the question-answering I.MMs. Tool-calling tasks offer high degree of controllability and comparability, making them ideal for delineating the boundaries of LLMs' gencralization capabilities across problems and tasks where LLMs' initial performance has considerable room for improvement (Qin et al. 2023).
tasks commonly encountered by
We categorized Tool-calling tasks into single-API calls and multi-API calls. Single-API calls refer to tasks that require only a single invocation to fulfill the instructions in the prompt, while multi-API calls necessitate considering the combined use of APIs to achieve more complex functionalities. Mirroring the definitions of generalization problem and task, we define single-APl calls as the basic generalization problem Thase, and the combination of APIs as the composite generalization problem Teom- This allows the Baseline model to be trained only on the basic generalization problem, while ComFuncLearner is trained both the basic and composite generalization problems. To ensure fair comparison, we guarantee that the Bascline and ComFuncLearne, are trained on the same number of samples and that ComFuncLeerner has not encountered any of the API combination forms present in the test data. Further experimental details can be found in the Appendix B33
The results are in Table When both are based LLaMA-2 and trained on the same number of samples, incorporating ICL can casily surpass the results of TooILLaMA (Qin et al. 2023). Compared to the Baseline model, ComFuncLeeat Larmer with ICI. demonstrates significant boost performance
8

---

Published as a conference paper at ICLR 2025
Table 4: API-calling accuracy on ToolBench. Following Qin et al. (002]. we report the results of Il Ii-inst I1-tool, 12-inst, 12-Cat, 13-Inst. During training. 11, 12. 13 denote single-tool. intra-category multi-tool. and intra-collection multi-tool instructions. For inference, data is divided into levels: Inst. for new instructions on trained tools. Tool for new tools in known categories. and Cat. for new tools in new categories. Tools in the same category share a common theme (c.g., sports, finance), while those in the same collection have similar functionality (c.g. database manipulation, web crawling). Baseline refers model trained with single-tool examples while CFL with multi-tool examples. ICL, mcans 16-shot evaluation with single-APl examples and ICLm with multi-APl examples. The difference highlighted refers to the improvement of ICL.
Model
11-Inst.
T1-Tool
T1-Cat.
Average,
12-
12-Cat.
13-Inst.
Averagem
T
25.0
29.0
33,0
29.0
30.5
31.5
25.0
29.0
Baseline
24.2
27.5
32.6
28.1
26.2
25.6
20.6
24.1
CFL
25.2
28.7
32.8
28.9
30.5
31.7
24.8
29.0
Bascline+ICL,
26.9
29.3
33.4
29.8 (+1.8)
27.0
26.6
22.5
25.4 (+1.3)
Bascline+ICLm
26.6
28.5
33.6
29.5 (+1.4)
28.1
27.5
23.6
26.3 (+2.2)
CFL+ICLs 26.8
31.2
34.7
30,9 (+2.0)
31.8
33.1
27.3
30.7 (+1.7)
CFL+ICL 26.2
31.3
33.4
30.3 (+1.4)
33.4
34.1
28.4
32.0 (43.0)
LaMA is the SOTA hased on LLaMA-2-7h. The result is reported in Qin et (2023)
multi-API tasks. This aligns with the conclusion of the function fitting experiment: the transformer's ICL exhibits better intra-problem generalization ability but weaker inter-problem generalization. Moreover, ComFuncl.earne even outperforms the Baseline some single tasks. This indicates that, in real-world experiments, training with complex and mixed data can enhance the generalization ability of the model in ICL, and even raise its upper limit on simple tasks. In other words, the diversity of generalization problems learned by the model can improve its intra-problem and intra-task generalization in ICL. These findings guide us to utilize sixeedppoblenn data more extensively for transformer training, rather than being limited to single, simple tasks even when the target task is simple. Training data with mixed problems not only improves the model's s cross-problem generalization ability but also enhances its performance originally simple tasks.
4.2 TRANSLATION
As existing LLMs are typically applied to natural language-related tasks, we also validate the practical implications of our findings on translation tasks. To more clearly demonstrate the boundaries of generalization problems and tasks, and to avoid interference from unknown large-scale pretraining corpora on our conclusions, we pretrain randomly initialized models with the same architecture of Qwen2-1.5B (Yang et al., 20244] Bai et al.) (2023) the CC100 (Conncau) 2019) dataset, limiting the task language scope to English and German.
Building upon the models pretrained on CC100, train three models WMT14 corpus for the translation task: Baseline,2,, Baselineaze- and ComFuncLearner with translation from English to German data, translation from German to English data, and translation from mixed data to English data, respectively. To generate generalization problems distinct from the single-language to single- language translation task, we randomly replace portion of the words in the sentence be translated with the other language while preserving the overall semantic meaning (e.g.. in English-to- Eogrishtto-Grrmann translation, we randomly replace some English words with German) as the mixed translation data, To ensure a fair comparison, we guarantee the following: 1. All models are trained on the same amount of tokens; ComFuncLeemer has not encountered the specific problem during training that it will face during testing (e.g., if the test requires translating a mixed English and German sentence into English. ComFuncc_earnes will only have seen data for translating mixed English and German sentences into German during training). Detailed procedures are provided in the Appendix B.4]
The results are shown in Table On the complex task involving mixed-languse input, ComFun- cLearne achieves noticable better results than Baseline, and the improvement after ICL is even more pronounced, consistent with the conclusions in the previous sections. On the simple task, the Baseline finetuned with the exact same test target achieves the best results, indicating that the intra- problem and inter- problemo generalization ability of ICL is still lower than the intra-task generalization ability.
To further investigate what additional knowledge ComFuncLearee learns through ICL compared to the Baseline model, we further divide the WMT14 and WMT19 test set into easy and hard sets. The hard set contains 500 samples, which name WMT500. The detailed selection procedure can be

---

Published as a conference paper at ICLR 2025
Table 5: BLEU score performance on WMT14 de2en test set. Pretrained indicates the model pre- trained on CC100 and other models are finetuned based on it. BL indicates Baseline models.
Figure 6: The improvement BLEU score with ICL WMT500 dataset of hard samples. The rectangles in lighter colors represent the results without ICL, while the darker rectangles represent improvement brought by ICL.
Model
mix2en
mix2de
de2en
en2de
Pretrained
28.06
24.26
18.05
17.24
mix2de
en2de
BLaa
32.19
27.55
23.45
24.81
A-2.15
12
1-0.64
Bl
33.31
28.10
25.94
22.37
A-0.77
CFl
35.74
30.89
23.10
21.83
14.68
11-
10.98
A=0.65
14 A-1.35
10.34
ICL
33.57
28.45
25.02
25.78
A-1.41
10
BLnL
34.74
29.12
26.73
23.02
CFL
37.69
24.36
CIL
32.65
22.45
BLezd
BL
CFLmax
BLezd
BLaze
CFLmix
found in Appendix B.4 The experimental results on WMT500 are shown in Figure 6 We observe that simple tasks, such as translating sentences composed of single language into another single language with simple sentence structures and shorter lengths, the improvement brought by ICL is less significant, and the gap between ComFuncLearner and Baseline is not substantial. However, hard tasks, such as those involving mixed-language input or complex sentence structures, ICL can bring more significant improvements to ComFuncl less improvement. This indicates that during the training phase, if the model has been exposed to wider range of problems, it significantly raises the upper limit of improvement achievable through ICL, thereby realizing generalization capabilities on complex tasks.
while the Baseline shows considerably
5 DISCUSSION
is important to note that our discussions the main text focus on the generalization capabilities that ICL can achieve based on the training data. This implicitly assumes no distribution shift between the samples in ICL and the test data. However, in practical applications, this assumption is not easily satisfied. We often cannot obtain data that perfectly matches the distribution of the test samples, and even samples directly collected from the application scenario can exhibit distribution shifts due factors such as temporal changes and selection bias. Therefore, we further investigate the generalization ability of transformer-basee models when there is discrepancy between the data distribution of ICL and the test samples in Appendix C
CONCLUSION
To systematically investigate the generalization of transformers with ICL, we defined task-centric framework along three dimensions: inter-problem, entra-problent and intra-task generalization. Through extensive experiments including both simulated and real-world experiments, we showed that transformers could achieve intra-task and intra-problem generalization, but failed on inter-problem generalization. In other words, while exposure to diverse families of basis functions during training hinders the Bascline models' ability to learn combinations of these functions through subsequent in- context examples, the ComFuncLearne model trained on a single specific combination demonstrated remarkable flexibility. These models readily generalize to other unseen combinations of the same basis functions, suggesting that transformer models possess the inherent ability for in-context task acquisition, but require specific training data configurations to unlock this potential. This finding highlights the importance of carefully crafted training data that provides targeted "inspiration" for the model effectively learn and be applied to complex tasks.
ACKNOWLEDGEMENT
This work supported in part by China National Postdoctoral Program for Innovative Talents (BX20240203). Beijing Municipal Science and Technology Project (No. 2241100004224009, NSFC(No. 62425206. 62141607).
10

---

Published as a conference paper at ICLR 2025
REFERENCES
Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, 1lge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et Gpt-4 technical report. arXiv preprint arXiv:2303.08874, 2023.
Kartik Ahuja and David Lopez-Paz. A closer look at in-context learning under distribution shifts. arXiv preprint arXiv:2305.16704 2023.
Ekin Akyürek, Dale Schuurmans, Jacob Andreas, Tengyu Ma, and Denny Zhou. What learning algo- rithm in-context learning? investigations with linear models. arXiv preprint arXiv:2211.156611 2022.
Jinze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, et al. Qwen technical report. arXiv preprint arXiv:2309. 2023.
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models few-shot learners. Advances in neural information processing systems, 33: 13:7-1711 2020.
Rich Caruana and Alexandru Niculescu-Mizil. An empirical comparison of supervised learning algorithms. In Proceedings of the 23rd international conference on Machine learning, pp. 161-168, 2006.
Yanda Chen, Ruiqi Zhong, Sheng Zha, George Karypis, and He He. Meta-learning via language model in-context tuning. arXiv preprint arXiv:2110.078144 2021.
Yanda Chen, Chen Zhao, Zhou Yu, Kathleen McKeown, and He He. On the relation between sensitivity and accuracy in-context learning. arXiv preprint wwXiv:2209007661 2022.
Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam
Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, al. Palm: Scaling language modeling with pathways. Journal of Machine Learning Research, 24(240):1-113, 2023.
Conneau. Unsupervised cross-lingual representation learning at scale. arXiv preprint 1rXiv:1911.02//6 16, 2019.
Damai Dai, Yutao Sun, Li Dong, Yaru Hao, Shuming Ma, Zhifang Sui, and Furu Wei. Why can gpt learn in-context? language models implicitly perform gradient descent as meta-optimizers, 2023.
Qingxiu Dong, Lei Li, Damai Dai, Ce Zheng, Zhiyong Wu, Baobao Chang, Xu Sun, Jingjing Xu, and Zhifang Sui. A survey for in-context learning. arXiv preprint arXiv.2301.00224. 2022.
Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, and et al. The llama herd models, 2024.
URL httthttss///xiiiii
abs/2407... 21783
Shivam Garg, Dimitris Tsipras, Percy Liang, and Gregory Valiant. What can transformers learn in-context? a case study of simple function classes. Advances in Neural Information Processing Systems, 35:30583-30598. 2022.
Brian Lester, Rami AI-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning, arXiv preprint arXiv:2104 100.0009111 2021.
Yingcong Li, Muhammed Emrullah Ildiz, Dimitris Papailiopoulos, and Samet Oymak. Transformers as algorithms: Generalization and stability in in-context learning. In International Conference on Machine Learning, pp. 19565-19594. PMLR, 2023.
Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for gpt-3? arXiv preprint arXiv:2101.06800 2021.
Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing. ACM Computing Surveys, 55(9):1-35, 2023.

---

Published as a conference paper at ICLR 2025
Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. arXiv preprint NrXii:210400876, 2021.
Nicholas Meade, Spandana Gella, Devamanyu Hazarika, Prakhar Gupta, Di Jin, Siva Reddy. Yang Liu, and Dilck Hakkani-Tür, Using in-context learning improve dialogue safety, arXiv preprint arXiv:2302.00887, 2023.
Sewon Min, Mike Lewis, Luke Zettlemoyer, and Hannanch Hajishirzi. Metaicl: Learning to learn in context. arXiv preprint arXiv:2 2021.
Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannanch Hajishirzi, and Luke Zettlmmyer. Rethinking the role of demonstrations: What makes in-context learning work?, 2022.
Tai Nguyen and Eric Wong- arXiv:2302.11042, 2023.
In-context example selection with influences. arXiv preprint
Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Dawn Drain, Deep Ganguli, Zac Hatfield-Dodds, Danny Hernandez, Scott Johnston, Andy Jones, Jackson Kernion, Liane Lovitt, Kamal Ndousse, Dario Amodei, Tom Brown, Jack Clark, Jared Kaplan, Sam McCandlish, and Chris Olah. In-context learning and induction heads, 2022.
Yujia Qin, Shihao Liang, Yining Ye, Kunlun Zhu, Lan Yan, Yaxi Lu, Yankai Lin, Xin Cong, Xiangru Tang, Bill Qian, al. Toolllm: Facilitating large language models to master 16000+ real-world apis. arXiv preprint arXiv:2307.16789 2023.
Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019. URL hntpss: semant
org/Corpus 160025533
Ilija Radosavovic, Tete Xiao, Bike Zhang, Trevor Darrell, Jitendra Malik, and Koushil Sreenath.
Real-world humanoid locomotion with reinforcement learning, 2023.
org/abs 2203. 03381
Ilija Radosavovic, Bike Zhang, Baifeng Shi, Jathushan Rajasegaran, Sarthak Kamat, Trevor Darrell, Koushil Sreenath, and Jitendra Malik. Humanoid locomotion as next token prediction, 2024. URL
https://aara org/ abs/ 2402. 19469
Gemini Team, Rohan Anil, Sebastian Borgeaud, Yonghui Wu, Jean-Baptiste Alayrac, Jiahui Yu, Radu Soricut, Johan Schalkwyk, Andrew M Dai, Anja Hauth, et Gemini: family of highly capable multimodal models. arXiv preprint 212.:22112.11805, 2023.
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288 2023.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
Mitchell Wortsman, Gabriel Ilharco, Jong Wook Kim, Mike Li, Simon Kornblith, Rebecca Roelofs, Raphael Gontijo Lopes, Hannaneh Hajishirzi, Ali Farhadi, Hongseok Namkoong, et al. Robust fine-tuning of zero-shot models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7959-7971, 2022.
Sang Michael Xie, Aditi Raghunathan, Percy Liang, and Tengyu Ma. An explanation of in-context learning as implicit bayesian inference, 2022.
Steve Yadlowsky, Lyric Doshi, and Nilesh Tripuraneni. Pretraining data mixtures enable narrow model selection capabilities in transformer models. arXiv preprint arXiv:231 1.00871, 2023.
12

---

Published as a conference paper at ICLR 2025
An Yang. Baosong Yang. Binyuan Hui, Bo Zheng. Bowen Yu, Chang Zhou, Chengpeng Li, Chengyuan Li, Dayiheng Liu. Fei Huang, Guamting Dong, Haoran Wei, et al. Qwen2 technical report, 2024. URL
Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models, arXiv preprint arXiv:2210.03629, 2022.
Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In International Conference on Machine Learning, pp. 12697-12706. PMLR, 2021.
13

---

Published as a conference paper at ICLR 2025
A RELATED WORKS
In-context learning In-context learning is unique capability exhibited by LLMs (Chowdhery 2023), allowing LLMs to learn from few examples dynamically
al. 2023; Touvron et al.
without explicit weight updates. It has been tapped to improve accuracy and speed for model
training (Wortsman et al. 2022 Chen et al. 2021 Lester et al. 2021 Min et al., 2021), while related
to model safety (Meade et al. 2023). With rapid expansion of LLMs. recent studies have discovered that ICL ability can be boosted via pretraining (Chen et al., 2022, Min et al. 2022). Meanwhile,
rescarchers have been employing transformers into real-world tasks. Radosavovic al. (2023) and
Radosavoviic et al. (2024) treat humanoid locomotion as a POMDP (Partially observable Markov decision process), and thus it can be regarded next token prediction task. They use in-context learning techniques based on transformer architecture and find it the most robust locomotion predictor, highlighting the significance of figuring
what matters to in-context learning.
Howerver, In-context learning remains a black box. Following Garg et al. 2022), several researchers interpreted ICL implicit finetuing on Transformer, including induction heads (Olsson et al. 2022)
gradient descent (Dai et al. 2023). implicit Bayesian inference (Xie et al. 2022). highlighting the
differences from traditional supervised learning (Caruana & Siculescu-Mizll (206). Li et 2023
formalized ICL as algorithm learning problem, exploring its generalization bounds.
Upon those explanations, what affect the performance of in-context learning matters. Dong al. (2022); ; Liu et al. (2023); /Zhao et al.] (202T). Liu et al. (2023) suggest that ICL is sentsitive to almost all components of the prompt (inputs, outputs, formatting, input-output mapping, order of examples and on). Based on transformers, researchers carried out experiments to study its behaviors. Liu al.] (202T); Lu et al. (202T): Nguyen & Wong (2023) tested on various In-context examples. To further explore the mechanism of In-context learning, Yadlowsky et al. (2023) validated stability of ICL under distribution shifts. Ahuja & Lopez- Pappzz-Pzzlaa (2023) investigated the ability of transformer about its generalization capabilities, preliminarily establishing the generalization ability of transformers.
B IMPLEMENTATION DETAILS OF TRAINING PROCEDURES
B.1 GPT-2 EXPERIMENTS SETUP
Data Construction For the weight function d, initially sample from standard normal distri- bution (00, 1) and clip it to the range [-1, Since both convex combinations and products can yield values exceeding the range of base functions, increase the weights for fixed proportion of functions in the baseline.
Specifically, we define M, max((Vemmmmn) mimi) maz)) and M max MA where Vi,ii is the calculated minimum value by L-BFGS-B (Limited-memory BFGS with Bounds) and Vimaz the same.
For convex combinations, apply the following to 20% of the functions: & |M]. And for products, we employ a similar approach. We choose = II. Mr M While this scale-up does not
exactly match the true value range of the product, it prevents the baseline model from treating the product operation completely out-of-disttibuttin (OOI) task.
To ensure our generated input sequence approximately obeys the gaussian distribution and also
bounded, generate the prompt sequence following two steps. Firstly, sample 2o ~ *N(0, k Ia), where we set A -= Then, we clip the sampled value in zo within the interval [-k, As.. Because the Cumulative Distribution Function (CDF) value of Standard Normal Distribution {(1) 1) = 95.45% is pretty close to full probability, the probability that the sampled value in Fo being clipped is little. Therefore, the resulting distribution of the value in I; still resembles the gaussian distribution, and is bounded within the interval [-n, T..
2
3k
For additional in-context examples d,, we generate two candidate samples x+ = -x +
and
2
3k I_ = ZD 2
respectively, where To ~ N(0 4 La). We randomly select between x. and x. with
14

---

Published as a conference paper at ICLR 2025
equal probability to obtain E,. We can approximately conclude that æ; obeys the mixture distribution
of two guassian distribution and f; E [-2m; -r] U [mr, 2m). We take (di f(x)) ( + 10) as input tuple.
To avoid inaccuracies in analyzing the model's generalization ability caused by mutual approximation between base functions after weighting, we ensure that the expected function values of different base functions have significant we added a bias to each base function. Specificallly, the whole equations for sine and cosine functions are. .
signifcch differences. In the function fitting experiments (Sections 3.1, 3.2, and 3.3),
f(z) = dsin( 2) + (-1)9 * 3/2. f f(z) = ccco((3 x)) + (-1)² 33/2,
(5)
(6)
where B = 1,2.....
For the label noise Section C.I we randomly generate ~ N(0 8 I), where s is the strength of label noise.
Training Procedure We use randomly initialized GPT-2-Standard as base model. The hyper- parameterss are as follow. During training, we set batch_size = 128, learning_ _ateg__ttee___ = 5e - 5. For convex and product combination, combination as the loss is harder to converge. Following Garg et al. (2022), we set dropout 0 because the model will see each input once as we resample each step.
train 50k steps in total, and train 100k steps for composition
Parameter
Value
Embedding size
256
#Layers
12
#Heads
8
Total Parameters
9.5M
B.2 LLAMA-3 EXPERIMENTS EXPERIMENTS SETUP
We use LLaMA-3 8B as our base model, and run 10k steps of supervised finetuning, Each of the SFT data contains 19-shot Kxampoees
Parameter
Value
batch size optimizer learning rate weight _eert_deeyyyy
32
Adam W
5e-6
0.001
max_ max_grad _rrmm norm
parmmup- eeraeatto
0.3
0.03
Ir tr_scheduler_type constant
To generate our data, we firstly select group of x, and each of x contains 20 integers from (-40, 40). We then calculate the corresponding y and get group of (z, y) pairs We take them using the style shown in Figure 7 as our examples. And we use instruction shown in Figure g to control the answer format.
exammi
B.3 DETAILS OF TOOL-CALLIN COOO-CCLLLN MODEL TRAINING
Following Qin et al. 2023) we finetune LLaMA-2-77 2-7B with ReAct Yao et al. 2022) template. Details of EvllEval can be found in Qin's original paper. The dataset consists open- sourced data for training ToMILLaMA and our augmented data using their original pipeline. We also synthesise 0.5k single-turn data and 1 multi-turn turn data using gpt-4o for validation. As we need perform context
15

---

Published as a conference paper at ICLR 2025
Figure In-context exapmle for pretrained model generalization. We give 19 pairs before the final The sampled function is f()) = - -1/
Example of Shots
Example: (-7, -70), (34, -340). (0, 0), (2, -20), (11,, (31,-310) (38.-380), -380), (12, -120), (23, -230), (14, -140), (30,-5 -300), (-25, -25).. (33, -330), (300-300), (-24, -240), (16, -160), (6, -60), (13, -130), (-28, -280), (-31,)
Prediction: <Answer-331<<Answer
Figure 8: Instruction we used for evaluation. We notice that adding task description will reduce square error. We constrain the answer to fntswer><<Answerr as the model will output unrelated words without regularization.
Instruction
Now you are proficient funetion learning, who pairs. Your task to learn a function from (x, y) pairs from given points and predict a y" given x'.
learning math function from (x, y)
Specifically, we'll give you {a points-1] points (x, pairs, and you need to predict the value of the [n. points]-th point.
Please note that you should answer your prediction wrapped <Answer></Answr> like <An- swer241</Answer>.
Here examples. Points formatted as (x, y):
learning, set the model's context length 24588 using the extended Ilama- Furthermore, omitted tokens that repeats the output context, and found no performance drop but more in-context examples. Figure shows the flow of tool calling.
During training phase, we use learning rate of 5 x 10-5, a warpup ratio of x 10-2 and a total batch size of 128. We train the model for two epochs and select the model checkpoint with the best performance on our validation set.
B.4 DETAILS OF TRANSLATION MODEL TRAINING
Pretraining Due to limited computation resource, we use the architecture Qwen2-1.5B and randomly initialize the parameters. We select 2M pieces of English and German corpus from CC10d relatively as our pretraining data. We use a learning of x 10 a warmup ratio of x 10 a total batch size of 192 and epochs in total.
Supervised Finetuning As the spercsourced translation corpus are usually short, which are not suitable for SFT training, choose a two-stage training convention: 1. Use 2k instruction data from Huggingface for each language 2. Use 0.3M translation training data from WMT M We noticed that many pieces of data WMT14 are just word or phrase, which len (I') < 50. We keep the learning rate as 1 x 10-5, a warmup ratio of 4 x 10-2, total batch size 128. The epoch number is set be 3.
filter text 7 for
ht htte:///wuiiiiceeeeoooorrrrrrrrp
70k
format
16

---

Published as a conference paper at ICLR 2025
Figure 9: Examples for bilingual translation task (English and German). We use 5-shot examples to guide the model to output results directly, otherwise will output greeting words and difficult to get rid of.
Few-shot example for en2de translation task
Translate the English into German.
Input: Allotment holders cultivate the soil of former farmers.
Output: Kleingärtner bewirtschaften den einstigen Grund Bauern.
The oldest official map of Munich brings captivating stories light. Oulput: Die älteste offizielle Karte Münchens fördert spannende Geschichten zu Tage.
Input:
Input:
is annoying when geographical maps are not up-to-date. Output:
Few-shot example for de2en translation task
Übersetzen Sie das Deutsche ins Englische.
Importieren: Kleingärtner bewirtschafien den einstigen Grund Bauern. Exportieren: Allotment holders cultivate the soil of former farmers.
Importieren: Die älteste offizielle Karte Münchens fördert spannende Geschichten Tage. Exportieren: The oldest official map Munich brings captivating stories to light.
Importieren: Es nervt, wenn Landkarten nicht aktuell sind. Exportieren:
Figure 10: Examples for mixed translation task (English and German). We few-shot examples guide the model to just output the translated sentence. As the model not fully trained, we cannot avoid greeting words this setting. So manually eliminate abnormal result during test phase.
Few-shot example for mix2en translation task
Here is sentence mixed of English and German. Translate the sentence into English.
Input: Es sind policies und Maßnahmen und corresponding schedules aufzustellen oder weit- erzuentwickeln, z.B. die improvement der Energieeffizienz von Energie, für die Erhöhung des Anteils der Kraft-Wärme-Konn Warme-Kopplung und die use erneuerbarer Energieträger sowie für die reduction der Emissionen in den Bereichen transport und agriculture. Output: Policies and measures and appropriate timetables should be established strengthened, e.g., for the improvement of energy efficiency combined heat and power generation and use of renewable energy sources, and for the reduction of emissions by the transport and agriculture sectors.
Nutzung und production
energy use and production, for increasing the share of
Input: Der wording der opinion ist in Anlage enthalten. Output:
17

---

Published as a conference paper at ICLR 2025
Figure 11: Prompt for mixed corpus generation from English.
Few-shot example for mix2en translation task
Your task is to replace random English phrases from the given text with equivalent German phrases. Ensure that the replacement is natural and the meaning of the sentence remains understandable. Keep the rest of the text in English.
Instructions:
Select random phrases to replace, not necessarily every word.
Maintain the overall readability of the sentence.
Ensure that the German words are grammatically appropriate the context of the English sentence.
# Example1
Input: I went the supermarket yesterday and bought some apples, oranges, and bananas.
Output: went the Supermarkt yesterday and hought Apfel, oranges, and Bananen.
# Example2
Input: The weather was great, so we decided to hiking in the mountains.
Output: Das Wetter war großartig. also beschlossen wir, den Bergen wandern gehen.
Example3
Input: She works as a teacher in a local school, and she loves her job. Oulput: She works as Lehrerin in local Schule, and she loves her job.
Task
Input: Knowledge is power, and with great power comes great responsibility.
Output:
Dataset Construction In order analyze the effect of ICL deeply, sample 500 sentences from the combination of WMT14 and WMT117en2dee test set called WMT500. For each translation task, We firstly filtered out sentences which length are below 20 as they are often just word or phrase. We then use bert sorrtsscordd package
package to evaluate the difficulty of a sentence. We then sample 400 sentences with lowest hert-score for Baseline,as Baseline,.. and CFI and deduplicate them. Finally, we randomly sample 500 sentences from them.
B.5 EXTRA EVALUATION RESULTS FOR TRANSLATION TASK
We provide results using BLEU score 5 Here we give the full evaluation results for our translation task.
BLEUScore BLEU Score is precision- based evaluation metric that measures the overlap between a candidate translation and one or more reference translations. It focuses on n-gram matches while penalizing overly short translations through brevity penalty. is calculated follows:
N wn log Pr.
BLEU BP exp
where:
P.. is the precision of n-gram matches between the candidate translation and the reference translations:
Number of matched n-grams
Pn Total number of n-grams in the candidate translation
(8)
18

---

Published as a conference paper at ICLR 2025
Figure 12: An example for multi-tool calling task. The user gives instruction and the model will do Cofl (Chain of Thought) to solve the problem. If the tool manipulation fails, the model will retry until reaching the limit of context length. As there repeated information (annotated in red), omit the redundant information for token compression.
Example for multi-tool calling task
Thought:
need to search for Python developer jobs in California using the Indeed Jobs API. This will help me gather information about available job opportunities Additionally, need to fetch the details of a specific job with the ID 138024 using the Open To Work Re- mote API. This will provide me with more information about the job and help me make a better decision.
job fair.
Action: searchjobs for indeed indeed_jobs job__oobsaaaa
Action Input: { ""location": "California", "keyword": "Python developer", "offset": 0
Observation:
"response"; "Successfully retrieved Python developer job listings for California. Here are the first
results:
Job Title: Python Developer
Company: ABC Company
Location: San Francisco
Description: We are looking for skilled Python developer join team.
Requirements: Strong knowledge Python, experience with data analysis, and proficiency in data visualization.
2. Job Title: Senior Python Developer
Company: XYZ Corporation
Location: Los Angeles
Description: are seeking senior Python developer to lead our team.
Requirements: Strong leadership skills, experience with Python, and knowledge of data science.
3. Job Title: Python Developer
Company: DEF Inc.
Location: San Diego
Description: We are looking for a Python developer to join our team.
Requirements: Strong knowledge of Python, experience with web development, and proficiency in data analysis."
Action: get_one _one_job______eeoee jtr_jooo_ooroooo_e for_opee_too to_ work work__emmte_app
Action Input: { "is__dd: 138024 }
Observation:
"response": "Successfully retrieved details for job 138024:
Joh Title: Python Developer
Company: ABC Company
Location: San Francisco
Description: We are looking for skilled Python developer join
Requirements: Strong knowledge Python, experience with data analysis, and proficiency in data visualization."
}
Action: Finish
Action Input: { ("returm_typre "give answer", "final, answer": "Here are some Python developer job
opportunities California: (JOB LISTED ABOVE (OMITTED FOR BRIEFNESS)))
Observation: ("error": "Tool input parse error...". "response": : ""J
Thought: have found some Python developer job opportunities in California. Here few
examples:
(JOB LISTED ABOVE (OMITTED FOR BRIEFNESS)
Action: Finish
Action Input: ("return type": "give answer".
"final answer": "Here are some Python developer job opportunities California: (JOB LISTED
ABOVE (OMITTED FOR BRIEFNESS))"
Observation:
("response": "ssuccssfuulllll giving the final answer.")
19

---

Published as a conference paper at ICLR 2025
Table 6: BLEU score performance on WMT14 de2en test set. Pretrained indicates the model pretrained on CC100 and other models are finetuned based on it. BL indicates Baseline models.
Model
mix2en
mix2de
de2en
en2de
Pretrained
28.06
24.26
18.05
17.24
Bl
32.19
27.55
23.45
24.81
BLa
33.31
28.10
25.94
22.37
CFL
34.25
31.68
23.32
22.15
CFL
35.74
30.89
23.10
21.83
CFL
37.02
24.36
CFLaze
31,83
22.37
BL
33.57
28.45
25.02
25.78
BLLL
34.74
29.12
26.73
23.02
II
34.98
32.35
23.47
22.74
CIL
36.27
31.66
23.59
22.29
CCL
37.69
24.36
CFL
32.65
22.45
Wn is the weight assigned to the n-gram precision (lypically ti, v. equally distributed).
BP is the brevity penalty, which accounts for the length difference between the candidate translation and the reference translations:
{
if >
BP
exp 5)
5)
if rr
where the length of the candidate translation and the effective reference length (usually the closest length among all references).
For reproducibility, we use sacrebleu package for evaluation. Results are shown at Table
BERTScore BERTScore is semantic evaluation metric that computes the similarity between candidate translation and reference translations using contextualized embeddings from pre-trained models like BERT. is calculated follows:
Given candidate sentence C f21, C and reference sentence R {r1, r,,,,,,,..ul :nn):
Tokenize C and R and transform them into contextualized embeddings C {c1, (c,,C2,... .., Cm. and R = ,,, using pre-trained BERT model.
2. Compute the cosine similarity between each pair of embeddings:
r
sim(c,, ry) ||c ||r
(10)
For each token in the candidate sentence C, find the maximum similarity with any token in the reference sentence R:
m Σ
(C,
max sim(c,, ry).
(11)
m
jE(l.....)
Similarly, for each token in the reference sentence R, find the maximum similarity with any token in the candidate sentence C:
Rec(C. (C, R)
max sim(c, ry). lE(L....m)
(12)
Compute the harmonic mean (FI score) precision and recall:
Prec(C, C, R) Rec(C, R)
BERTScore(C, Rt) Fi
(13)
Prec(C, R) + Rec(C, R)
For reproducibility, bert_scor package for evaluation. Results shown Table
20

---

Published as a conference paper at ICLR 2025
Table 7: Bertscore(F1) performance on WMT14 de2en test set. Pretrained indicates the model pretrained on CC100 and other models are finetuned based on it. BL indicates Baseline models.
Model
mix2en
mix2de
de2en
cn2de
Pretrained
91.23%
83.15%
69.90%
70.32%
-24
91.97%
84.23%
71.46%
72.57%
B
92.83%
84.21%
73.42%
71.24%
CFL
92.10%
85 65.
71.13%
71.74%
CF
92.55%
85.07%
71.01%
71.53%
CFL
92.74%
73.93%
CFLaze
85.60%
73.11%
Bl BI
92.16%
84.67%
71.93%
73. 14%
BLa++ILL
93.45% %
84.85%
73.85
71.80%
CII. 92.68%
86.58%
71.39%
72.00%
CFI mC.
93.38%
85.76%
71.44%
71.98%
CF ICL
93.29%
74.01%
+IL
86.03%
73.56 %
Table GPT-4o evaluation on WMT14 De2En test set. Pretrained indicates the model pretrained on CC100 and other models are finetuned based on it. BI. indicates Baseline models.
Model
mix2en
mix2de
de2en
en2de
Pretrained
8.58
8.12
6.85
6.57
BLead
9.04
8.65
7.84
8.21
Blan
9.12
8.40
8.38
8.02
CF
8.98
9.04
7.65
7.92
CFLaze
9.24
8.59
7.59
7.85
CFL
9.15
8.36
CFL
9.11
8.28
BLa++CL 9.10
8.84
8.69
Bl ICI 9.23
8.62
8.50
8.17
CIL 9.08
9.14
7.89
8.21
CFL 9.26
8.84
7.77
8.10
CLL 9.22
8.76
CCL
9.31
8.34
LLM-as-a-Judde Measuring the semantic similarity between two languages before and after translation has relied heavily on rule-based and statistical approaches. However, these methods often struggle to capture deeper semantic relationships and contextual nuances. We aim leverage the semantic understanding capabilities of large language models, which excel at capturing contextual meaning and complex linguistic relationships.
Let Ct5 represent the classification score assigned by the model for the i-th case the j-th repetition, where's i E 2........ N (total number of cases) and [1, (number of repetitions). The final score for the i-th case, denoted as S,, is computed as the average of the scores across the three repetitions:
S
Σ
Cajy
Vi (1,
(14)
The overall performance score, Sang. is then calculated as the average of the scores across all cases:
San
S
Cij.
(15)
N
KN
1=1
Specifically, we categorize translation performance into five categories and make LLM to perform the classification task. We take k=3, which means we repeat the process three times for each case, and take the average as final score. You can find the prompt at Figure 14 and results at Table
21

---

Published as a conference paper at ICLR 2025
Table SE of the CoaruerLearneer and Baseline model tested on the product combination base functions under label noise. The product combinations used via training phase is F and F3 Str. indicates the standard deviation of noise. P and indicate partial ICE and all of ICE are with noisy labels, respectively.
Midel
Str.
Range
5003
6033
$12X1
<12x)
Metto
Conu
Meatc
Baseline
3.14e1
1.87e2
3.9e
330e-
4.316-2
381e2
4.3e
3.9e-
4.03c-2
3.33a22
5.176-2
3.1402
1.53-2
188c-
493-2
5.96-2
37ee2
496--2
534c-2
630-2
5.16-2
3.36-3
3.3e-22
3.30-3
3.4e-3
3.Ne-1
3.7e-3
401e:2
3,06-
38162
381e2
391e2
17He1
3.24e-5
1.34e-5
5.We55
6.31e-5
4.3c65
1.6c3
488c-5
3,57e-3
683e3
348c-
183c-
8.7ee
585c3
1.38-1
431c-2
14463
3.9--2
2.5e-1
4.75-2
408e-
5.3e11
4.5e1
3.09222
2776-2
28762
3.302
3,00e2
3.46e2
325622
3.5622
3,01e2
33362
3.46-2
3,5c2
333e2
+ (0116=si((x)H002200oor
-2
-2
.4
4
33
2
0
GT
ICE
Baseline
CFL
CFL (noised)
Baseline (nuised)
Figure 13: Function curves on the product combinations of base functions fitted by the Baseline and ComFuncLearnee models after ICL under label noise, where the standard deviation of noise is 2. The product combination used via training is Fi and F3- The two figures on the left are under partial noise, and full noise on the right.
Figure 14: Prompt for Ilm auduee.
Few-shot example for mix2en translation task
Evaluate the semantic similarity between the following two sentences and provide between and 10. Use the following criteria:
+*1=0; The sentences are completely unrelated, with no semantic connection.
#+2-3*#; The sentences almost unrelated, with very little semantic similarity.
*+4-5*#; The sentences share some similarity, but their overall meaning is quite different.
**6-7**; The sentences are semantically similar, though there are some notable differences.
**8.9*** The sentences are very similar, with only slight differences in meaning.
** 10 The sentences are identical in meaning. with no semantic differences.
Please provide the score wrapped in <Score><//core>> dircctly. Do add any greeting words and analysis!
# Example:
## Input
Sentence I: habe Morgen Kaffee getrunken.
Sentence 2: drank coffee this morning.
## Output
<Score>9</Score>
Task
## Input
Sentence 1: The movie was engaging that didn; It notice the time passing.
Sentence 2: Der Film fesselnd, dass wir die Zeit nicht vergingen bemerkten. #il Output:
22

---

Published as a conference paper at ICLR 2025
C GENERALIZATION UNDER DISTRIBUTION SHIFTS BETWEEN ICL AND TEST SAMPLES
Table 10: SE of the ComFuneLearner and Bascline model tested on the convex of base functions under label noise. Str. indicates the standard deviation of noise. P and F indicate partial ICE and all of ICE are with noisy labels, respectively.
Model
0
5.46-5
2.57e-5
6.85-55
144s-4
7.31e-5
5.29--
1.32e-1
2,6ko-1
1.36-1
7.666-2
7.986-3
3.53e-1
9.25e-2
1
5:15-2
2.26-3
1.67e-2
377o-1
3-44-3
1:75e-2
4.95e-
1
1-70-1
6.75p-
3650-
3:8k-1
1.
Bowelin
6.25077
375--
7.5567
4.53-3
4.7k-1
1.30-2
1.86-1
1.16e-1
180k-1
1.81e1
1.17-1
1Me-2
1.06-1
2
1.3e-1
6.73e1
4.1fe-2
9.20-2
1.77e11
3.22-1
4.10c-1
1.4g-1
4,46-2
323c-]
7.7k-1
1.83e6
2,6665
1.88-4
1996-4
L.22e4
1,53-2
6.45e-4
2.1e2
134622
4.8662
2.76--3
Li2x-1
L.7--2
K.10e-
7:36-1
4.41e33
7:30=3
6.5--
9.7ke-3
1.05-2
3
1.8k-1
2.31
4:5k-2
189-1
CR.
1.3367
7.8%-3
8:10-3
1:30-2
1.96-3
2316-
1.70-1
2.1763
1.76-2
2.5-1
2
7.55e-3
4.3e-3
3,03-3
3.96-3
5
603e-3
1A98-2
2000-
4.22-3
4.48-2
3.7622
1.36e2
Upon our investigation in the main text, we explore the inter- and intra-problem generalization of transformers with ICI., i.e., the performance of the model in ICL. scenarios where the distribution of in-context examples (ICE) differs from the target test data. In real-world applications, the ICE provided to the model may not perfectly reflect the target application's 's data distribution. Therefore, a crucial question arises: how do biased input or noisy labels within ICL impact the intra-task, intra- and inter-problem generalization of transformers?
We consider three critical scenarios when ICL is biased: (1) label noise within ICE, (2) distribution shifts in input data between ICE and test samples, and (3) the combined effect of distribution shifts and noisy labeling. We aim investigate how these challenges influence the model's ability fit known functions and generalize to unseen function combinations. This may help to understand the model's 's robustness and susceptibility to various forms of data uncertainty for assessing its real-world applicability in scenarios where perfect data alignment is often unattainable.
C.1 LABEL NOISE
We explore the impact of noisy labels within ICE on the efficacy of ICL. Following Ahuja & Lopez Paz (2023), we add randomly generated noise N(0 I) the outputs (labels) of ICE, where 7 is the strength of noise and we set it to and in our experiments.
To investigate the effects of varying degrees of label corruption, implemented two noise injection strategies: partial addition and full addition. In the partial addition setting, 10 noisy samples were introduced within the ICF, while the remaining samples maintained their original, unbiased labels. Conversely, the full addition strategy involved contaminating all ICE with noisy labels.
Table 9 and 10 shows the SE of the Baseline and LearereLeamner model at the 40th point with noisy ICE, where each model is fed 39 ICE and predicts the 40th output. Figure [3 shows the curves the models learn after 39 ICE. They show a significant negative impact of label noise on the generalization ability of both models, particularly in the fitting of base functions. This suggests that the presence of inaccurate labels disrupts the models' intra-task and intra-problent generalization.
Moreover, we find a critical aspect of ICL: surprisingly high sensitivity to relatively few noisy samples. Introducing as few as 10 out of 39 ICE with label noise significantly compromised the model's 's generalization ability, irrespective of their position within the sequence.
C.2 BIASED INPUT
We explore the effect of perturbing ICE with samples outside the test data's input range. Specifically,
we control the test sample input sampled in the range (- TT and the additional ICE at (-2T,, ))) and (T, 2T), respectively and add them at the beginning and end of the in-context sequence.
Please note that the outputs of these additional ICE are still generated with the groud-truth function. While it might be expected that these additional inputs, due to their nor-overlapping input range with the test samples and still retaining the ground truth function, would not significantly influence the predictions, our experiments revealed a surprising result. Adding these out-of of-renge ICE significantly hampered the model's generalization to the test samples.
23

---

Published as a conference paper at ICLR 2025
Table 11: SE of the ComFuncLearnee and Baseline model tested on the product combinations of base functions with biased ICE. The product combinations used via training phase is F(0) and Fi Type indicates the type of bias in ICE and O indicates no bias. In and I&O indicate based input and based input and output, respectively.
Model
Type
604
o124
Means
<0489920)
Comuu
Mease
6.15e-5
8,5ke4
3,5e-5
4,33-5
2.19e-
142x2
1,4k-3
928p-3
1:30e11
8.59e2
2.31e1
6.07e:
2
1.34--1
2.11e1
5.40e1
9.33e1
2.3c-1
2.01e11
1,07
3.5te1
Baseline
1s
40
1516-2
1.33-2
4.91c2
491c2
2.46o22
8.87022
1.99-2
1.75s-1
1.56e2
3.1c2
1.30c2
197T-1
9.70-2
I&0
70
4.96-2
1:89-1
4.73-2
1.5e-3
6:16e1
8.512-3
2.31e1
4.62-1
140p-1
199e-1
1.8e-1
4.1e-2
1.3te1
14.0
40
2.796-2
5.55g22
1.7262
3.56-12
3,40c2
8.39
1.00-1
2.15:-1
5.396-2
4/64-22
4.57622
3.46-1
1.27e1
3.246-5
L34-55
6.50-5
131e5
4.8k65
8.46-3
4.36-5
6.196-3
8.36-
7.3464
436c-3
9.75
2136-2
5.5ke3
3936-2
103c-1
140
70
2.63-1
1.19-1
4.86-3
3.%vol
3.0%-1
4.26--2
5.89-1
1:34
2.53-11
1-96-1
4.0k-1
483x-
4.15cl
140
40
3.62-2
6.2622
18762
2.86-2
3
4.152-2
6.0622
1866-1
5.0062
5.136-2
3.56
164c-1
3.55e22
Table 12: SE of the ComFuncl and Baseline model tested on the convex combinations of base functions with biased ICE. Type indicates the type of bias in ICE and 0 indicates no bias. In and I&O indicate based input and based input and output respectively.
Model
Type
Pos
3031
4101
s12X)
41241
Meens
MX345120
40184422))
21AMLH224)
CoslAll
Meate
L.55e.5
7.02e-5
5.29p5
4.603
2.56-1
1.39-3
8.13-3
5.35c2
Roollir
1.90m-1
104r-1
715--
1.9k-1
1.56-1
1-7k-3
300e-1
6106-1
5.0c-1
3.3el1
5.9%-
985e-1
4.36el
180
20
2.69e-1
1.21c
1.33x11
3.0k=1
2.28c-1
7.91e-2
4.8c-1
0.34-11
7.686-1
4,7Kc1
1.59c1
L.4c0
6.71e-1
16n
40
1.88e-1
1.34--1
3680-
1.0-1
141o-
6.1o01
304--1
6.3%--
5.80-1
4.00-1
7.09-3
125:0
471c-1
4.47e46
1.17x-8
1.0e-4
1.36e4
K79e4
5.00-3
378r-4
1.26-3
SA5e-3
2.17e3
1,0-3
443e3
286e-3
1.53e-2
1.96-2
6.2x-3
2
1.4e-2
1.56-1
4.0s-2
1.39-2
5.7261
1376-2
8266-2
3.36-
IA0
1.946-2
3.67-3
2.51-1
K-96-1
4.9k-
1.30-1
403--2
9.1362
6.66-2
6.5--1
1:76-1
1.26-1
5.1%-2
180
2.59633
3.99
125
2.26
1.336-
3
3.5083
1
1
6,34
2.00
133g-1
1.0e2
Table IT] 12 and Figure [ show the effect of augmenting ICE with 10 out-of-range input samples both before and after the standard sequence of 20 examples, respectively. Here we set the combination of base functions the product combinations and more results with other combinations are in Appendix.
Both the Baseline and ComFuncLeamer model exhibits vulnerability to augmentation with out-of- range samples. Notably, their performance significantly declines not only on unseen combinations of base functions but also on the fitting of seen base functions. This counterintuitive observation holds regardless of whether the out-of-ran -range samples are placed the beginning or end of the in-context sequence. Thus the presence of biased input in ICE disrupts both intra-task and intra- -traleroblem generalization of transformers.
C.3 BIASED INPUT AND OUTPUT
To investigate the influence of severely biased examples on ICL, we implement a scenario where some ICE intentionally lie outside the test data's input range whose output is biased. Specifically, we confine the test sample imput range to (-T, TT) while placing additional OOD examples at (-2iT, -x) deliberately introduce constant offset of 10 to their outputs, modifying them to y f( Φ:) + 10, where fz(:; Φb) is the ground-truth function for the current sequence and y is the outputs of ICE. These OOD examples inserted at the beginning and end of the in-context sequence. Similar to Section C.2, as shown in Table IT and Figure [5] both Baseline and ComFunc models demonstrate remarkable susceptibility ICE with biased input and output. The trend persists regardless of the placement of out-of-range samples within the sequence, suggesting that the presence of biased input disrupts both intra-task and intra-problem generalization of transformers.
and (T, 2x).
D SUPPLEMENTARY RESULTS
D.1 FUNCTION FITTING ON PRETRAINED GPT-2
At Section 3.1 and Section 3.2 we take the base functions ((0) , F .F.00) ;))(()))))))) defined in 2.3 and
the combination of (()) [ To support the phenomenon that transformers gain ability to solve intra- pitra-problem generalization when trained with corresponding combinations of base functions, we test different settings to further validate the conclusion.
24

---

Published as a conference paper at ICLR 2025
0.55 (55
+0.09*sin(22)00007000222
10
1.5
2.5
0.0
0 GT
ICB
Biseline
CFL
CFL (biosed)
* Boseline (biased)
Figure 15: Function curves on the product combinations of base functions fitted by the Baseline and ComFuneLearner models after ICL with biased ICE. The product combination used via training is F1 and Fz. Upper figures give points outside the domain of definition during the training phase (Type I), and the lower figures additionally modify the value of y outside the domain. (Type I&O)
tut 305
4.5
Ypa sage
Tojjet Larritt
371
eura btals Baac
60
Figure 16: Function curves of the Baseline models tested on the convex combinations base functions. The shared base functions are ((( -= (() means it is trained on 50 additionally, while model w/ extra basis function indicates that it is trained only on shared base functions. We keep total training steps the same.
(0) (0) Model w/o extra basis function
Baseline Learned with Base Functions To verify whether cross-problem generalization can be achieved solely by increasing the amount of data, we conducted additional experiments where the model was trained with more data from only base functions and tested on various function fitting tasks. The results shown in Table [3] The conclusion drawn from these experiments is consistent with the main text: the transformer model only achieves intra-tase task and intra-problem generalization, but not inter-problem generalization.
25

---

Published as a conference paper at ICLR 2025
Table 13: SE of the CaarereLearner and Baseline model tested on the convex combinations of base functions, where the Baseline model is learned on 4 base functions and the same number of samples as the ComFuneLeamne model.
Rong:
Modd
<(2g)
Mrany
<ts/4a(25)
Cama
Mon:
1-10
Buselite
CFL
2.3e 1
1.3le2
3.82=2
2,48e 1
6,468 2
1266
4.268:2
1,51e
2.66s
1,8e
5018
1.98.2
4,48c-3
8,00s
5336-2
1.96-2
1,49:22
1.396
5.95e
1,388
2.9e
1.1ee2
5,03
1.7k22
2.93x
1.35:
11-20
Baselino
CFL
6,560 3
5.99p4
8.15e4
1,07
2.11e3
199k-4
4.7e-4
1.3002
8.38e
5.7o-4
211r-3
3.32-3
2.36c4
5.260-5
3826-
417e-1
38263
7.53--
5.90-5
4,4824
2:18e-3
199e-1
4.59
K.19--
2,6633
1,00=1
Baselino
440k-44
1,00e33
1.85-4
5.7264
535e-4
2.26e33
4.30-5
306e-1
6.99-
5,3ee8
191e-1
1.0t-3
6336-
9.45-3
1.56-1
1.50-2
8.06-1
2.00-3
2,41e4
3.46-3
4.00-3
5.00-4
24W-1
4.7e-3
2.86-3
7.7864
5466-4
2246-3
1.26-3
5.4655
3.3b.3
9.16-3
1.36--3
357e3
5,56-
Table 14: SE of the Cearee and Baseline model tested on the convex combinations of base functions, where the Baseline model is learned 4 base functions and the same number of samples as the CerrnerLearner model. The convex combination F1
+ F2
#0088c1200
#208c120
1-10
Rouline
CEL
521e22
1,37ex00
9.85
8.20p2
2.37e-1
2.18c-2
8.66
6.1ed
3,96
7,00 3
141e22
5.23o-
7,4e
2,01x-2
7.66e3
2.45e
1.71o2
4886-3
1996.3
1.3c22
1826-3
1.56 3
4,3e.3
1.96-22
11-20
Bootine
CEL
4.36
7886-4
461c-3
1826-3
700re4
295c4
6.50-4
181e4
6.55e4
1-6e-
3,99
2.666-1
3.16-5
1.70x
8656-
4.256-5
2,800
8.1k-1
1.1765
4.56-
1716-5
8866-1
1.3e-5
2736-
Bastine
4.47e-4
5186-3
6Mted
4.0k-4
3.T9e-
518-1
7.56-1
4.90-
5756-
780e1
2176.3
1.79c44
735e-4
3.1e-5
2886-5
2946-
1.2e6
1626-
22765
31-40
1.78-4
230x
290e-5
2.1365
1
2.3e5
Convex Combination Generalization with ComFuncl_earne Learning other Combinations Here, we keep the base function classes defined in Section 3.1 and let the ComFuncl Leanerr model
leverages convex combination of =(()) and F( i.e., F2
+ +F The Baseline model is trained on
all base function classes and F:(O) {dsin(3x)) & R.. Results are shown in Figure 17
We also
carry out experiment on F( + F(()) Results can be found at Figure 18 and Table 14
Composition Generalization At Section 3.3
we select four base function classes
T F())) F()) To evaluate the significance of baseline function classes, we implemented class numbers to 16. The base functions classes now include F(()), 1, 16, namely (onkn)k)), & = 1,2, .8....8 U cocos z).k k = 1.). Other settings keep the same. The re-
sult showed Figure 19
D.2 FUNCTION FITTING ON PRETRAINED LLAMA SERIES
To further validate our findings, we conducted additional experiments focusing on convex and multiply combinations on pretrained LLaMA-3. These experiments aimed to assess the model's performance for intra-problem and intra-task generalization.
Figure 20 that when exposed to convex combinations, the model still struggles with inter- problem generalization, while successfully leveraging its prior knowledge to address intra-problem and intra-task generalization.
These additional experiments reinforce assertion that the diversity and representativeness of the finetuning dataset play a pivotal role in enhancing the model's generalization capabilities.
We carried the same experiments LLaMA-2-7b-ht and found similar conclusion. Results can be found at Figure 21 22
D.3 REVERSE INTER-PROBLEM AND INTRA-PROBLEM
To investigate whether the observed inter- and intra- intra-problem generalization behaviors hold when the roles of base functions and their combinations reversed, conducted the following supplementary experiment. In contrast to the experimental setup in the main text, we now explore whether a model exposed to diverse combinations of base functions can generalize base function fitting tasks.
26

---

Published as a conference paper at ICLR 2025
(osttt (d
Wwyh
marda WAN
Figure 17: Results of the ConFueceeearner and Baseline model tested on the convex combinations of base functions. The convex combinations used via training phase is F:(O) and F(() GT refers to ground truth. CC refers to ComFuncLearner and Zero Estimator refers to constant function f(z) = 1.
27

---

Published as a conference paper at ICLR 2025
RAy Bittheee Spfreed))
f00 teaekg 42
Cayee
13
05
65
13
15
G1
ConFindeeam
Baacline
Figure 18: Function curves of the two Baseline models tested on the convex combinations base functions. The base functions are F _ =()) F(O)
We change the convex combination from
F F F(0)
Table 15: SE of the ComFuncLearmer and Baseline model, which trained on reversed data, tested on the product combinations of base functions.
Skeps
x043
13.33
<(<
Cemua
Meas::
2.756
7.178
1883
Bascline
1.30-2
1.30-2
1.5k-3
L676-1
5.64-2
1.35e2
1.28c-2
100c2
L.36-
1.36-2
161s-1
5.63=2
1044-2
1.03e-3
1.00e-2
1.7M-2
1.33e-2
1.3e-2
1itee1
1.4e2
1.06-2
1.8k-1
1,37e2
4.62e2
2.20e:2
20le-1
7,5te
201
1.4c-2
1.57e-2
1.11e2
1.63-2
1.34-2
1.5cc22
L.22-2
1.56-1
1.58-2
177pl
1.73-2
Li6e-]
5.1822
CFL
30k
9.20-3
1.3e-2
8.34e-3
1.55a-2
1.18:2
1.366-2
8.80-3
1516-
1.26622
1.40-1
1.4682
L37e
5.66:
4.4
1002-3
6.19--
1.51-2
1-76-2
1446-1
9.4e-1
1.35-3
1.56-3
Li1e1
1856-2
1.7p-1
5.00-2
504
8,5763
386-
7,33-3
1.36-2
1.0r-2
1.36-1
8.00-3
1.36-3
1.446-2
1656-1
1.56-2
133p-]
5.21o22
The results demonstrate that our findings hold even when we reverse the roles of composite functions and base functions, treating function combinations Thase and the base functions (which can be approximated as combinations of multiple combinations of functions) as Teom This further reinforces our conclusion that transformers with ICL enable intra-problem generalization but not inter-problem generalization.
The Baseline model is trained solely F + (0) F +
combinations of 4 functions:
(J(() + Fi +F(0))
The ComF FomFuncLeen Learner is trained on the same 4 function combinations the Baseline
model, but additionally exposed one base function: (F(())
The results shown in table 15
D.4 CURRICULUM LEARNING
To investigate the influence of data point order and sample difficulty on the generalization ability of the transformer, designed the following experiments:
For the Caarer,, we designed a two-stage training process. In the first 25,000 iterations, the model learns only the base functions. Subsequently, in the next 25,000 iterations, it is exposed to the combined functions. We then compare the performance of this model with a ComFuncLeameer trained on a random sequence of samples. The results are presented Table T6
We find that training the model on base functions first, followed by combined functions, does not further improve its generalization ability. In fact, it results in worse generalization performance compared to model trained with randomly sampled data. This could be attributed to the need for careful tuning of the ratio iterations dedicated to learning base functions versus combined functions to achieve optimal performance.
D.5
GENERALIZATION ON OTHER BASE FUNCTION CLASSES
Aiming at analyzing the model's ability to generalize across different function classes, we conduct experiments on another set of base functions. Inspired by Legendre polynomials, we select new base functions as follows.
(1) VL
30
[
28

---

Published as a conference paper at ICLR 2025
1.0
65
68
0.0
+6.
-013
RAY L0P"onCiie
Fit Iii--BaPsaaeeeaaal
RX0 2000
fiyy L.BPsinZewsaa
68
Rxy S00-1a-
[i) (e)
1.0
12
6.5
6.0
Base line
(biieed)
Basel (istlase))
3.8
30125
30332
20355
30215
X011
0031
2.10
230
14100
1354
330
C112
CFLA
Baseline
0.00
Figure 19: Result of of the ComFunc and Baseline model tested on the composition com- binations of base functions. To delve deeper into the effect of base function diversity, we increase the function number to 16 (Jr(() i 1, ,., 16). However, we do not find significantly drop in SE compared to six functions in 3.3 with at most four combinations
Table 16: SE of the model tested on the product combinations of base functions. CFL11 CL means CFL11 learned with curriculum learning.
Model
5033
c03
<02x)
Meata
500880003
500880220)
c00829120
$120860120)
Comuus
Mease
Reseline
2.53e-5
7.34-65
16te-
3.71e55
1.1765
2.8661
7.76-3
2.70.-1
8.60-3
8.53-3
S21e-3
5.06e-2
1.08p-2
CFLI
1.82e-8
6.5e-6
365e-5
3.76-
2.3te-5
3.16-3
499c-8
7.58e-3
2.4e-2
1.16e-2
1.59e-
9.88e-
5.24e-3
CRLLCC
338e-3
7.82e-3
3-bb-3
7.52e-3
5.49e-3
7.81e-3
2.89-3
7.46e-3
8.02-3
1.M0e-2
833e 3
4.06e
9.92e-3
29

---

Published as a conference paper at ICLR 2025
Bxjm250's
100ed2he1d
2000
2004
6x0-th
2010
2000
2000
CornFurel.ooneer
Boseline
2000
Figure 20: The performance of LLaMA-3 on convex combinations of learned functions (x, x.2 x and )² Baseline indicates LLaMA-3-88 finetuned with base functions. ComfuncLearner indicates LLaMA-3-8B finetuned with base functions and the combination of x² and x².
1o0m-92bb
Rxy-ld'12
10
100
675
0
Gf
CocsF LocLEae
Baiclas
Figure 21: The fitted curves of LLaMa-2 composition combinations of learned functions (absolute value functions - x and quadratic function x2).
LL 50
v2
(3x²
-25)
(3) 770
(x3 15x)
VL 500
VL 10000
(4)
Tv
(7x* - 150x² + 375)
The training data was derived from these functions, and the model was subsequently evaluated on various function fitting tasks. The results, presented and Table align with the findings in the main text: while the transformer model demonstrates strong intra-task and intra-problem generalization, it fails to achieve inter-problem generalization, even when trained on mathematically diverse base functions like the polynomials.
Table 17: SE of models tested on the convex combinations of polynomials.
Range
Model
x²
Memn
s&xx
xkx
x'8xx
<'8x'
<"dex"
Comar
Menne
1-10
Baseline
2.1ee-1
5356-2
5966-2
1.8e-1
2.57e1
3,58e-1
2.00-1
1.7261
1.55-3
1.54e22
1400e2
7.55e3
233e.
1.2le-3
8.59p
8.46-3
399e=3
3446-3
491o-3
4.95e33
9.126-
1.25e-2
11-20
Baseline
CFL
2A8e-2
2336
3336-3
1.0e
6.7263
1.21e3
2.10
5.02e2
2.41e:2
1.36e-2
8.08--3
6.53e
7.36-3
3.52
4.26e
7.5k-11
2.15e3
5106-3
5.02e-3
814444
1.22e4
3.0e-3
394e
488e-3
3.3e
21-30
Baseline
CFL
2.1le2
1.50e2
2.0e:2
5.67e-3
L18e3
6.6e-3
1.7e21
3.45e2
2.05e-2
9.3e
7.47e:3
5.85e33
1.41e:3
347e33
2.5e
3.53e:
7.4e-3
191e
4.26-3
3.76-3
8.90e4
6.53e4
4.0c3
433e3
3.39;
4.1e.3
4.2e-3
6656-3
7.99-4
466e3
1.362
7.726-3
2.376-2
1.626-2
3.716-3
1.86-3
6.51e-4
4.16e3
323e-3
30

---

Published as a conference paper at ICLR 2025
-800% +12hx"3
10
033
+05
O
G1
ConFFrncLoaae
Baacllae
Figure 22: The fitted curves of LLaMa-2 on composition combinations of learned functions (x, x2 x33 and )
Rxp=-877Pssiici 18.55cml22)
NXy-00990 8.18" cos(26)
Rx)- 1.0--100-ttts--1 couti
69
O Gf
ConFrnnLeame
Besclise
Function curves the Carrur and Baseline model tested on the convex combinations of base polynomials.
Figure 23:
D.6 GENERALIZATION ON OTHER STRUCTURES
We conduct further experiments with other model architectures, including MLP and KAN. The results
are presented Table 18 T9 and Figure 24 25
We surprised find that the generalization behavior observed in transformers persists in these other network architectures. This opens up exciting avenues for future research. is important to note that this should be strictly termed "in-context learning" for MLP and KAN. Since these models require fixed input and output dimensions, our experimental setup necessitates feeding 39 (x, f(x)) pairs along with the 40-th input, and the model predicts only the 40th f(x). This differs from the sequential prediction capability of transformers in ICL. However, we believe that our findings regarding generalization limitations may extend beyond transformers and ICL, potentially applying to other deep learning architectures and tasks.
Ra-- Ro0-100
BA 100--
NX0 -0.55eees000000000oee (.00000220
10
62
60
-10
ComFuncaame
Baseliar
Figure 24: Function curves of models trained on MLP architecture. The setting is the same Section
31

---

Published as a conference paper at ICLR 2025
Table 18: SE of models trained on MLP architecture. The setting is the same as Section 3
Rang=
633
<(20
Mrany
<33lbe200
Cam
Monn
Baseline
1:7782
7.3e-3
1,41:3
2.26-4
3,00c:
1.1922
147e.1
964c4
3.36:3
4.1624
1.00-3
9.158
2.49c
21-30
Basetine
CFL
4,70g
1.39e-1
1.8883
1,00-22
889e-3
1.7203
1.70e1
1.7602
1
5.0g
5.Ne-3
1,6764
900e4
191c4
240c4
1.50-3
4,3ke4
6.765
3.56-
2.5e-1
2.76-4
4.4cc-5
2.36
1.74e-
31-40
Baseline
CHI,
34de22
1.33-1
2.35e2
9.85-4
2.13e-3
1
7.40e2
1.76e11
5.89e7
1.6ee2
4.590-
5.d1e4
1.42-4
10ted1
1.7c4
2256-3
200
5.8c5
1.90e
38te-1
24Re-4
4.60-5
2,5g-
1.Me-
1.86-
8,)--11000 wwwp0//"coooo/oooooooooooooo
Bascluz
Figure 25: Function curves of models trained on KAN architecture. The setting is the same as Section
Table 19: SE table of models trained on KAN architecture. The setting is the same as Section
Ringe
600
#/3
<120)
Meano
900801220
5008e01201
c00885220
c008cc20)
#2x18c1221
Comus
Meonc
1:15-2
9.5k--
2.90-3
7.50e
9.26e
1.79
1.0e
3.20
4.58
1.268
255e
2.15c
11:20
Baselino
CRL
3.40o44
9.546-3
1.370-
1.14e=2
7.86-
3.16e3
3.86-4
8.17e1
8.5p-1
1.306-2
182r-4
2886-3
2.36-4
3.9%-5
4166-4
288e-1
4.5s-
9.20e4
1.0%-4
2.5e-4
2.31m-1
2.3r-
1.00
1.6b-
21:30
Buseline CRI.
7.88-4
1.63-2
3.59<2
1.33-5
659c2
1.006-1
1.3622
7.76-4
3.3662
1.006-1
601e-3
A81e-4
6.18c33
1.806-4
6.1663
41764
9,06-3
4.55-4
1.6633
1.96-4
498-
2.0
3.00g3
2.58-4
541a3
3.564
31 40
Buseline
7.86-4
1.10c2
1.58-2
7.69e-4
2.68-22
7.3464
9.9763
6.14-44
7.83-4
1.6762
3.0c-3
4.8c-3
1,50-4
411c-3
295-44
5.8c-3
3.20-
1.00-3
1.M0p4
276e-3
3.56-4
222c-3
2
3.40:-3
2.Wp-
32


Reviews:
[{"review_id": "ofbTpVYSDs", "reviewer": "Reviewer_udL3", "summary": "The paper presents an empirical study which seeks to advance our understanding of the in-context learning abilities of transformers.  It identifies three different types of generalization, depending on the training and test data: inter-problem (ICL of completely unseen problems), intra-problem (ICL of similar tasks) and intra-task generalization (ICL of already seen tasks).\nExperimental results are presented on synthetic data, involving trigonometric functions, as well as more realistic settings, namely tool-calling and translation.", "questions": "On line 213, you state that you add a third class in order to balance the data for the Baseline model. Why did you not just sample more data from the 4 base function classes?\n\nDo you expect your results to hold for a different class of functions, s.a. polynomials?\n\nDo you expect similar results for non-transformer architectures?", "limitations": "", "rating": 8, "confidence": 3, "soundness": 4, "presentation": 4, "contribution": 3, "strengths": "Pros: Addresses an important problem in a systematic way.; Clearly defined research questions and synthetic data. ;Extensive experiments.; Provides actionable insight for training transformers;", "weaknesses": "Cons: \n\nIt is not clear to me that the chosen synthetic functions are representative of ICL tasks that we care about, and that the conclusions drawn from them would be applicable to other synthetic functions.\n\nHaving a non-transformer baseline would have been useful in order to understand if the observed behaviours can differ, based on the architectures.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "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": "N1AtD8QlsW", "reviewer": "Reviewer_XdrE", "summary": "This work investigates the generalization boundary of transformers' in-context learning. \n\nThe authors propose systematically exploring this problem through three dimensions: (i) inter-problem: generalization on problem combination; (ii) intra-problem: generalization across problem combination with guidance; and (iii) intra-task: in-domain generalization. \n\nThey conduct experiments on function fitting, API calling, and translation and shed light on strategically designing training data by leveraging the intra-problem and intra-task generalization of ICL.", "questions": "* The performance improvement on simple tasks when incorporating combination data is intriguing. \n    - To ensure a fair comparison, did you control the training data size to have an equal number of samples related to the target simple tasks? From my understanding, combination data should also be factored in as they provide supplementary knowledge. \n    - Additionally, have you tried a reverse inter- and intra-problem generalization setup to explore how effectively the model can learn directly from combination data? This could help better understand the generalization mechanism across different conditions. \n\n* Regarding the ComFuncLearner setting, did you observe any impact of data point order, such as when using a curriculum learning schedule? It seems feasible that learning samples from easy to hard could affect the model's performance, particularly for complex generalization tasks.\n\n* Why choose $\\mathcal{F}_5^{(0)}$ to be included in Baseline? It seems unrelated to the functions of interest and may hinder the performance.", "limitations": "", "rating": 6, "confidence": 3, "soundness": 3, "presentation": 2, "contribution": 3, "strengths": "* **Well-scoped problem formulation**.\nThis paper studies three different dimensions of the generalization with ICL in well-scoped scenarios with a clearly defined experimental protocol. The task formulation corresponding to each research question is clear and adaptable, making it straightforward to generalize findings across the chosen real-world domains.\n\n* **Comprehensive analysis and extended experiments**.\nThis paper conducts comprehensive experiments that strongly support their conclusions. There are also smart experiment designs in different scenarios to interpret the performance trend across different approaches. I also find the experimental setups sharp and non-trivial in real-world tasks such as tool calls.\n\n* **Convincing and intriguing results**.\nThe analysis regarding intra-problem generalization and how it works in different tasks provides insights into how data diversity and combinations can augment training for better generalization.", "weaknesses": "* **Lack of analysis for a mechanistic understanding of intra-problem generalization**.\nWhile intra-problem generalization appears crucial to ICL, the paper does not sufficiently explore the mechanisms behind this phenomenon. They show that transformers excel in intra-problem generalization across function-combination operators, yet it's unclear how to disentangle the effect of training data in terms of the knowledge derived from functions versus operators. For example, the operator is like a second-order function that can be generalized to higher-order ones, which is particularly pertinent in real-world applications. More in-depth analysis or discussion on this would enhance the work's generalizability and provide greater insights into the workings of intra-problem generalization.\n\n* **Simple task formulation that may not apply to complex natural language tasks**.\nWhile the experiments cover domains like tool usage and provide consistent results, how these findings apply to complex natural language tasks, such as reasoning, is still unclear. For example, results on Llama3 suggest that pre-trained language models may struggle with function fitting despite extensive training corpora. This highlights a domain shift challenge that could be especially relevant for NLP tasks due to the inherent diversity in language. Addressing this limitation or providing additional insights into generalization on natural language tasks could broaden the study’s applicability.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "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": "4DmI08Z5LH", "reviewer": "Reviewer_Htfn", "summary": "The present work studies in-context learning (ICL) generalization. The authors’ ICL problems considered sinusoidal functions with varying frequencies and amplitudes (Eq. 2) as basis functions, and additive, multiplicative, or compositional combinations of two of such sinusoidal basis functions (Eq. 3). They considered 3 axes for ICL generalization:\n* Inter-problem generalization: Can models trained on the basis functions alone generalize to additive, multiplicative, or compositional combinations of functions?\n* Intra-problem generalization: Can a model trained on some functions generalize to other, functionally very distinct functions (e.g., combinations of functions with different frequencies)?\n* Intra-task generalization: Can a model trained on some functions generalize to functionally similar functions (e.g., only changes in amplitude that don’t change the x-positions of characteristic points like minima)?\n\nThroughout the experiments, the authors found that transformers show intra-task and intra-problem but lacked inter-problem generalization (Secs. 3 & 4). They partially verified that these findings on synthetic data also hold on real data (Sec. 4). They conclude that task diversity is essential for improved ICL generalization.", "questions": "* **Q1**: What is the meaning of the superscripts in Eq. 2 and other equations? I.e., what does $(0)$ mean? It appears that it is always the same throughout the paper and seems unnecessary (e.g., superscripts are absent in Eq. 3).\n\n* **Q2**: What is the range of $\\phi$ in the experiments?\n\n* **Q3**: Are the GPT-2 models trained with permutation invariance? If either yes or no, why? I think it’d be meaningful to train it with permutation invariance, as it better fits the considered sinusoidal ICL problems (Eqs. 2 & 3).\n\n* **Q4**: How are test functions generated, e.g., in Fig. 2? For example, Fig. 2 left (similar Fig. 3 left) shows $f(x)=sin(x)-0.5$. However, this is different from the functions defined in Eqs. 2 & 3 or Fig. 1, e.g., $\\mathcal{F}^{(0)}_1=\\lbrace\\phi sin(x): \\phi\\in\\mathbb{R}\\rbrace$. Importantly, that may influence the results. This could impact the results, as seen in Fig. 2 (second plot from the left), where both methods closely follow the sinusoidal shape but appear shifted.\n\n* **Q5**: l. 255-258: should it be Baseline instead of ComFuncLearner? If not, could you please clarify what is meant in that sentence?\n\n* **Q6**: Do the findings from Sec. 3.1 also hold when we train the ComFuncLearner on the convex combination $\\mathcal{F}_1^{(0)}+\\mathcal{F}_2^{(0)}$ instead of $\\mathcal{F}_1^{(0)}+\\mathcal{F}_3^{(0)}$?\n\n* **Q7**: Why was Llama-3 chosen in Sec. 3.4? The experiments would be more consistent if they also used Llama 2, as in Sec. 4 (as they must for fair comparison with ToolLlama).\n\n* **Q8**: Can you provide results for the mixed translation task (Sec. 4.2)?\n\n* **Q9**: How do the authors account for synonyms/paraphrases in the translation experiments (Sec. 4.2)? I tried to input the English output sentence (“Policies and measures…”, Fig. 10) into different translators and translated them to German and back to English. They often yielded very different sentences but the core meaning remained the same. Other metrics than BLUE, e.g., BertScore, may be better fit. \n\n## Suggestions\n\n* **S1**: Most experimental Figs. & Tabs: I suggest writing out the functions (e.g., f(x)=sin(x)) instead of the current format of the subplot titles or table entries. For example, in Tab. 3 & Fig. 4 for compositional combinations, it’s challenging for readers’ to figure out what’s the inner and outer function at a glance.\n\n* **S2**: The paragraph in l. 263-265 appears to address two separate things that could be separated for clarity.\n\n* **S3**: It'd be good to add the description of the ComFuncLearner model variants in l. 364-366 also in Sec. 3.2.\n\n* **S4**: The meaning of the red numbers in Table 4 should be clarified, especially since the number for Baseline+ICL_s under Average_s is not directly computable from the table (likely due to rounding).", "limitations": "", "rating": 6, "confidence": 4, "soundness": 2, "presentation": 3, "contribution": 2, "strengths": "* **S1**: The work’s systematic setup across the three axes is very well-designed (Secs. 2.2 & 2.3). The real-word experiments (Sec. 4) are also set up sensibly.\n\n* **S2**: The results for compositional combinations are validated on real data and commonly used LLMs. Findings and conclusions from the synthetic experiments from Sec. 3.3 also hold on real data for compositional tasks.\n\n* **S3**: The paper is generally well-written and clear (except the minor points from the questions/suggestions below).\n\n* **S4**: The paper studies a problem that I believe is relevant to the research community. Understanding when ICL will generalize and when it will not is an important research question.", "weaknesses": "* **W1** (also see **Q4**): The paper claims that “transformers lack inter-problem generalization with ICL” (l. 19), yet Fig. 2 left or Fig. 3 left show that transformers generalize to y-axis shifted sinusoids (to a certain extent). This seems contradictory. A more nuanced analysis of when transformers can and cannot generalize across ICL problems would strengthen the paper.\n\n* **W2**: The finding that task diversity aids inter-problem generalization is neither novel nor surprising. This is a known reason, e.g., for training LLMs on large, diverse text corpora, as diversity is known to be a key ingredient for generalization. Other popular research areas (e.g., model robustness) also found that data is a key factor. That this is also the case for ICL generalization is expected.\n\n* **W3**: The paper does not offer new insights when transformers do or do not generalize in ICL, particularly in inter-problem generalization. For instance, I think it is clear that the baseline transformer won’t generalize to convex combinations with basis functions with different frequencies (e.g., $sin(x)+sin(2x)$) when trained only on sinusoidals with the same frequency, as these combinations are not well-supported by the training data.\n\n* **W4**: It seems that the combined ICL problems in Eq. 3 will have function values outside the range of those in models trained only on the basis function from Eq. 2. However, this may also be a misunderstanding, as the values for $\\phi$ in the experiments are not provided (see **Q2**).\n\n* **W5**: The experiments on convex combinations (Sec. 3.1) and product combinations (Sec. 3.2) are unrelated to the real-word experiments in Sec. 4. It is unclear whether the findings on the synthetic data also hold in the real-world setting for these combinations.\n\n* **W6**: Code is not provided and certain details are missing, e.g., range of $\\phi$. Providing code or ensuring all needed experimental details are provided would enhance the paper’s reproducibility.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "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:

Decision: Accept (Poster)