FixTheRobot Explore Robotics / LLM / LM2 / LM2-L3

This lab works on phones, but writing code is much easier on a laptop.

LLM · Text Data and Tokenization · LM2-L3 · Intermediate

Diagnose Sliding Windows and Batching

The loss is falling, the generated text is fluent, and the validation loss is suspiciously good. The bug is not in the model: it is in how the training examples were cut.

You will build input-target pairs from a token stream and write the checks that catch the data bugs that raise no errors.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math (and slamkit for small matrix helpers: matmul, transpose, solve, inverse, identity). Images, point clouds and detections arrive as lists inside the dictionary D; an image is a list of rows, each row a list of pixels. There is no NumPy or OpenCV: you write the algorithm yourself, which is the point of the lab. Print with print().

    Hints

    What this lab teaches

    Stage 1 explores context length, stride and coverage. Stage 2 builds input-target pairs. Stage 3 diagnoses four classes of data-pipeline bugs. The token streams are short lists of integers; real corpora are far larger but the indexing is identical. Your code is graded on hidden sequences and pipelines.

    Theory for this lab

    Text Data and Tokenization labs

    1. LM2-L1: Build a Simple Tokenizer
    2. LM2-L2: Implement Byte-Pair Encoding
    3. LM2-L3: Diagnose Sliding Windows and Batching: this lab.

    Educational simplification: sequences of a few dozen integer tokens, one window length per case and four injected bug types. Real pipelines add shuffling, multi-process loading and padding for variable-length data, which introduce further failure modes. All data in this lab are invented.

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.