Skip to main navigation Skip to search Skip to main content

Do Nonlinear Transformers Implement Kernel Regression In-Context? An Empirical Investigation

  • Jiahui Wang
  • , Di Zhang*
  • *Corresponding author for this work
  • Xi'an Jiaotong-Liverpool University

Research output: Chapter in Book or Report/Conference proceeding › Conference Proceeding › peer-review

Abstract

Recent work has shown that linear transformers can perform in-context learning (ICL) by implicitly implementing ridge-regression-like algorithms. However, practical transformers use softmax attention and nonlinear MLPs, and it remains unclear to what extent their ICL behavior can still be interpreted through a kernel-regression lens. We study this question through a kernel surrogate hypothesis, which compares a trained nonlinear ICL predictor with kernel ridge regression (KRR) using a combined attention- and MLP-inspired kernel. Rather than claiming an exact equivalence, we evaluate this hypothesis through controlled synthetic experiments on polynomial regression, Gaussian process (GP) regression, and sparse linear regression. Across these tasks, we compare trained single-layer transformers with closed-form KRR reference predictors in terms of predictive error, context-length scaling, attention-weight alignment, and model-width sensitivity. The results show that the KRR surrogate closely follows the Bayes reference on GP tasks, whereas trained transformers achieve high correlation with KRR outputs on polynomial tasks (r > 0.90) but retain a persistent MSE gap. Attention analysis further shows that transformer attention becomes more aligned with KRR contribution weights during training, although the alignment remains moderate. Overall, these findings suggest that kernel regression provides a useful reference-level description of nonlinear ICL in controlled settings, but not a complete account of finite-width trained transformer behavior.

Original languageEnglish
Title of host publicationAdvanced Intelligent Computing Technology and Applications - 22nd International Conference on Intelligent Computing, ICIC 2026, Proceedings
EditorsDe-Shuang Huang, Chuanlei Zhang, Wei Chen, Yijie Pan, Prashan Premaratne
PublisherSpringer Science and Business Media Deutschland GmbH
Pages564-574
Number of pages11
ISBN (Print)9789819234165
DOIs
Publication statusPublished - 2027
Event22nd International Conference on Intelligent Computing, ICIC 2026 - Toronto, Canada
Duration: 22 Jul 2026 → 26 Jul 2026

Publication series

NameLecture Notes in Computer Science
Volume16663 LNAI
ISSN (Print)0302-9743
ISSN (Electronic)1611-3349

Conference

Conference22nd International Conference on Intelligent Computing, ICIC 2026
Country/TerritoryCanada
CityToronto
Period22/07/26 → 26/07/26

Keywords

  • empirical study
  • In-context learning
  • kernel methods
  • nonlinear activation
  • transformers

Cite this