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
      68 of 88

      Merge the most common pair

      Language models read text as symbols, and a tokenizer invents them: it starts with single letters and keeps gluing two neighbours into a new symbol, so common chunks of text take fewer symbols. Write merge_once(tokens): add one new symbol, two neighbouring symbols glued together, chosen to make the text as short as possible, and glue it everywhere it fits, left to right. If two pairs would do equally well, take the one that shows up first in the text.

      solution.pyLoading Python
      ← How far can it see?Who should “it” listen to? →