Machine Learning with PyTorch and Scikit-Learn
-- Code Examples
Package version checks
Add folder to path in order to load from the check_packages.py script:
Check recommended package versions:
Chapter 16: Transformers – Improving Natural Language Processing with Attention Mechanisms (Part 3/3)
Quote from https://huggingface.co/transformers/custom_datasets.html:
DistilBERT is a small, fast, cheap and light Transformer model trained by distilling BERT base. It has 40% less parameters than bert-base-uncased , runs 60% faster while preserving over 95% of BERT's performances as measured on the GLUE language understanding benchmark.
Fine-tuning a BERT model in PyTorch
Loading the IMDb movie review dataset
General Settings
Download Dataset
The following cells will download the IMDB movie review dataset (http://ai.stanford.edu/~amaas/data/sentiment/) for positive-negative sentiment classification in as CSV-formatted file:
Check that the dataset looks okay:
Split Dataset into Train/Validation/Test
Tokenizing the dataset
Dataset Class and Loaders
Loading and fine-tuning a pre-trained BERT model
Train Model -- Manual Training Loop
Fine-tuning a transformer more conveniently using the Trainer API
Reload pretrained model:
...
Readers may ignore the next cell.