A company wants to build a spam classifier for email text. They have a few thousand labeled examples and plan to fine-tune a pre-trained BERT model (trained on English Wikipedia). How should the specialist initialize the BERT model before fine-tuning on the custom labeled emails?
Choose an answer
Tap an option to check your answer.
Correct answer: Initialize all layers with pretrained weights, replace the final fully connected layer with a new classifier, and fine-tune the model (including the classifier) using the labeled data..
Why this is the answer
The correct approach is to initialize all layers with pretrained weights, replace the final fully connected layer with a new classifier, and then fine-tune the entire model (including the new classifier) using the labeled data. This leverages the extensive knowledge captured in the pretrained BERT weights for general language understanding, while adapting the model specifically for the spam classification task with the new classifier. Fine-tuning the entire model allows the pretrained layers to adjust their representations to be more relevant to the specific downstream task. Initializing all layers with pretrained weights except the final fully connected layer is a common practice, but it's crucial to fine-tune the entire model, not just the new classifier. Training only the classifier on top of the first output token (CLS token) would not allow the powerful feature extraction layers of BERT to adapt to the specific nuances of spam detection. Initializing all layers with random weights would discard the benefits of pretraining, requiring significantly more data and training time to achieve comparable performance.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed