leixiang25/hw2-perfume-occasion-distilbert
Perfume Occasion Classifier (fine-tuned DistilBERT)
Purpose
Predicts the occasion a perfume suits — everyday, going out, formal, casual-relaxed — from a short English description of its notes and character. Built for CMU 24-679 Homework 2 to practice fine-tuning. Labels reflect one person's opinion; not a perfume recommender.
Data
- Source: ypolatog/perfume-occasion-texts (CC-BY-4.0), by classmate
ypolatog. - 100 real texts (29 everyday, 38 going out, 13 formal, 20 casual-relaxed) + 1,243 synthetic (char swap/delete, word swap, WordNet synonym).
- Split by parent text (seed 42, stratified): train 60 texts (811 incl. synthetic), validation 15 (205 incl. synthetic), test 25 real texts only. Synthetic copies never cross sets. Exact IDs in
split.json(reused by the Problem 4 prompting comparison).
Preprocessing
DistilBERT uncased tokenizer, truncation at 96 tokens, dynamic padding. No other cleaning.
Training setup
- Base:
distilbert-base-uncased+ new 4-way classification head; full fine-tuning. - 4 epochs, learning rate 2e-05, batch 16, weight decay 0.01, AdamW, seed 42.
- Best epoch by validation macro-F1: epoch 3 (restored at end).
Results (25 real test texts)
Confusion matrix and per-class metrics are in the training notebook. One test text ≈ 4 accuracy points, so differences of a few points are within noise.
Limitations and ethics
- Subjective single-annotator labels; many perfumes plausibly fit two occasions.
- Small classes: 13 real
formaltexts; synthetic copies add typos, not new meaning. - Shortcut cues: season sentences correlate with labels (cold weather → often
going out), and many texts share the opening "Prominent notes…"; the model may rely on these. - Descriptions mention brands and "dupe of…" comparisons; the model may associate brands with occasions.
How to use
from transformers import pipeline
clf = pipeline("text-classification", model="leixiang25/hw2-perfume-occasion-distilbert")
clf("Prominent notes of iris and saffron. Elegant and refined, suits evening events.")Compute
Google Colab, NVIDIA T4 GPU, a few minutes of training.
AI usage disclosure
Code and this card were drafted with Claude (Anthropic) and reviewed, run, and interpreted by the author.
Acknowledgments
Dataset by ypolatog (CMU 24-679, Fall 2026). Base model by Hugging Face (DistilBERT, Apache-2.0).
