Transformer-Evolution-Paper
  • README
  • 数学符号
  • Act
    • A survey on recently proposed activation functions for Deep Learning
  • Arch
    • Supplementary Material Implementation and Experiments for GAU-based Model
    • MetaFormer is Actually What You Need for Vision
    • Deeper vs Wider A Revisit of Transformer Configuration
    • Perceiver General Perception with Iterative Attention
    • General-purpose, long-context autoregressive modeling with Perceiver AR
    • Hierarchical Transformers Are More Efficient Language Models
    • Branchformer: Parallel MLP-Attention Architectures to Capture Local and Global Context for Speech Recognition and Understanding
    • Generalization through Memorization: Nearest Neighbor Language Models
  • FFN
    • Large Memory Layers with Product Keys
    • Transformer Feed-Forward Layers Are Key-Value Memories
    • GLU Variants Improve Transformer
    • Simple Recurrence Improves Masked Language Models
    • Pay Attention to MLPs
    • S2-MLP Spatial-Shift MLP Architecture for Vision
    • S2-MLPv2 Improved Spatial-Shift MLP Architecture for Vision
    • HyperMixer An MLP-based Green AI Alternative to Transformers
    • DeFINE: DEep Factorized INput Token Embeddings for Neural Sequence Modeling & DeLighT: Deep and Light-weight Transformer
    • When Shift Operation Meets Vision Transformer: An Extremely Simple Alternative to Attention Mechanism
    • Sparse MLP for Image Recognition: Is Self-Attention Really Necessary?
  • Head
    • Multi-Head Attention Collaborate Instead of Concatenate
    • Fast Transformer Decoding: One Write-Head is All You Need
  • Memory
    • Compressive Transformers for Long-Range Sequence Modelling
    • Memformer The Memory-Augmented Transformer
    • Memory Transformer
    • Do Transformers Need Deep Long-Range Memory
    • LaMemo Language Modeling with Look-Ahead Memory
    • GMAT Global Memory Augmentation for Transformers
    • Block-Recurrent Transformers
    • Augmenting Self-attention with Persistent Memory
    • Recurrent Memory Transformer
    • Memorizing Transformers
    • Scaling Transformer to 1M tokens and beyond with RMT
    • Adapting Language Models to Compress Contexts
  • MHA
    • FFT
      • Fourier Neural Operator for Parametric Partial Differential Equations
      • Global Filter Networks for Image Classification
      • Adaptive Fourier Neural Operators: Efficient Token Mixers for Transformers
      • FNet: Mixing Tokens with Fourier Transforms
    • LocalGlobal
      • CrossFormer: A Versatile Vision Transformer Hinging on Cross-scale Attention
      • Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding
      • Neighborhood Attention Transformer
      • FMMformer: Efficient and Flexible Transformer via Decomposed Near-field and Far-field Attention
      • Adaptive Attention Span in Transformers
      • CoLT5: Faster Long-Range Transformers with Conditional Computation
    • MatrixMethod
      • Skyformer Remodel Self-Attention with Gaussian Kernel and Nyström Method
      • Is Attention Better Than Matrix Decomposition
    • RightProduct
      • Kronecker Attention Networks
      • An Attention Free Transformer
      • Transformer with Fourier Integral Attentions
      • Linear Complexity Randomized Self-attention Mechanism
      • UFO-ViT: High Performance Linear Vision Transformer without Softmax
      • XCiT: Cross-Covariance Image Transformers
      • SimpleTRON: Simple Transformer with O(N) Complexity
      • A Dot Product Attention Free Transformer
      • On Learning the Transformer Kernel
      • Momentum Transformer: Closing the Performance Gap Between Self-attention and Its Linearization
    • SparseOrLowRank
      • Explicit Sparse Transformer: Concentrated Attention Through Explicit Selection
      • Scatterbrain: Unifying Sparse and Low-rank Attention Approximation
      • Sparse Factorization of Large Square Matrices
      • Blockwise Self-Attention for Long Document Understanding
      • H-Transformer-1D: Fast One-Dimensional Hierarchical Attention for Sequences
      • ChunkFormer: Learning Long Time Series with Multi-stage Chunked Transformer
      • Enhancing the Locality and Breaking the Memory Bottleneck of Transformer on Time Series Forecasting
      • Fast Transformers with Clustered Attention
      • Long-Short Transformer: Efficient Transformers for Language and Vision
      • LongT5: Efficient Text-To-Text Transformer for Long Sequences
      • Luna: Linear Unified Nested Attention
      • Memory-efficient Transformers via Top-k Attention
      • Separable Self-attention for Mobile Vision Transformers
      • Simple Local Attentions Remain Competitive for Long-Context Tasks
      • You Only Sample (Almost) Once: Linear Cost Self-Attention Via Bernoulli Sampling
    • Others
      • Synthesizer: Rethinking Self-Attention in Transformer Models
      • Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kern
      • Combiner Full Attention Transformer with Sparse Computation Cost
      • Ripple Attention for Visual Perception with Sub-quadratic Complexity
      • Sinkformers: Transformers with Doubly Stochastic Attention
      • SOFT: Softmax-free Transformer with Linear Complexity
      • Value-aware Approximate Attention
      • EL-Attention: Memory Efficient Lossless Attention for Generation
      • Flowformer: Linearizing Transformers with Conservation Flows
      • ETSformer: Exponential Smoothing Transformers for Time-series Forecasting
      • IGLOO: Slicing the Features Space to Represent Sequences
      • Swin Transformer V2: Scaling Up Capacity and Resolution
      • Skip-Attention: Improving Vision Transformers by Paying Less Attention
  • Normalize_And_Residual
    • ReZero is All You Need Fast Convergence at Large Depth
    • Batch Normalization Biases Residual Blocks Towards the Identity Function in Deep Networks
    • Improving Deep Transformer with Depth-Scaled Initialization and Merged Attention
    • RealFormer Transformer Likes Residual Attention
    • On Layer Normalizations and Residual Connections in Transformers
    • Transformers without Tears: Improving the Normalization of Self-Attention
    • Query-Key Normalization for Transformers
    • Understanding the difficulty of training transformers
  • Pe
    • A Simple and Effective Positional Encoding for Transformers
    • DeBERTa Decoding-enhanced BERT with Disentangled Attention
    • DecBERT Enhancing the Language Understanding of BERT with Causal Attention Masks
    • Encoding word order in complex embeddings
    • Improve Transformer Models with Better Relative Position Embeddings
    • KERPLE Kernelized Relative Positional Embedding for Length Extrapolation
    • PermuteFormer Efficient Relative Position Encoding for Long Sequences
    • Rethinking Positional Encoding in Language Pre-training
    • Transformer-XL Attentive Language Models Beyond a Fixed-Length Context
    • Translational Equivariance in Kernelizable Attention
    • Transformer Language Models without Positional Encodings Still Learn Positional Information
    • Stable, Fast and Accurate: Kernelized Attention with Relative Positional Encoding
    • Randomized Positional Encodings Boost Length Generalization of Transformers
  • Pretrain
    • XLNet Generalized Autoregressive Pretraining for Language Understanding
    • Transcormer Transformer for Sentence Scoring with Sliding Language Modeling
    • Optimus Organizing Sentences via Pre-trained Modeling of a Latent Space
    • ELECTRA Pre-training Text Encoders as Discriminators Rather Than Generators
    • Cramming: Training a Language Model on a Single GPU in One Day
  • Softmax
    • Transformer with a Mixture of Gaussian Keys
    • Normalized Attention Without Probability Cage
  • Others
    • Accelerating Neural Transformer via an Average Attention Network
    • Do Transformer Modifications Transfer Across Implementations and Applications?
    • Object-Centric Learning with Slot Attention
    • Do Transformer Modifications Transfer Across Implementations and Applications?
    • Why self-attention is Natural for Sequence-to-Sequence Problems? A Perspective from Symmetries
  • LongConv
    • Legendre Memory Units: Continuous-Time Representation in Recurrent Neural Networks
    • Parallelizing Legendre Memory Unit Training
    • Simplified State Space Layers for Sequence Modeling
    • Pretraining Without Attention
    • What Makes Convolutional Models Great on Long Sequence Modeling?
    • Hungry Hungry Hippos: Towards Language Modeling with State Space Models
    • Hyena Hierarchy: Towards Larger Convolutional Language Models
    • RWKV
    • Simple Hardware-Efficient Long Convolutions for Sequence Modeling
    • Time-aware large kernel convolutions
    • Resurrecting Recurrent Neural Networks for Long Sequences
    • CKConv: Continuous Kernel Convolution For Sequential Data
    • FlexConv: Continuous Kernel Convolutions with Differentiable Kernel Sizes
    • Towards a General Purpose CNN for Long Range Dependencies in ND
  • Rnn
    • When Attention Meets Fast Recurrence: Training Language Models with Reduced Compute
    • Linear Transformers Are Secretly Fast Weight Programmers
    • Going Beyond Linear Transformers with Recurrent Fast Weight Programmers
    • Parallelizing Linear Recurrent Neural Nets Over Sequence Length
    • Quasi-recurrent neural networks
  • CrossAttention
    • Neural Machine Translation in Linear Time
  • Inference
    • Extrapolation
      • Parallel Context Windows for Large Language Models
      • Structured Prompting: Scaling In-Context Learning to 1,000 Examples
      • Naive Bayes-based Context Extension
  • Peft
    • Parameter-Efficient Fine-Tuning without Introducing New Latency
    • Make Your Pre-trained Model Reversible: From Parameter to Memory Efficient Fine-Tuning
  • LLM
    • LLM Details Summary
    • What Language Model to Train if You Have One Million GPU Hours?
