Skip to content

feat: Add scaled dot-product self-attention, single head - #9

Open
ThomasHartDev wants to merge 1 commit into
mainfrom
thomas/feat/attention
Open

feat: Add scaled dot-product self-attention, single head#9
ThomasHartDev wants to merge 1 commit into
mainfrom
thomas/feat/attention

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

Adds the Vaswani attention core in plain numpy: softmax(QK^T / sqrt(d_k)) V, optional boolean masks (False positions go to -inf before softmax), and a single-head self-attention module that projects one sequence into Q, K, and V. Includes a causal lower-triangular mask helper and tests for shapes, scale vs saturation, retrieval, empty/single-token edges, and autoregressive masking.

Closes #8.

Implement Attention(Q,K,V) = softmax(QK^T / sqrt(d_k)) V with causal
masking and a SelfAttentionHead that projects one sequence into Q, K, V.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add scaled dot-product self-attention (single head)

1 participant