← Questions

Scaled dot-product attention from scratch

0
MetaCodingLast asked Sep 2025

Write scaled dot-product attention by hand: from queries, keys and values, compute the scores, scale them by the square root of the key size, apply an optional mask, take a softmax and weight the values. Start from the formula, keep the tensor shapes straight, and extend to several heads if time allows. The code doesn't need to run.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding