Meta-Attention: Bayesian Per-Token Routing for Efficient Transformer Inference

Alan Ferrari
5/27/2026
cs.LG
transformer-attentionbayesian

Official code: KFEAL/meta-attention (0 stars, Python, last commit 2026-06-16).

Abstract

Standard transformer architectures apply a single attention mechanism uniformly across all tokens and sequence positions, irrespective of local context or computational budget. We propose Meta-Attention, a framework that dynamically routes each token to the most appropriate attention strategy -- full softmax attention, linear (kernel) attention, or sliding-window local attention -- via a Bayesian Meta-Controller.

Show full abstract

Unlike prior routing approaches that use deterministic or prior-free learned routing, the Meta-Controller treats per-token mechanism selection as posterior inference under a compute-aware Dirichlet prior: routing weights are the output of an amortised variational posterior q(alpha | x_t; phi) trained with an Evidence Lower Bound (ELBO) objective that jointly encodes task performance and attention-mechanism cost. This design produces principled routing uncertainty estimates that govern the soft-to-hard routing transition, mitigates routing collapse without ad hoc load-balancing losses, and yields better compute-performance trade-offs than deterministic or prior-free learned routing at negligible overhead. Phase 1 empirical results on a Tiny LM benchmark confirm core predictions: the Bayesian controller's learned routing distribution implies a projected normalised FLOP cost of 25.1% under hard routing, vs. 59.3% for the prior-free baseline (-34.2 pp), and reduces routing entropy from 55.8% to 43.3% (-12.5 pp), demonstrating that the Dirichlet prior prevents routing collapse while the non-Bayesian model defaults to full attention. We present the Bayesian architecture, ELBO training objective, and a Phase 1 PyTorch prototype validating forward-pass correctness, posterior diversity, and a controlled ablation against a prior-free baseline. Code available at: https://github.com/KFEAL/meta-attention

View on arXivView PDF

Code Implementations(1)

Meta-Attention dynamically routes tokens to Full Softmax, Linear, or Sliding-Window attention via a Bayesian Meta-Controller. Using a compute-aware Dirichlet prior and ELBO objective, it cuts Tiny LM normalized cost from 59.3% to 25.1%, avoids routing collapse, and projects a 39.0%–64.0% FLOP reduction. PyTorch prototype included.

00PythonMay 27, 20265 months agoNOASSERTION

Similar Papers

Cite this paper

@article{ferrari2026metaattention,
  title  = {Meta-Attention: Bayesian Per-Token Routing for Efficient Transformer Inference},
  author = {Alan Ferrari},
  year   = {2026},
  eprint = {2605.28384},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.28384v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.28384.svg)](https://codeofpaper.com/paper/2605.28384)

Discussion