FixTheRobot Explore Robotics / LLM / LM7 / LM7-L1

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

LLM · Instruction Fine-Tuning · LM7-L1 · Beginner

Format Instruction Data with Templates

An instruction-tuned model learns from text, and the text is produced by a template. If the template does not mark where the answer starts and ends, or if a few examples are malformed, the model learns the wrong habits: it runs on after the answer, or answers with nothing.

You will compare templates, write the formatter, and write the checks that find bad examples before training.

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 compares three templates for recoverability, an end token and empty sections. Stage 2 writes the exact formatter. Stage 3 finds malformed examples. The examples are invented, the reader in Stage 1 is a rule-based program and no model is trained. Your code is graded on hidden examples.

    Theory for this lab

    Instruction Fine-Tuning labs

    1. LM7-L1: Format Instruction Data with Templates: this lab.
    2. LM7-L2: Implement Loss Masking
    3. LM7-L3: Instruction-Tune a Tiny Model and Evaluate It

    Educational simplification: five or a dozen short examples, a string template and rule-based checks. Real instruction data sets have tens of thousands to millions of examples, several languages and richer structure; the same templates and the same checks apply. 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.