Finetune Transformers
Learning how to finetune a BERT model using PyTorch/TensorFlow from HuggingFace for your usecase is a art in itself because there are so many ways and methods to do it that you will not able to figure out which is the best for my usecase. BTW, you can always refer to HuggingFace documentation.
For example!
- Choose between PyTorch and TensorFlow. (let choose )
- If you are importing your dataset with
pandas
orpolars
then need to create a custom class by inheritingtorch.utils.data.Dataset
class. - Then need to tokenize the data and need to use
DataLoader
and Data Collator. - Then use a for-loop to train and validate the model.
But there is a easy way to finetune, by using objects like
transformers.TrainingArguments
andtransformers.Trainer
which reduces the manual looping complexity.