Lab build

Instruction fine-tuning a small LLM

Instruction-tunes Pythia-70M on a documentation Q&A set and evaluates it against base models.

Role
Builder, end to end
Group
Fine-tuning
Services
AI & LLM systems

What it does

Q&A pairs from the Lamini documentation dataset are formatted with question and answer prompt templates, tokenised with padding and truncation and split 90/10. Pythia-70M is trained with the Hugging Face Trainer, compared with base and instruction-tuned Llama 2 outputs, and evaluated by exact match on the test split and on ARC-Easy through lm-evaluation-harness.

What was built

  1. 01

    Alpaca and Lamini docs examples are hydrated into instruction prompt templates and saved as JSONL.

  2. 02

    Tokenizer pads with the EOS token, truncates to 2048 tokens and adds labels before a 90/10 split.

  3. 03

    Trainer fine-tunes Pythia-70M for a few steps; a longer-trained checkpoint is compared on the same questions.

  4. 04

    Evaluation runs exact-match checks on test questions and ARC-Easy via lm-evaluation-harness.

The pipeline, layer by layer

Four layers, one pipeline.

  1. L1Data

    • Lamini docs Q&A
    • Prompt templates
  2. L2Preparation

    • Tokenise, pad, truncate
    • Train-test split
  3. L3Training

    • Pythia-70M fine-tuning
  4. L4Evaluation

    • Exact match
    • ARC-Easy harness

Stack

  • Hugging Face Transformers
  • Hugging Face Datasets
  • PyTorch
  • Pythia-70M
  • Lamini
  • Llama 2
  • lm-evaluation-harness
  • jsonlines

Next lab build · 45 / 46

QLoRA Llama 3.1 price predictor

QLoRA fine-tune of a 4-bit Llama 3.1 8B that predicts product prices from descriptions.

Previous: Dialogue summariser (Pegasus on SAMSum)

Need a system like this in production? Tell us about it.