AdvancedAbout 25 min

    Self-Attention Mechanism

    Read the full article on Substack

    6 min read.

    Interactive visualization of how self-attention works in transformer models.

    10%The35%cat40%sat10%on3%the2%matsatQueryKeys
    "sat" gives 40% to "sat" and 35% to "cat". "sat" looks back at "cat", the one who sat.

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Scaled dot-product attention

    Sequence

    Order the computation.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    6. 6Drop a step here
    6 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    Self-attention lets each token in a sequence…

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going