transformers

Neural network architectures based on self-attention for sequence modeling (encoder, decoder, and encoder-decoder variants) used in models like BERT, GPT, and ViT; working with them involves attention mechanisms, positional encodings, layer normalization, and frameworks/libraries such as Hugging Face Transformers and Fairseq.

transformers

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

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

This work addresses the challenge of enhancing neural networks’ ability to focus on salient information in long-sequence and multimodal tasks. By establishing a unified theoretical framework for attention mechanisms, the study systematically analyzes their mathematical foundations, computational properties, and cross-task generalizability. The framework is instantiated across diverse architectures—including autoregressive Transformers, bidirectional encoders, Vision Transformers, and cross-modal attention models—demonstrating consistent performance gains. The research further uncovers an intrinsic relationship between attention structure and model interpretability, validates empirical scaling laws governing training dynamics and performance, and achieves state-of-the-art results on multiple benchmark datasets. Attention visualization techniques are employed to enhance model transparency, offering insights into the decision-making process of these architectures.

attention mechanismscomputational scalabilityinterpretability

Transformadores: Fundamentos teoricos y Aplicaciones

Feb 18, 2023
JD
J. D. L. Torre
🏛️ Universitat Oberta de Catalunya

Spanish-speaking researchers face high barriers to understanding Transformer models due to limited localized pedagogical resources and a scarcity of rigorous, accessible academic materials in Spanish. Method: This work constructs the first three-tiered knowledge framework—spanning mathematical foundations, algorithmic implementation, and multimodal applications—systematically explaining core components (self-attention, positional encoding, multi-head attention, layer normalization, and feed-forward networks), and extending them to cross-modal tasks including natural language processing, computer vision, speech processing, and reinforcement learning. It introduces a cognition-aware Spanish-language pedagogical framework integrating theoretical derivations, reproducible code, and domain-specific case studies. Contribution: This is the first structured, pedagogically grounded, and engineering-oriented dissemination of state-of-the-art Transformer theory in the Spanish-speaking academic community. It substantially lowers the conceptual and practical barriers to comprehension and reproduction, thereby advancing the deep localization and equitable adoption of foundational AI models beyond English-dominant research ecosystems.

Exploring architecture elements and potential modifications of transformersPresenting key applications of transformers in diverse data tasksUnderstanding transformer models' mathematical and algorithmic foundations

Universal Approximation with Softmax Attention

Apr 22, 2025
JH
J. Hu
🏛️ Northwestern University | Fudan University

This paper investigates whether the self-attention mechanism—relying solely on linear transformations and the Softmax nonlinearity—can serve as a universal approximator for continuous sequence-to-sequence functions over compact domains. Method: Through interpolation analysis and explicit construction of attention weights, the authors establish approximation guarantees by proving that self-attention can uniformly approximate generalized ReLU functions—a key technical step enabling universal approximation without auxiliary components. Contribution/Results: The work proves that either (i) two-layer multi-head self-attention or (ii) single-layer self-attention followed by Softmax suffices to approximate any continuous sequence mapping on a compact domain to arbitrary precision—without requiring conventional feed-forward networks. This constitutes the first rigorous demonstration of universal approximation capability in pure attention architectures. The result is further extended to contextual statistical modeling. By decoupling self-attention from mandatory feed-forward layers, the study challenges the standard Transformer paradigm and provides a theoretical foundation for lightweight, interpretable, feed-forward-free attention models.

Analyzing attention's mechanism via interpolation to approximate ReLUDemonstrating multi-head attention suffices as universal approximator without feed-forward networksProving self-attention's universal approximation capability for sequence functions

Neural Attention: A Novel Mechanism for Enhanced Expressive Power in Transformer Models

Feb 24, 2025
AD
Andrew DiGiugno
🏛️ University of Bridgeport

Standard Transformer self-attention relies on dot-product similarity, which lacks expressivity for capturing complex, nonlinear token interactions. To address this, we propose Neural Attention—a novel attention mechanism that replaces the fixed dot-product with a learnable feed-forward neural network to compute attention weights. This is the first approach to introduce parameterized nonlinear mapping into attention weight computation while preserving dimensional compatibility and mathematical differentiability, thereby substantially enhancing representational capacity. The mechanism is inherently cross-modal: it achieves consistent gains across NLP and CV benchmarks—reducing perplexity by over 5% on WikiText-103 and significantly improving classification accuracy on CIFAR-10/100. Through rigorous computational complexity analysis and architectural optimization, we ensure both enhanced modeling capability and practical deployability.

Enhancing expressive power in Transformer modelsImproving NLP and image classification performanceReplacing dot products with feed-forward networks

Latest Papers

What's happening recently
View more

The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures

Oct 06, 2025
AM
Alexander M. Fichtl
🏛️ Technical University of Munich

