---
title: "Using group theory to explore the space of positional encodings for attention"
description: "Requiring a positional encoding for attention to be linear in queries and keys, translation-invariant (depending only on relative position) and continuous forces it to be a one-parameter matrix group A(t)=exp(tX)."
url: "https://swe.quest/articles/using-group-theory-to-explore-the-space-of-positional-encodings-for-attention-24091e992dee90df"
canonical: "https://blog.janestreet.com/using-group-theory-to-explore-positional-encodings-attention/"
source: "Jane Street Tech Blog"
published: "2026-04-22"
difficulty: "hard"
kind: "Research"
reading_minutes: 11
tags: ["llms","machine-learning"]
---

# Using group theory to explore the space of positional encodings for attention

A post on [Jane Street Tech Blog](https://swe.quest/sources/jane-street.md), published 2026-04-22, 11 min read, Research. Original: [https://blog.janestreet.com/using-group-theory-to-explore-positional-encodings-attention/](https://blog.janestreet.com/using-group-theory-to-explore-positional-encodings-attention/)

## Summary

Requiring a positional encoding for attention to be linear in queries and keys, translation-invariant (depending only on relative position) and continuous forces it to be a one-parameter matrix group A(t)=exp(tX). Classifying the generator X recovers the known options: zero gives NoPE, negative real eigenvalues give exponential decay as in linear attention, and complex conjugate pairs give RoPE, optionally damped as in RetNet and Mamba-3. Defective (non-diagonalizable) generators yield a largely unexplored family with polynomial time terms, and an addendum shows ALiBi can be built from one by augmenting queries and keys. The practical takeaway is that the sensible encodings in this space are probably already in use.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)

## Prerequisites

- attention mechanism in transformers
- linear algebra and eigendecomposition
- matrix exponentials
- basic group theory

## Keywords

RoPE, ALiBi, RetNet, Mamba-3, NoPE, GRAPE, Jordan normal form

## Related posts

- [You could have designed state of the art positional encoding](https://swe.quest/articles/you-could-have-designed-state-of-the-art-positional-encoding-af87c15753b60969.md): Hugging Face · 2024-11-25 · Hard · 15 min read · LLMs, Machine learning
  Rotary Positional Encoding (RoPE) can be derived step by step from simple ideas.
- [Falcon-H1: A Family of Hybrid-Head Language Models Redefining Efficiency and Performance](https://swe.quest/articles/falcon-h1-a-family-of-hybrid-head-language-models-redefining-efficiency-and-d1a0dda74c9407b8.md): Hugging Face · 2025-05-21 · Hard · 11 min read · LLMs, Model training, Inference & serving, Evaluation
  Falcon-H1 is a family of six open-weight language models (0.5B to 34B, base and instruct, Apache 2.0-based license) built on a parallel hybrid mixer that runs attention and Mamba-2 SSM heads side by side, with a tunable attention/SSM ratio.
- [Understanding BigBird's Block Sparse Attention](https://swe.quest/articles/understanding-bigbird-s-block-sparse-attention-c6890f38de755efc.md): Hugging Face · 2021-03-31 · Hard · 18 min read · LLMs, Machine learning, Algorithms, Performance engineering
  BigBird replaces BERT's quadratic full attention with block sparse attention, which combines sliding-window, global and random attention to approximate full attention at linear cost.
- [Optimizing your LLM in production](https://swe.quest/articles/optimizing-your-llm-in-production-aa5bbb901928fa57.md): Hugging Face · 2023-09-15 · Medium · 31 min read · Inference & serving, LLMs, Performance engineering, Python
  Serving billion-parameter LLMs efficiently comes down to three levers: lower precision, Flash Attention, and inference-friendly architectures such as ALiBi, rotary embeddings, Multi-Query Attention and Grouped-Query Attention.
- [Perceiver IO: a scalable, fully-attentional model that works on any modality](https://swe.quest/articles/perceiver-io-a-scalable-fully-attentional-model-that-works-on-any-modality-f8a43e7ae2c87797.md): Hugging Face · 2021-12-15 · Hard · 21 min read · Machine learning, LLMs, Computer vision, Python
  Perceiver IO avoids the quadratic cost of self-attention by running attention over a small fixed set of latent variables (e.g. 256×1280).

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
