/root

Fine-tuned BERT model for POS tagging

Primary LanguagePythonMIT LicenseMIT

This BERT based POS tagger is derived almost entirely from https://github.com/Kyubyong ipython notebook

https://github.com/Kyubyong/nlp_made_easy

Requirements

  • Pytorch (conda install -c pytorch pytorch)
  • Pytorch pre-trained BERT . (pip install pytorch-pretrained-bert)
  • nltk (pip install nltk)

Data

  • Automatically fetches treebank training data using nltk (when running first time, it will prompt to install treebank. This can be done from within python prompt in command line)

Usage

  1. To train. python bert_post_train.py < model dir to save. e.g. out > . (this will result in training with accuracy ~98%)

  2. To test. python bert_post_test.py < model dir to load >

    Example input: The bird flew over the house and perched on a tree

    Output: [('The', 'DT'), ('bird', 'NN'), ('flew', 'VBD'), ('over', 'IN'), ('the', 'DT'), ('house', 'NN'), ('and', 'CC'), ('perched', 'VBD'), ('on', 'IN'), ('a', 'DT'), ('tree', 'NN')]

License

MIT License