ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Scaled dot-product attention logits

For each query, compute its dot product with every key and divide by the square root of the query/key feature width. The transposed key axes put corresponding features into the contraction. These are unnormalized attention logits; the mask and softmax occur in the…

Donor model implementationhistorical source recovered; expression not executed in this website audit
Learn with the Atlas

Understand the scale

See what normalization changes and which assumptions it introduces.

Open guided lesson
donor-eq-547f51dfe2b9desource-code mathematical expression
attn_weight = q @ k.transpose(-2, -1) / math.sqrt(q.shape[-1])

Read the equation

For each query, compute its dot product with every key and divide by the square root of the query/key feature width. The transposed key axes put corresponding features into the contraction. These are unnormalized attention logits; the mask and softmax occur in the surrounding code.

Terms & definitions

The recovered passage does not supply a separate symbol table. Read the source context for the notation used in this version; familiar letters may carry different meanings in other builds.

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
k = k.transpose(0, 1)
    v = v.transpose(0, 1)

    attn_weight = q @ k.transpose(-2, -1) / math.sqrt(q.shape[-1])
    attn_weight += attention_mask
    attn_weight = torch.softmax(attn_weight, dim=-1,
                                dtype=torch.float32).to(q.dtype)
Exact original notation
attn_weight = q @ k.transpose(-2, -1) / math.sqrt(q.shape[-1])

Related builds

Sources & provenance

01
kimi source tree.txt
lines 1189–1189 · Aug 5, 2026
attn_weight = q @ k.transpose(-2, -1) / math.sqrt(q.shape[-1])
02
kimi source tree.txt
lines 1189–1189 · Aug 5, 2026
attn_weight = q @ k.transpose(-2, -1) / math.sqrt(q.shape[-1])

Search equations, builds, manuscript text, and recovered sources.