Transformer’s self-attention mechanism suffers from $O(n^2)$ time and memory complexity, severely limiting efficiency in long-sequence modeling. This work systematically evaluates sub-quadratic alternatives—including sparse attention, linear attention, state space models (SSMs), recurrent architectures, and hybrid designs—across theoretical complexity, empirical throughput, memory footprint, and downstream task performance. Through rigorous benchmarking on Long Range Arena, PG19, and WikiText, coupled with theoretical analysis, we find that several non-attention architectures significantly outperform standard Transformers on long-context tasks, achieving superior scalability and modeling capability. Our results empirically demonstrate that self-attention is not indispensable for effective sequence modeling, challenging its architectural primacy. The study provides concrete evidence and a principled roadmap for developing next-generation efficient sequence models, bridging theoretical advances with practical system-level gains.

Assessing potential challengers to pure-attention transformer dominanceOvercoming quadratic complexity bottleneck in transformer attention mechanismsSurveying sub-quadratic alternatives to traditional transformer architectures

This work proposes Exclusive Self-Attention (XSA), a novel variant of self-attention that mitigates the tendency of conventional self-attention mechanisms to overemphasize positional information of the current token, thereby impairing contextual modeling. XSA introduces, for the first time, an orthogonality constraint on value vectors within the self-attention computation, compelling the model to attend exclusively to context representations orthogonal to the current token. This design effectively suppresses interference from the token’s own positional embedding. Implemented within a standard Transformer architecture, XSA consistently outperforms conventional self-attention in language modeling benchmarks, with performance gains becoming increasingly pronounced as sequence length grows. Notably, the advantage persists even in large-scale models, yielding measurable improvements in a 2.7B-parameter setting.

context modelingorthogonal informationself attention

To address the high computational complexity (O(n²)) of self-attention in modeling long sequences, this paper proposes Poolformer—a computationally efficient sequence-to-sequence model based on pooling and recursive architecture. Its core innovation replaces self-attention with multi-scale pooling operations, integrated within a recursive SkipBlock structure featuring residual connections, down/up-sampling pooling, and nested sub-blocks—enabling effective sequence compression and long-range dependency modeling. This design substantially reduces computational overhead and alleviates sequence-length limitations. Evaluated on raw audio generation, Poolformer outperforms state-of-the-art models including SaShiMi and Mamba, achieving faster training convergence, superior Fréchet Inception Distance (FID) and Inception Score (IS), stronger generalization, and reduced overfitting risk.

Addresses quadratic scaling of self-attention in long sequencesImproves efficiency and performance for long-sequence modeling tasksReplaces self-attention with pooling-enhanced recurrent layers

This work investigates the necessity of key design principles in Transformer dot-product attention—namely, cross-position information mixing, sequence-dependent activation, specific mathematical formulation, and query/key hidden-state coupling. Methodologically, we systematically construct controlled variants: simplifying attention computation, decoupling query and key generation, performing layer-wise substitution, and training hybrid architectures, complemented by fine-grained ablation studies. Our results reveal that information mixing is essential for attention’s effectiveness, whereas sequence dependence and the standard mathematical form can be substantially simplified without performance loss. Crucially, strategic layer-wise collaboration—e.g., retaining standard attention in only a subset of layers—suffices to maintain strong language modeling performance. We demonstrate that models with just a few standard attention layers achieve comparable perplexity to full-attention baselines, enabling significant model compression and enhanced interpretability while preserving accuracy.

Exploring simplified attention variants that maintain model performanceInvestigating which attention design principles are essential for effective language modelingTesting necessity of token mixing, sequence dependency and mathematical form

Protein Secondary Structure Prediction Using Transformers

Dec 09, 2025
MK
Manzi Kevin Maxime
🏛️ Carnegie Mellon University Africa

This study addresses protein secondary structure prediction (α-helices, β-sheets, and coils) using a Transformer-based end-to-end deep learning framework. To tackle variable-length input sequences and long-range residue dependencies, the model employs self-attention mechanisms and introduces a novel sliding-window data augmentation strategy—enhancing simultaneous capture of local and global structural interactions. Evaluated on the standard CB513 benchmark, the method achieves state-of-the-art Q3 accuracy and demonstrates superior robustness and generalization compared to conventional RNN- and CNN-based approaches. Key contributions include: (i) the first systematic empirical validation of Transformer architectures for protein secondary structure prediction; (ii) a lightweight, effective sliding-window augmentation technique that mitigates challenges posed by limited training data and sequence length variability; and (iii) an openly reproducible technical foundation for future attention-driven protein structure modeling.

Apply transformer attention mechanisms to protein sequence dataGeneralize across variable-length sequences capturing residue interactionsPredict protein secondary structures from amino acid sequences

Hot Scholars

YL

Yingyu Liang

The University of Hong Kong
machine learning
ZS

Zhenmei Shi

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

Hemanth Saratchandran

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

Linfeng Zhang

DP Technology; AI for Science Institute
AI for Sciencemulti-scale modelingmolecular simulationdrug/materials design
WM

William Merrill

Ai2 / TTIC
language modelsformal languagescomputational linguisticsdeep learning