Fine-Tuning With the Trainer API
Train a classifier on your data.
Why Fine-Tune
A pretrained model already knows language; fine-tuning nudges it to excel at your specific task using your labeled data.
Start From a Checkpoint
Load a model with a classification head sized to your labels. The base weights are reused, only the head starts fresh.
from transformers import AutoModelForSequenceClassification
m = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=2)All lessons in this course
- The Transformers Library Tour
- Tokenizing for Transformer Models
- Fine-Tuning With the Trainer API
- Evaluating and Saving Your Model