Lab build

Dialogue summariser (Pegasus on SAMSum)

Fine-tunes Pegasus on SAMSum dialogues and serves summaries through FastAPI train and predict routes.

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

What it does

A config-driven pipeline downloads the SAMSum data, tokenises dialogues and summaries with the Pegasus tokenizer and fine-tunes google/pegasus-cnn_dailymail with the Hugging Face Trainer. An evaluation stage computes ROUGE-1, ROUGE-2, ROUGE-L and ROUGE-Lsum on a test sample and writes them to CSV. A FastAPI app exposes /train to rerun the pipeline and /predict to summarise text.

What was built

  1. 01

    Stage 1 downloads and unzips the SAMSum dataset from a configured URL into artifacts.

  2. 02

    Stage 2 tokenises dialogues and target summaries and saves the dataset to disk.

  3. 03

    Stage 3 trains one epoch with gradient accumulation 16 and 500 warmup steps, then saves model and tokenizer.

  4. 04

    Stage 4 scores ROUGE metrics on test samples and writes metrics.csv.

  5. 05

    FastAPI /predict runs the fine-tuned model in a summarization pipeline; /train reruns main.py.

The pipeline, layer by layer

Five layers, one pipeline.

  1. L1Ingestion

    • SAMSum download
  2. L2Transformation

    • Pegasus tokenizer
  3. L3Training

    • Pegasus fine-tuning
    • HF Trainer
  4. L4Evaluation

    • ROUGE metrics CSV
  5. L5Serving

    • FastAPI train and predict

Stack

  • Hugging Face Transformers
  • Hugging Face Datasets
  • Pegasus
  • PyTorch
  • evaluate
  • FastAPI
  • Uvicorn
  • PyYAML
  • python-box

Next lab build · 44 / 46

Instruction fine-tuning a small LLM

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

Previous: Agent with custom tools, evaluation and reflection

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