Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning 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
      Intuition
      86 of 102

      Word order matters

      Attention compares words with words, so it sees a sentence as a bag: dog bites man and man bites dog look the same to it. Write position_tag(position, length): a list of numbers to add to the word at position (0 is the first word) in a sentence of length words, so the model can tell where each word is. A word is a list of 16 numbers between −1 and 1, so a tag can have at most 16.

      Attention sees a sentence as a pile of words, so “dog bites man” and “man bites dog” give the same pile. Each place needs a tag added to its word, so the two piles come out different. What should the tags be?

      dogbitesmanplace 0tag ?place 1tag ?place 2tag ?what attention seesmanbitesdogplace 0tag ?place 1tag ?place 2tag ?what attention sees=the same pile: attention can’t tell them apart
      Your functionposition_tag(position, length)
      positionwhere the word is (0 = the first word)e.g. 0
      lengthhow many words the sentence hase.g. 10
      returnsa list of numbers (at most 16) to add to that word
      solution.pyLoading Python
      Sign in for an AI hint
      ← Don’t peekDistance, not place →