Git Product home page Git Product logo

bert-keyphrase-extraction's Introduction

I don't maintain this repo anymore. There are now way better repos for you to find out keywords like this one

Keyphrase Extraction using SciBERT (Semeval 2017, Task 10)

Deep Keyphrase extraction using SciBERT.

Usage

  1. Clone this repository and install pytorch-pretrained-BERT
  2. From scibert repo, untar the weights (rename their weight dump file to pytorch_model.bin) and vocab file into a new folder model.
  3. 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.
  4. For training, run the command python train.py --data_dir data/task1/ --bert_model_dir model/ --model_dir experiments/base_model
  5. For eval, run the command, python evaluate.py --data_dir data/task1/ --bert_model_dir model/ --model_dir experiments/base_model --restore_file best

Results

Subtask 1: Keyphrase Boundary Identification

We used IO format here. Unlike original SciBERT repo, we only use a simple linear layer on top of token embeddings.

On test set, we got:

  1. F1 score: 0.6259
  2. Precision: 0.5986
  3. Recall: 0.6558
  4. Support: 921

Subtask 2: Keyphrase Classification

We used BIO format here. Overall F1 score was 0.4981 on test set.

Precision Recall F1-score Support
Process 0.4734 0.5207 0.4959 870
Material 0.4958 0.6617 0.5669 807
Task 0.2125 0.2537 0.2313 201
Avg 0.4551 0.5527 0.4981 1878

Future Work

  1. Some tokens have more than one annotations. We did not consider multi-label classification.
  2. We only considered a linear layer on top of BERT embeddings. We need to see whether SciBERT + BiLSTM + CRF makes a difference.

Credits

  1. SciBERT: https://github.com/allenai/scibert
  2. HuggingFace: https://github.com/huggingface/pytorch-pretrained-BERT
  3. PyTorch NER: https://github.com/lemonhu/NER-BERT-pytorch
  4. BERT: https://github.com/google-research/bert

bert-keyphrase-extraction's People

Contributors

ibatra avatar pranav-ust avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bert-keyphrase-extraction's Issues

what did you do for word out of vocab ?

it seems you have not done anything to handle out of vocab during training .this code have many KeyError during train model . what is your suggestion to handle this error?

Is there any papers published?

I would like to ask if this model has been published. I would like to read it in detail.Working on this task recently, I found that many open source projects are from 2017.
thanks~

Unable to reproduce results

Hi,

I've tried replicating your results for task 1 and task 2, but keep getting drastically lower F1 scores. I am getting an F1 score of 44 for task 1, and an average of 36.79 for task 2. Any suggestions?

Also this is really nice work, thanks for posting this.

'NoneType' object has no attribute 'convert_tokens_to_ids'

While running train.py I encountered this error:
Model name 'model/' was not found in model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese). We assumed 'model/vocab.txt' was a path or url but couldn't find any file associated to this path or url.

Traceback (most recent call last): File "train.py", line 168, in <module> train_data = data_loader.load_data('train') File "/content/BERT-keyphrase-extraction/data_loader.py", line 83, in load_data self.load_sentences_tags(sentences_file, tags_path, data) File "/content/BERT-keyphrase-extraction/data_loader.py", line 51, in load_sentences_tags sentences.append(self.tokenizer.convert_tokens_to_ids(tokens)) AttributeError: 'NoneType' object has no attribute 'convert_tokens_to_ids'

I think it isn't registering the pytorch_model.bin file, which I directly downloaded as bert-base-uncased.tar.gz

Also, when I modify the command to go in task1/train, python train.py --data_dir data/task1/train/ --bert_model_dir model/ --model_dir experiments/base_model the error is:
Loading the datasets... Traceback (most recent call last): File "train.py", line 165, in <module> data_loader = DataLoader(args.data_dir, args.bert_model_dir, params, token_pad_idx=0) File "/content/BERT-keyphrase-extraction/data_loader.py", line 28, in __init__ self.tag_pad_idx = self.tag2idx['O'] KeyError: 'O'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.