Read the equation
Query-key dot products are divided by √dₖ, row-wise softmax converts them into weights that sum to one, and those weights average the value vectors. The code implements these stages with maximum subtraction for numerical stability. Compatible nonempty query/key widths and matching key/value counts are needed for the standard interpretation.
This exact expression also occurs in another recovered revision. Its mathematical annotation is shared; the source references below preserve this occurrence.
Terms & definitions
| Term | Meaning in this source |
|---|---|
| Q | Query matrix |
| K | Key matrix |
| V | Value matrix |
| d_k | Query/key feature width |
How it works
Read the definition from its right-hand expression to the quantity on the left. Its surrounding source records the intended input, state, or parameter context. Where the source leaves an operation unspecified, this page preserves that gap.
Assumptions & limits
Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.
Original context
Read the surrounding source passage
// Package transformer implements transformer-based generators (76-85) // Attention(Q,K,V) = softmax(QK^T/√d_k)V package transformer import ( "math" "math/rand" "generator_core/pkg/consciousness" "generator_core/pkg/generators" )
Exact original notation
Attention(Q,K,V) = softmax(QK^T/√d_k)V
Related builds
Related mathematical records
Scaled dot-product attention
Query-key dot products are divided by √dₖ, row-wise softmax converts them into weights that sum to one, and those weights average the value vectors. The code implements these…
Scaled dot-product attention
Query-key dot products are divided by √dₖ, row-wise softmax converts them into weights that sum to one, and those weights average the value vectors. The code implements these…
Scaled dot-product attention
Query-key dot products are divided by √dₖ, row-wise softmax converts them into weights that sum to one, and those weights average the value vectors. The code implements these…
Scaled dot-product attention
Query-key dot products are divided by √dₖ, row-wise softmax converts them into weights that sum to one, and those weights average the value vectors. The code implements these…