Focus Your Attention (with Adaptive IIR Filters)

Shahar Lutati, Itamar Zimerman, Lior Wolf

Introduction

Modern sequence modeling is currently caught in a "Goldilocks" dilemma. On one hand, standard Transformers offer unparalleled expressivity through self-attention, yet their quadratic computational complexity makes them prohibitively expensive for long sequences. On the other hand, State Space Models (SSMs) and global convolutions provide near-linear scaling but often rely on "static" filters that lack the dynamic, input-dependent adaptability that makes attention so effective.

The Focus layer is a novel architectural component designed to bridge this gap. By combining the long-range efficiency of global convolutions with the dynamic adaptability of attention, Focus allows models to process massive sequences with sub-quadratic time complexity and significantly reduced memory overhead.

The Focus Layer Architecture

The Focus layer achieves its efficiency through a combination of four primary technical innovations:

  1. Adaptive Second-Order IIR Filters: While previous efficient models (such as MEGA) utilized simple first-order Exponential Moving Averages (EMA), Focus employs second-order Infinite Impulse Response (IIR) filters. These are mathematically more expressive, capable of capturing complex oscillating patterns and under-damped responses that first-order filters cannot.
  2. Hypernetworks for Dynamic Control: To move beyond static filtering, Focus uses a hypernetwork to generate filter coefficients. This hypernetwork processes previous chunks of data to determine the coefficients for the current chunk, making the filtering process both causal and highly sensitive to the specific input content.
  3. Frequency Domain Efficiency: To maintain high performance, the filtering operation is executed in the frequency domain using Fast Fourier Transforms (FFT). This allows the model to apply global filters without the computational burden associated with standard time-domain convolutions.
  4. Hybrid Attention Mechanism: The adaptive filtering acts as a sophisticated pre-processor. Once the sequence is "primed" by the IIR filters, a standard local attention mechanism is applied. This allows the model to use the filtered signal to determine exactly where the attention heads should "focus."

Theoretical and Empirical Insights

The Power of Second-Order Systems

A key insight of this research is the transition from 1st-order to 2nd-order filters. While 1st-order filters are limited to simple smoothing, 2nd-order filters can model decaying oscillations, providing a much richer representational space. The authors provide a theoretical framework to ensure these 2nd-order systems remain stable during training, preventing the numerical explosions often associated with recursive filters.

Dynamic Spotlighting

The hypernetwork essentially acts as a spotlight. In tasks like Associative Recall, visualizations reveal that the model learns to boost filter magnitude by five orders of magnitude at the precise moment a relevant "key" appears in the sequence. This behavior mimics the selective nature of attention but within a convolutional framework.

Experimental Results

The Focus layer was evaluated against several competitive benchmarks, demonstrating superior scaling and efficiency:

  • Associative Recall: Focus maintained 100% accuracy on sequences up to 64,000 tokens. In contrast, standard Transformers failed at 8,000 tokens, and non-adaptive versions of the Focus layer saw performance drop to 28%.
  • Language Modeling (enwiki8): Focus achieved a Bits-Per-Character (BPC) score of 0.94 using only 22 million parameters. For comparison, Transformer XL required 277 million parameters (12x more) to achieve a lower BPC of 0.99.
  • Image Classification: On the sequential MNIST (sMNIST) task, where images are processed as long pixel sequences, Focus reached 99.7% accuracy, outperforming the well-known S4 model.
  • Memory Efficiency: The Focus layer utilizes only 38% of the memory required by a standard Transformer, making it ideal for hardware-constrained environments.

Limitations and Future Directions

Despite its strengths, the Focus layer introduces certain trade-offs. The computational overhead of the hypernetwork and FFT operations means that raw inference speed (wall-clock time) is currently slower than simpler models like S4 or MEGA. Additionally, while stability is proven for 2nd-order systems, extending this to higher-order filters remains an open challenge.

Future work may explore higher-order adaptive filters or "hyper-global" convolutions to further refine the balance between computational speed and model expressivity. For now, Focus provides a compelling blueprint for the next generation of efficient, long-context sequence models.

Summary updated

BibTeX
@inproceedings{lutati2023focus,
  author = {Shahar Lutati and Itamar Zimerman and Lior Wolf},
  title = {{Focus Your Attention (with Adaptive IIR Filters)}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.772},
}
Figure