In-Context Function Learning in Large Language Models

Elif Akata, Konstantinos Voudouris, Vincent Fortuin, Eric Schulz

TL;DR

This paper frames in-context learning (ICL) in Large Language Models (LLMs) as Gaussian Process (GP) regression, revealing that LLMs exhibit inductive biases towards rougher functions in lower dimensions. Crucially, they demonstrate that post-training methods like reinforcement learning can effectively steer these biases towards smoother functions, improving sample efficiency.

What Problem Does This Paper Address?

Large Language Models (LLMs) have shown a remarkable ability to learn new tasks from just a few examples provided at inference time, a phenomenon known as in-context learning (ICL). While this capability is powerful for tasks like text generation, its application to continuous function learning (e.g., predicting numerical values) has been less understood. Specifically, it's unclear what underlying assumptions or "inductive biases" LLMs have when learning functions, and whether these biases can be intentionally modified. This paper aims to bridge this gap by analyzing LLM function learning through the principled lens of Gaussian Processes (GPs) and investigating how post-training techniques can shape these learned biases.

Methods

The authors employ a multi-pronged approach:

  1. In-Context Learning Curve Analysis: They evaluate LLMs on controlled experiments where models are presented with function samples drawn from known GP priors (specifically, Matérn and Squared Exponential kernels with varying length scales). They measure the mean absolute error as a function of the number of demonstrations.
  2. Principled Baselines: To interpret the LLM learning curves, they compare them against two benchmarks:
  3. Gaussian Process (GP) Regression: This serves as an empirical lower bound on achievable error, assuming the correct GP prior.
  4. 1-Nearest Neighbor (1-NN) Rule: This acts as a data-driven upper bound, representing a simple memorization strategy.
  5. Inductive Bias Analysis: They use a likelihood-based approach. For a given set of demonstrations, they compute the log-likelihood of the LLM's prediction under the posterior predictive distribution of GPs with different kernels. The kernel that yields the highest likelihood is considered to best explain the LLM's inductive bias.
  6. Post-Training Interventions: They investigate how parameter-efficient fine-tuning methods, specifically Supervised Fine-Tuning (SFT) and Reinforcement Learning (using GRPO), can alter these inductive biases. They train models on functions generated from specific kernels and then re-evaluate their inductive biases and learning curves.

Datasets

The experiments utilize synthetic datasets generated from Gaussian Processes (GPs) with Matérn and Squared Exponential kernels. These kernels are chosen to represent a range of smoothness properties. The functions are sampled in dimensions ranging from 1 to 4. The LLMs are prompted with sequences of input-output pairs from these functions, with the number of demonstrations varying from 0 to 49.

Key Insights and Ideas

  • LLMs as GP Learners: The study provides strong evidence that LLMs, when performing in-context function learning, behave remarkably like non-parametric regression learners, specifically approximating GP behavior.
  • Inductive Bias Towards Roughness (in low dimensions): A key finding is that LLMs, particularly in lower-dimensional settings, exhibit an inductive bias towards rougher functions (characterized by Matérn kernels with lower smoothness parameters, $\nu$). This is counter-intuitive, as humans tend to favor smoother functions.
  • Adaptation to Dimensionality: Interestingly, this bias shifts towards smoother functions as the dimensionality of the input increases.
  • Post-Training Steering: Parameter-efficient fine-tuning methods (SFT and GRPO) are shown to be effective in shifting LLM inductive biases.
  • Reinforcement Learning's Generalization: GRPO appears to promote more generalizable adjustments in inductive biases compared to SFT, which may lean towards memorization.

Key Results

  • Learning Curves: LLM learning curves generally approach the GP regression lower bound as the number of demonstrations increases, significantly outperforming the 1-NN upper bound.
  • Model Size: Larger LLMs (14B and 32B) show improved performance over smaller ones (8B), but the gains diminish with scale, suggesting a logarithmic scaling law.
  • Inductive Bias: For 1D functions, LLM predictions are most likely under rougher kernels (e.g., Matérn with low $\nu$) and least likely under smoother kernels (e.g., Squared Exponential). This trend reverses for higher dimensions.
  • Post-Training Impact: Fine-tuning with SFT and GRPO leads to LLM predictions being more likely under a wider range of kernels, indicating a shift in inductive biases. GRPO shows comparable boosts for different kernel types, while SFT's effectiveness is more tied to the training data's kernel.

Limitations and Future Work

  • Variance Inflation Effect: The inductive bias analysis is susceptible to a "variance inflation effect," where kernels with higher posterior predictive variance (e.g., rougher kernels) can artificially appear more likely. The authors propose a correction method for this.
  • Generalization to Real-World Tasks: The current study uses controlled synthetic data. Future work should explore how these findings generalize to more ecologically valid in-context learning scenarios, such as user interaction or novel coding tasks.
  • Periodic and Compositional Kernels: The study focuses on Matérn and SE kernels. Investigating periodic and compositional kernels would offer a more comprehensive understanding of LLM function learning capabilities.

Summary updated

BibTeX
@inproceedings{akata2026context,
  author = {Elif Akata and Konstantinos Voudouris and Vincent Fortuin and Eric Schulz},
  title = {{In-Context Function Learning in Large Language Models}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2026},
  url = {https://openreview.net/forum?id=HemJLYgBIi},
}
Figure