Powered by GitBook
On this page
  • 整体思路以及计算方式
  • 时间复杂度
  • 代码
  • 简评
  1. LongConv

Time-aware large kernel convolutions

PreviousSimple Hardware-Efficient Long Convolutions for Sequence ModelingNextResurrecting Recurrent Neural Networks for Long Sequences

Last updated 2 years ago

论文地址:

补充:这篇论文提供了cuda代码。

整体思路以及计算方式

整体思路是利用卷积的方式进行序列建模,看完之后感觉非常赞,这里详细理一下计算思路。

步骤一,simple conv1d,序列建模的方式。

以一维序列x0,…,xn−1x_0,\ldots, x_{n-1}x0​,…,xn−1​为例,利用部分和(kernel值为1的卷积)的形式得到输出:

oi=∑j=αilαirxjo_i=\sum_{j=\alpha_i^l}^{\alpha_i^r} x_joi​=j=αil​∑αir​​xj​

其中αil,αir\alpha_{i}^l , \alpha_i^rαil​,αir​为oio_ioi​对应的边界值,注意上式的计算复杂度太高,但是可以构造前缀和降低计算复杂度:

{S0=0Si=Si−1+xi,1≤i≤n.\left\{\begin{array}{l}\mathcal{S}_0=0 \\ \mathcal{S}_i=\mathcal{S}_{i-1}+x_i, \quad 1 \leq i \leq n .\end{array}\right.{S0​=0Si​=Si−1​+xi​,1≤i≤n.​

那么:

oi=Sair−Sail−1o_i=\mathcal{S}_{a_i^r}-\mathcal{S}_{a_i^l-1}oi​=Sair​​−Sail​−1​

那么现在的问题就是如何计算αir,αir\alpha_i^r, \alpha_i^rαir​,αir​,这在步骤二中可以解决。

步骤二,确定上界和下界。

首先构造可学习的参数:

a~i{l,r}=σ(f{l,r}(xi))∈[0,1]\tilde{a}_i^{\{l, r\}}=\sigma\left(f^{\{l, r\}}\left(x_i\right)\right) \in[0,1]a~i{l,r}​=σ(f{l,r}(xi​))∈[0,1]

然后利用下式计算边界:

ail=i−a~il⋅lmax⁡air=i+a~ir⋅rmax⁡\begin{aligned} a_i^l & =i-\tilde{a}_i^l \cdot l_{\max } \\ a_i^r & =i+\tilde{a}_i^r \cdot r_{\max }\end{aligned}ail​air​​=i−a~il​⋅lmax​=i+a~ir​⋅rmax​​

其中lmax⁡,rmax⁡l_{\max}, r_{\max}lmax​,rmax​是超参。现在的一个问题是,ail,aira_i^l, a_i^rail​,air​不一定是整数,但是我们只能计算整数下标的Sk,k∈Z\mathcal S_k, k\in \mathbb ZSk​,k∈Z,这一点利用插值即可解决:

Sail−1=γl⋅S⌊ail⌋−1+(1−γl)⋅S⌈ail⌉−1Sair=(1−γr)⋅S⌊air⌋+γr⋅S⌈air⌉\begin{aligned} \mathcal{S}_{a_i^l-1} & =\gamma^l \cdot \mathcal{S}_{\left\lfloor a_i^l\right\rfloor-1}+\left(1-\gamma^l\right) \cdot \mathcal{S}_{\left\lceil a_i^l\right\rceil-1}\\ \mathcal{S}_{a_i^r} & =\left(1-\gamma^r\right) \cdot \mathcal{S}_{\left\lfloor a_i^r\right\rfloor}+\gamma^r \cdot \mathcal{S}_{\left\lceil a_i^r\right\rceil}\end{aligned}Sail​−1​Sair​​​=γl⋅S⌊ail​⌋−1​+(1−γl)⋅S⌈ail​⌉−1​=(1−γr)⋅S⌊air​⌋​+γr⋅S⌈air​⌉​​

步骤三:归一化和鲁棒性。

这里作者为了让算法work,增加了归一化和dropout:

o~i=oi⋅(1lmax⁡+rmax⁡+1)\tilde{o}_i=o_i \cdot\left(\frac{1}{l_{\max }+r_{\max }+1}\right)o~i​=oi​⋅(lmax​+rmax​+11​)

步骤四:

之前讨论的的都是一维的情形,然后作者将其推广到ddd维度时候发现性能一般,这里感觉主要问题是映射a~i{l,r}=σ(f{l,r}(xi))∈[0,1]\tilde{a}_i^{\{l, r\}}=\sigma\left(f^{\{l, r\}}\left(x_i\right)\right) \in[0,1]a~i{l,r}​=σ(f{l,r}(xi​))∈[0,1]不太稳定,为了缓解这点,作者将ddd维拆成h×(d/h)h\times (d/ h)h×(d/h),每d/hd/hd/h个特征共享一个αi{l,r}\alpha_i^{\{l,r\}}αi{l,r}​,并且由这d/hd/hd/h共同确定。

时间复杂度

因为是查找表,所以时间复杂度是O(nd)O(nd)O(nd)。

代码

简评

非常赞的一个思路,其作用机理优点类似于window attention,其中window范围由输入确定。

https://arxiv.org/abs/2002.03184
https://curve.carleton.ca/system/files/etd/66a5a0db-fc74-4de3-8ad2-742c860100f5/etd_pdf/e8bfee5862f9739964ee653864b59f0b/lioutas-sequencemodelingwithlinearcomplexity.pdf
https://github.com/lioutasb/TaLKConvolutions