This project demonstrates fine-tuning a BERT model for language modeling using TensorFlow. Bidirectional encoder representations from transformers (BERT) is a language model introduced in October 2018 by researchers at Google. It learns to represent text as a sequence of vectors using self-supervised learning. It uses the encoder-only transformer architecture.
- TensorFlow 2.x
- Hugging Face Transformers library
- Datasets library from Hugging Face
- Install the required dependencies:
pip install -r requirements.txt
-
OPTIONAL: Train model on your data you want
- First: edit
models/dataset.json
to your liking. - Second: train the model, run:
python scripts/train.py
- First: edit
-
You can run tests of your trained BERT model via the
tests/
directory. -
The model will be saved to the
trained_model/
directory.
This is a simple setup for fine-tuning BERT. You can modify it for larger datasets or more advanced features such as early stopping, distributed training, etc.