Black Friday Sale: 20% off Premium yearly · $105.60 for the first year · until Monday, Nov 30Get it

Deep-ML
Learn
ProblemsPractice, projects, collections, and your progressLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      ← back to the problem

      Prerequisite path

      Implement Masked Self-Attention

      CodingmediumOpen goal
      Start path
      Whole map

      Dependency network

      FoundationsGoal
      IntuitionMathCoding
      Goal · Coding

      Implement Masked Self-Attention

      Open goal

      Needs first 2

      32 nodes · 43 connections

      After this goal

      • A KV Cache for Autoregressive Decoding
      • A Unique-Hard Attention Transformer: Masks, Tie-Breaking and the Acceptance Vector
      • Causal and Padding Masks with scaled_dot_product_attention
      • From Decoder to Encoder: Bidirectional Attention with Padding Masks
      • Gated Attention: A Sigmoid Gate on Each Head's Attention Output
      • Hybrid Linear/Full Attention Layer Routing
      • Implement Batched Causal Self-Attention
      • KV Cache for Efficient Autoregressive Attention
      • Learned Relative Position Bias Added Before Softmax
      • Multi-Head Attention Two Ways: Value-Up per Head vs One Output Matrix
      • NoPE: Position from the Causal Mask Alone
      • Residual-Stream Decomposition in an Attention-Only Transformer

      And 5 more