Apex › Storage & databases

How attention works (transformers)

The core of every transformer and LLM. Each token emits a query, a key, and a value; a token attends to another by how well its query matches that key (a dot product), the scores are scaled and softmaxed into weights that sum to 1, and the token’s new representation is the weighted blend of everyone’s values. Real scaled dot-product attention over a 6-token toy: “river” attends to the water words, “money” to the finance words, and ambiguous “bank” to both. Pick the query token and watch the weights and the blended output.

More in Storage & databases