Fine-tuning BERT for NER
In this recipe, we will fine-tune the pretrained BERT model for the NER task. The difference between training a model from scratch and fine-tuning it is as follows. Fine-tuning an NLP model, such as BERT, involves taking a pretrained model and modifying it for your specific task, such as NER in this case. The pretrained model already has lots of knowledge stored in it and the results are likely to be better than when training a model from scratch.
We will use similar data as in the previous recipe, creating a model that can tag entities as Artist
or WoA
. The data comes from the same dataset but it is labeled using the IOB format, which is required for the transformers
packages we are going to use. We also only use the Artist
and WoA
tags, removing the Artist_or_WoA
tag, since there is not enough data for that tag.
For this recipe, we will use the Hugging Face Trainer
class, although it is also possible to train Hugging Face models using PyTorch or Tensorflow...