Transformers convert text into high-dimensional vector representations.

Self-Attention Mechanism

Self-attention computes Query (Q), Key (K), and Value (V) projections for every token. Matrix dot-products softmax(Q · K^T / √d) determine how much context every word borrows from surrounding tokens. Multi-head attention repeats this across 32–128 parallel attention spaces.