---
id: 9644
lang: en
title: "The Geometry of Attention: How QK Norm Teaches a Model to Understand Meaning"
published_at: "2026-05-17 18:11:39"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1036128/?utm_campaign=1036128&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/9644"
categories: ["business"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# The Geometry of Attention: How QK Norm Teaches a Model to Understand Meaning

> **Краткая суть (BLUF):** QK Norm in transformers is not just about stabilization. Normalization turns the dot product into cosine similarity, forcing the network to express meaning through the angles between vectors rather than their magnitude.  The result: the model handles rare words better and avoids the "attention sink".

QK Norm, the normalization of query and key before the dot product in the attention mechanism, is often treated as a technical footnote for numerical stability. In fact, it is a deep geometric constraint that forces a transformer to express meaning in a completely different way.

## The problem without normalization

Network layers are lazy. Without a norm, instead of deftly rotating vectors and expressing meaning through angular relationships, a transformer takes the easy path: it increases magnitude. An important token simply gets louder. It does this because it can. The dot product q⃗ · k⃗ = |q⃗| |k⃗| cos(θ) grows with both the angle and the magnitude. The network learns both: it looks at the angle and inflates the vector. And inflating is cheaper than understanding.

This leads to the "attention sink": grammatical function tokens (commas, articles, pronouns) start to dominate because they appear often and will accumulate large magnitude simply by default.

## How QK Norm works

Normalization is a constraint. When we normalize query and key to unit length, the dot product becomes cosine similarity. The vectors end up "locked" on an N-dimensional hypersphere. Now the network cannot inflate a vector to attract attention. Only one option remains: rotate the vector so that its angle with other vectors expresses the intended semantic relationship. If you need a connection between words, show it with an angle, not with loudness.

This fundamentally changes how internal representations work:

- Meaning is encoded in the angles between vectors, not their magnitude
- All tokens sit at the same distance from the origin
- Rare words don't get lost, because on the hypersphere everyone is equal
- Attention is based on semantic similarity, not on frequency

## The right place in the architecture

One critical detail: QK Norm must come *before* RoPE (Rotary Position Embedding), not after. If the norm is applied after RoPE, positional information gets blurred and is not encoded correctly. The order: query-key norm → then RoPE.

## What this means

This is not just an engineering trick for numerical stability. It redefines what "attention" means at the geometric level. A network that relies on angles instead of magnitudes learns to generalize better to rare tokens and avoids the habit of letting function words dominate.

Without empirical results on billion-parameter models, this remains a theoretical argument, but the logic is geometrically sound.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1036128/?utm_campaign=1036128&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/9644
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
