Title: Lab 3 — Cleaning and Curating a Fine-Tuning Dataset from Dolly-15k
Course: AIINFRA 201: Model Adaptation — Fine-Tuning & Quantization > Section: Week 03 — Dataset Design and Data Preparation for Fine-Tuning

🛠️ Lab 3 — Cleaning and Curating a Fine-Tuning Dataset from Dolly-15k (50 pts)

Goal: Practice the full data-preparation workflow — load, filter, clean, profile, and compare — on a real, freely available instruction dataset, so you can defend the curation decisions behind any fine-tuning dataset you build in the future. Steps:

1. Open a free Google Colab notebook (no paid tier required) and install the datasets library (pip install datasets).
2. Load databricks-dolly-15k (CC BY-SA 3.0, free and commercially usable) from the Hugging Face Hub using the datasets library's load_dataset function.
3. Inspect the dataset's structure: print the features, a handful of raw examples, and the full list of task categories it contains (e.g., closed_qa, summarization, brainstorming, information_extraction).
4. Filter the dataset down to 2–3 task categories of your choice (for example closed_qa and summarization) using the library's filtering functions, and explain in a short comment why you chose those categories relative to a task distribution you define (one sentence describing the fine-tuning task you are imagining this data would support).
5. Write a data-cleaning script that, on your filtered subset: (a) removes exact and near-duplicate examples, (b) filters out examples that are too short to contain a real instruction or too long to be practical for a training example (choose and justify your own min/max length thresholds), and (c) scans for and redacts obvious PII patterns (emails, phone numbers, full names in unexpected fields) using simple regex-based scrubbing.
6. Use the datasets library to profile your cleaned subset: plot or tabulate the length distribution of instructions and responses, and report the category balance (how many examples per category survived cleaning).
7. Load the raw Alpaca or OpenAssistant dataset (also from the Hugging Face Hub) for comparison purposes only — do not clean it. Compute the same profiling statistics (size, length distribution, duplicate rate) on a comparable sample and place them side-by-side with your cleaned Dolly subset.
8. Write a short (300–500 word) reflection comparing the two: what did cleaning remove and why, how did the category balance and length distributions change, and what does this tell you about the tradeoff between the raw dataset's size and your cleaned subset's quality?

Deliverables: Submit your Colab notebook (.ipynb, shared link or file upload) containing all code, output, and profiling results, plus your written reflection (can be in the notebook as markdown cells or submitted as a separate text entry).