Skip to main content

Exercises — Tokenization strategies

Self-check questions, exercises, and worked answers

← Back to the lesson: Tokenization strategies

Check your understanding

Formative exercises extend this page, notably on BPE merges, in the Text-data collection.

  1. Two tokenizers produce different token counts for the same text. What observations and measurements would you compare before concluding that one yields a better downstream model?
Show the answer

No: a shorter sequence first demonstrates a difference in granularity and compression. Length is neither a quality metric nor a guarantee of linguistic analysis; the useful comparison concerns the corpus, tokenizer, and objective together.

  1. Is training the tokenizer already pretraining the language model?
Show the answer

No. The tokenizer has its own training (merge rules, vocabulary, normalization) on its own data, and is then frozen. Pretraining the language model optimizes the network weights to predict tokens, with the tokenizer frozen. The two trainings share neither objective nor parameters.

  1. Can the same token ID denote different fragments in two models?
Show the answer

Generally yes: an ID only has meaning relative to the vocabulary of the tokenizer that produced it. Unless the tokenizer or its revision is identical, the same integer can correspond to different fragments; IDs do not transfer as-is between models.

Experiment: compare multiple tokenizers

Encode the same text — “What have the Romans ever done for us?” — with at least two tokenizers. If possible, choose different tokenizer families or vocabularies.

For each tokenizer, record:

  • the exact pieces and token IDs returned;
  • the total token count and the effects of normalization or special tokens;
  • segmentation differences for rare words, accents, punctuation, and whitespace.

Interpret the results without conflating sequence length, compression, linguistic suitability, and downstream model quality. A tokenizer comparison alone cannot attribute a quality difference to the tokenizer: the model, data, task, and evaluation protocol must be controlled.

You have understood this step if you can distinguish training the tokenizer from encoding at inference, and explain why IDs depend on the vocabulary and its version.

Language: Français · English