Tokenization and NLP practice problems

29 problems · 0 solved

Before a language model sees text, a tokenizer cuts it into pieces and maps each piece to an id. The choice of tokenizer affects cost, speed and how well a model handles languages like Hindi, Tamil or Kashmiri. It is similar to deciding how to break words into syllables before teaching someone to read. These problems cover modern tokenizers and classic NLP basics. You will pre-tokenize text into words, numbers and symbols, extract character n-grams, encode text with a byte fallback, decode SentencePiece pieces, do one merge step of a BPE tokenizer and encode a word with ranked merges, tokenize with WordPiece greedy longest match, map tokens back to character offsets, find the best segmentation with a unigram model and Viterbi, score words with TF-IDF, compute Levenshtein edit distance, train a bigram language model and measure perplexity, and score bigrams with Kneser-Ney smoothing. Start with the Easy problems on pre-tokenization, n-grams and TF-IDF. Then do BPE, WordPiece and edit distance, and finish with unigram segmentation and the smoothed language models. Tokenizer bugs cause strange model behaviour, and interviewers often ask how BPE works.

Easy 12

Medium 11

Hard 6

Related topics

All practice problems