transformer architecture

Designing and training transformer-based models and components (encoders, contextual integration, objectives) to embed sequences and support tasks such as joint causal-outcome prediction and context-weighted token importance.

transformerarchitecture

12-Month Skill Trend

Momentum and market value over time
Trending
Score
+20 in 12 mo
96
12 mo agoNow
Career
Value
+$12K in 12 mo
$42K/year
12 mo agoNow

Recommended Survey Paper

Quick overview of the field
View more

Must-Read Papers

Most classic and influential ideas
View more

Towards Understanding the Universality of Transformers for Next-Token Prediction

Oct 03, 2024
ME
Michael E. Sander
🏛️ Ecole normale superieure | CNRS

This work investigates the universal mechanism by which Transformers implicitly learn temporal mappings—such as linear and periodic patterns—in autoregressive next-token prediction, with a focus on how self-attention encodes causal sequence structure. We propose *causal kernel descent*, a novel theoretical framework that, for the first time, constructsively proves that causal Transformers can implicitly implement an online Kaczmarz-type algorithm via self-attention to approximate a dynamic context function (f) in a Hilbert space. We rigorously construct a Transformer architecture capable of exactly learning (f), and validate its efficacy through controlled sequence experiments under linear, exponential, and softmax attention. This work establishes the first provably correct, constructively universal theoretical framework for understanding how large language models intrinsically perform in-context reasoning—offering a new paradigm for analyzing their implicit inference capabilities.

Developing a causal kernel descent method for in-context learning.Exploring causal Transformers' capacity for autoregressive sequence prediction.Understanding Transformers' universal next-token prediction ability.

Introduction to Sequence Modeling with Transformers

Feb 26, 2025
JK
Joni-Kristian Kämäräinen
🏛️ Tampere University

This work clarifies the functional boundaries and necessity of core Transformer components—tokenization, embedding/un-embedding, masking, positional encoding, and padding—addressing widespread conceptual ambiguity in their mechanistic roles. Targeting ML engineers, we propose an incremental, invertibility-based analytical framework: using binary (0/1) sequences as probes, we systematically introduce each component via a “zero-one construction” and empirically validate its irreplaceability in the encode-decode pipeline. Implemented lightweightly in PyTorch, our framework supports manual attention matrix construction, explicit positional embedding injection, and interpretable mask design. Experiments demonstrate significantly improved conceptual accuracy among learners. Notably, we provide the first empirical verification that, in the absence of self-attention, positional encoding combined with padding alone suffices for basic length-aware tasks.

Incremental modeling with simple sequencesRole of tokenization, embedding, masking in transformersUnderstanding transformer architecture components

Pool Me Wisely: On the Effect of Pooling in Transformer-Based Models

Oct 02, 2025
SE
Sofiane Ennadir
🏛️ King AI Labs | Microsoft Gaming | NXAI GmbH | Kreditz AB | Amazon

The impact of pooling operations on representational capacity and task performance in Transformer models has long been overlooked. Method: We establish, for the first time, theoretical expressivity bounds for pooling methods and propose a unified analytical framework that characterizes how distinct pooling strategies—e.g., [CLS], mean, and attention-weighted pooling—affect input discriminability, contextual modeling capability, and optimization dynamics. Our analysis spans three modalities—NLP, computer vision, and time series—and encompasses multiple attention variants across diverse downstream tasks. Contribution/Results: Empirical evaluation reveals that pooling choice significantly influences accuracy, gradient sensitivity, and convergence stability. Crucially, we identify task-agnostic, high-performing pooling patterns that generalize consistently across modalities and tasks. This work provides both theoretical foundations and practical guidelines for task-aware pooling design in Transformer architectures.

Analyzing pooling's impact on Transformer model expressivity and capacityEvaluating pooling strategies across vision, NLP, and time-series tasksProviding theoretical and empirical guidance for pooling mechanism selection

This work addresses the lack of a rigorous mathematical characterization of Transformers’ ability to model contextual relationships. The authors propose a measure-theoretic framework in which text is represented as a probability measure over a semantic embedding space, and inter-word contextual dependencies are modeled as coupling measures. They introduce the Sinkhorn Transformer architecture to approximate arbitrary continuous coupling functions. By integrating optimal transport theory with function approximation theory, the study establishes the first universal approximation theorem for Transformers in modeling contextual relations, proving that the proposed architecture can uniformly approximate any continuous coupling function. This result provides a formal theoretical guarantee for the semantic coupling mechanism and expressive power of Transformers.

contextual relationsexpressive powermathematical characterization

This work addresses the limitations of Transformer-based models in long-sequence multivariate time series forecasting, particularly their inadequate input representation quality and structural modeling capacity. To overcome these challenges, the authors propose a two-stage framework: first, a convolutional neural network (CNN) extracts local dynamic features from fixed-length temporal segments and generates compact patch-level token embeddings; subsequently, a Transformer encoder with attention mechanisms models the global dependencies among these segments. By decoupling local feature extraction from global dependency modeling, the approach enhances both scalability and representational power. Experimental results on synthetic multivariate time series datasets demonstrate that the proposed method significantly outperforms CNN baselines under long input sequences and achieves performance comparable to state-of-the-art patch-based Transformer models.

input representationmultivariate time-seriessequence length

Latest Papers

What's happening recently
View more

Causality-Induced Positional Encoding for Transformer-Based Representation Learning of Non-Sequential Features

Sep 20, 2025
KX
Kaichen Xu
🏛️ Zhongnan University of Economics and Law | Emory University

