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
      35 of 102

      Cut the long tail

      A language model gives every possible next word a chance, and then picks one at random (“Roll a loaded die”). Most words get a tiny chance, and together that long tail of junk still gets picked now and then. Write keep(chances, share): the indexes of the words to keep before picking. No junk, but enough variety: keep the most likely words until they cover share of the chance.

      After “I’d like a cup of”, the model gives five next words a chance and draws one. Even a junk word gets its turn now and then. Which words should it keep before drawing, so they cover 80% of the chance?

      After “I’d like a cup of”, the model gives five words a chance.“I’d like a cup of …”10%water40%coffee5%soup30%tea15%milkall five, end to end: the model draws from thesethe chance the kept words cover?share 80%100%8 endings it wrote… of … of … of … of … of … of … of … of
      Your functionkeep(chances, share)
      chancesone per word, adding up to 1e.g. [0.97, 0.01, 0.01, 0.01]
      sharehow much of the chance the kept words should covere.g. 0.9
      returnsthe indexes of the words to keep
      solution.pyLoading Python
      Sign in for an AI hint
      ← Roll a loaded dieIs the bet worth it? →