← all concepts

Quadratic Attention Cost

The property that standard transformer attention grows with the square of the input length — doubling the context roughly quadruples the compute and memory — which is why long context windows are expensive and why grounding budgets exist.

What it means

In a standard transformer, attention lets every token compare itself against every other token. For a sequence of n tokens that is n × n comparisons, so the cost scales with . Double the input and you roughly quadruple the work and the memory needed to hold the attention scores. This is the quadratic attention cost, and it is the central reason long contexts are expensive rather than free.

Why it shapes the products you use

The quadratic term is what makes a large context window costly to actually fill. It explains why longer prompts are slower and priced higher, why providers impose per-request length limits, and why AI search systems ground answers against a fixed per-query word budget instead of dumping every candidate page into the model. DEJAN research has established that Google's AI Mode works within such a fixed budget — a constraint driven by attention economics and latency, not by the theoretical size of the underlying model's window.

How systems get around it

Because the naive cost is punishing, modern systems avoid paying it in full. Retrieval-augmented generation keeps the context short by fetching only the most relevant passages. Ranking methods like BlockRank exploit the block-sparse structure of attention so in-context ranking scales to large candidate sets. Architectural variants use sparse, windowed, or linear-attention approximations to break the wall. All of these are, at heart, ways to spend the attention budget where it matters.

Why it matters for AI SEO

The quadratic cost is the economic force behind selection. Because a model cannot afford to read everything, it reads a budgeted slice — which turns visibility into a competition for that slice and makes the needle-in-a-haystack problem unavoidable. Content that is concise, self-contained, and easy to rank into the budget is content that survives the cut.

Related concepts

Concept