Deep Keyphrase extraction using BERT.
- Clone this repository and install
pytorch-pretrained-BERT
- Change the parameters accordingly in
experiments/base_model/params.json
. We recommend keeping batch size of 4 and sequence length of 512, with 6 epochs, if GPU's VRAM is around 11 GB. - For training, run the command
python train.py
- For eval, run the command,
python evaluate.py
- For running prediction on
data/h1_7.txt
file, runpython keyphrase_task.py
Python version 3.7
We used IO format here.
On test set, we got:
- F1 score: 0.3799
- Precision: 0.2992
- Recall: 0.5201
- Support: 921
['I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']
- Implemented a custom BERT Model, applying Bi-LSTM and CRF layers over PyTorch's
bert-base-uncased
pre-trained model - Added a weight matrix to the loss function to implement
weighted CrossEntropyLoss
This is a modified version of the original repo pranav-ust/BERT-keyphrase-extraction