In-Context Learning of Polynomial Kernel Regression in Transformers with GLU Layers

Haoyuan Sun, Ali Jadbabaie, Navid Azizan · DOI

Abstract

Recent theoretical work has established that Transformers can perform In-Context Learning (ICL) by implicitly implementing gradient descent for linear regression. However, these models struggle to explain how Transformers handle nonlinear tasks. This paper investigates the role of Feed-Forward Network (FFN) layers, specifically Gated Linear Units (GLU), in enabling nonlinear ICL. We demonstrate that Transformers with GLU layers function as kernel regression engines, utilizing their depth to perform block-coordinate descent across expanded feature spaces. Our findings suggest that while self-attention handles the optimization step, the FFN layers are responsible for the feature engineering necessary to transcend linear limitations.

Introduction

In-Context Learning (ICL) is a hallmark of Large Language Models (LLMs), allowing them to adapt to new tasks via prompt examples without explicit weight updates. While the mechanism for linear ICL is well-understood—where Linear Self-Attention (LSA) layers approximate gradient descent—this framework fails to account for the complex, nonlinear patterns found in real-world data. Mathematically, LSA-only architectures are restricted to the span of their inputs, making them incapable of outperforming simple linear predictors on nonlinear datasets.

This research addresses this gap by focusing on the Feed-Forward (FFN) layers, which constitute a significant portion of a Transformer's parameters. By analyzing a "Bilinear Transformer" architecture—incorporating simplified GLU layers common in modern models like Llama and PaLM—we show how these components allow the model to perform polynomial kernel regression in-context.

The Bilinear Transformer and Feature Generation

The core of the proposed mechanism lies in the interaction between the attention mechanism and the FFN. In the context of polynomial regression, the FFN layer acts as a feature generator. Specifically, the bilinear nature of the GLU (which involves element-wise multiplication) is uniquely suited to creating cross-terms, such as $x_i \cdot x_j$, from an input vector $x$.

By transforming raw inputs into a higher-dimensional "kernel space" of quadratic monomials, the Transformer can map a nonlinear problem in the original input space into a linear problem in the feature space. Once the FFN has expanded the features, the subsequent attention layers can perform the standard gradient descent-like operations to solve the regression task. We prove that a single bilinear Transformer block can achieve an ICL loss of $O(d^2/n)$, where $d$ is the input dimension and $n$ is the number of examples in the prompt.

Overcoming the Dimension Bottleneck via Depth

A significant challenge in kernel regression is the dimensionality of the feature space. To represent all quadratic features of a $d$-dimensional input, the model requires an embedding dimension of approximately $d^2/2$. For high-dimensional inputs, this requirement quickly exceeds the hardware limits of the model's width.

This paper introduces the concept of Block-Coordinate Descent as the solution provided by the network's depth. Rather than attempting to represent every possible nonlinear feature in a single layer, a deep Transformer distributes the computation. Each layer computes a specific subset of features and performs a partial update to the prediction. As the signal passes through multiple layers, the model effectively iterates through different coordinates of the feature space, allowing a "thin" model (small embedding dimension) to learn "wide" feature spaces (high-dimensional kernels).

Empirical Validation

The theory was tested using synthetic datasets of random quadratic and cubic functions. The results confirmed several key hypotheses:

  1. Nonlinear Superiority: Bilinear Transformers significantly outperformed linear-only baselines on quadratic tasks, proving that FFN layers are essential for nonlinear ICL.
  2. Depth vs. Width: In scenarios where the embedding dimension was smaller than the total number of required quadratic features, deep models (6+ layers) successfully converged on the target function, while shallow models failed. This supports the block-coordinate descent theory.
  3. Higher-Order Composition: For cubic functions, the research demonstrated that "dense" FFN weights are necessary. This density allows the model to compose features across layers—multiplying quadratic features from layer $L$ with original inputs in layer $L+1$ to generate cubic representations.

Conclusion

This work shifts the focus of ICL research from the attention mechanism alone to the critical interplay between attention and feed-forward layers. By framing the FFN as a kernel feature generator and the network depth as an iterative optimizer, we provide a more complete picture of how Transformers master complex, nonlinear tasks. While this study focuses on polynomial kernels, the principles of feature expansion and block-coordinate descent likely generalize to other nonlinearities, offering a roadmap for understanding the expressive power of modern LLMs.

Summary updated

BibTeX
@inproceedings{sun2026context,
  author = {Haoyuan Sun and Ali Jadbabaie and Navid Azizan},
  title = {{In-Context Learning of Polynomial Kernel Regression in Transformers with GLU Layers}},
  booktitle = {ALT},
  year = {2026},
  url = {https://openreview.net/forum?id=7u3GLaafyF},
}
Figure