Existing positional encodings rely on predefined sequential orders, limiting their ability to model non-sequential yet causally related features. To address this, we propose Causal-Aware Positional Encoding (CAPE): first, a generalized structural equation model learns a causal directed acyclic graph (DAG); second, the DAG is embedded in hyperbolic space to preserve both causal strength and specificity; third, a rotation-based transformation seamlessly integrates the encoding into Transformer self-attention. We theoretically prove that CAPE satisfies causal distance metric properties and exhibits generalization decay—key desiderata for causal representation learning—while remaining robust to positional perturbations. Empirical evaluations on synthetic and real-world datasets demonstrate that CAPE significantly enhances Transformer’s representational capacity for non-sequential causal data. The implementation is publicly available.

Addressing positional encoding for non-sequential but causally-related featuresEnhancing transformer self-attention with causality-aware positional encodingsIdentifying causal structure as DAG for non-sequential feature representation

Markov Chain Estimation with In-Context Learning

Aug 05, 2025
SL
Simon Lepage
🏛️ CRITEO AI Lab | LIGM | Ecole des Ponts | Univ Gustave Eiffel | CNRS

It remains unclear whether Transformers can algorithmically infer transition probabilities of Markov chains from context via next-token prediction alone—rather than relying on memorized patterns. Method: We train standard autoregressive Transformers on sequences generated by randomly sampled Markov chains with diverse transition matrices, systematically varying model size and training data scale. Contribution/Results: We identify dual thresholds in model capacity and data volume beyond which Transformers transition from pattern memorization to genuine context-driven estimation of transition probabilities. Incorporating explicit state embeddings significantly improves zero-shot generalization to unseen chain structures. Crucially, sufficiently large Transformers achieve accurate modeling of previously unobserved Markov chains without fine-tuning—demonstrating, for the first time, systematic evidence that Transformers can implicitly learn probabilistic algorithms from context. This provides foundational insight into the emergent algorithmic reasoning capabilities of large language models.

Explore encoding impact on prediction robustness across chain structuresStudy transformers' ability to learn Markov chain algorithmsTest model's transition probability estimation vs pattern memorization

Equivalence of Context and Parameter Updates in Modern Transformer Blocks

Nov 21, 2025
AG
Adrian Goldwaser
🏛️ University of Cambridge | Google Research

This work investigates the equivalence between context updates and parameter updates in Transformers. We propose a low-rank (rank-1) weight patching mechanism that implicitly encodes contextual influence as dynamic, input-dependent corrections to MLP layer weights. We establish, for the first time, a formal controllability-theoretic framework—proving that such context-to-parameter mapping is exactly realizable in MLP blocks satisfying mild structural conditions. Our formulation rigorously accommodates modern architectural components, including RMSNorm, gating mechanisms, and pre-/post-norm configurations, thereby unifying the explanation of context-driven parameter adaptation across Gemma, MoE, and deep stacked architectures. Experiments confirm exact equivalence of context effects under this mechanism in both Gemma-style modules and multi-layer models, with broad applicability across mainstream LLM architectures. This work provides a novel theoretical and mechanistic paradigm for understanding context awareness in large language models.

Establishes controllability framework for understanding prompt-to-weight transformationExtends context-parameter equivalence theory to modern LLM architecturesProves context effects map to rank-1 patches in MLP weights

This work addresses the inherent conflict between in-context learning (ICL) and in-weight learning (IWL) in Transformer models by proposing CoQE, a dual-representation architecture that decouples contextual information and input samples at the representation level. CoQE explicitly encodes context into a task representation space and samples into a distinct sample representation space, leveraging dual-space linear modeling grounded in duality theory and an enhanced Transformer structure. Experiments on few-shot classification and pseudo-arithmetic tasks demonstrate that CoQE significantly improves ICL performance while effectively preserving IWL capabilities, thereby validating the efficacy and generality of its co-optimization strategy for both learning paradigms.

In-Context LearningIn-Weight LearningLearning Conflict

Existing studies model induction heads using fixed-structure Markov chains, failing to capture the context-dependent dynamism inherent in natural language. Method: We propose the “Interleaved Delayed Markov Chain” framework, enabling Transformers to adaptively select optimal causal structures across varying contexts. We identify and construct a selective induction head circuit wherein self-attention and in-context learning jointly orchestrate dynamic structural switching; we theoretically prove its convergence to the maximum-likelihood solution. Contribution/Results: Experiments on a three-layer Transformer demonstrate that the model accurately infers context-optimal time delays and precisely replicates target tokens, simultaneously selecting causal structure during sequence prediction. This work overcomes the limitations of static causal modeling and establishes a novel paradigm for understanding the dynamic inductive mechanisms underlying Transformer architectures.

How transformers dynamically handle varying causal structures in contextMechanism for identifying appropriate token relationships in changing contextsUnderstanding how transformers select correct causal dependencies between tokens

Hot Scholars

HS

Hemanth Saratchandran

Australian Institute for Machine Learning/Adelaide University + CommBank AI Scholar
MathematicsMachine Learning
LB

Luca Benini

ETH Zürich, Università di Bologna
Integrated CircuitsComputer ArchitectureEmbedded SystemsVLSI
WM

William Merrill

Ai2 / TTIC
language modelsformal languagescomputational linguisticsdeep learning
ZS

Zhenmei Shi

Senior Research Scientist at MongoDB + Voyage AI; PhD from University of Wisconsin–Madison
Deep LearningMachine LearningArtificial Intelligence