Why Nostr? What is Njump?
2024-11-18 01:54:07
in reply to

Tom_Drummond on Nostr: nprofile1q…r59k6 As I understand it, masking is used to obtain causality so each ...

As I understand it, masking is used to obtain causality so each token only attends to the tokens preceding it (and itself).

Each token emits a query and a key and the code computes all pairwise dot products between queries and keys (using matmul) to create the attention matrix. This is then 'masked' by subtracting a large number from all the anti-causal logits in the matrix (everything above the leading diagonal if rows correspond to queries).

So the first token attends only to itself, the second attends to the first and itself - and so on. In general this uses half of the attention matrix. So the early tokens are being very wasteful, those in the middle are a little bit wasteful and those near the end are barely wasteful at all.

But maybe I have misunderstood your question...?
Author Public Key
npub1g4ss3v8573z4aus0ytsq3ewah9cphk5p48ffnfz5hp8htsc9ndjqphtq97