Simple character/byte-level tokenizer and text loader

Overview: what you’re building

You’ll build a single Python module (say tokenizer.py) that can:

  • Turn raw UTF-8 text into byte or character IDs and back (deterministic, invertible).
  • Define a vocabulary with a known ID range and a couple of special tokens.
  • Stream a big text file chunk by chunk (no full-file-in-RAM).
  • Pack the token stream into fixed-length (input, target) sequences ready for autoregressive training.

The end result will be something you can drop into a tiny language-model training loop later.

1 / 6