Giter VIP home page Giter VIP logo

pos-tagger-bert-tensorflow's Introduction

BERT POS tagger (tensorflow)

Fine-tune Google's BERT for POS-tagging task (UD Treebank as the dataset).

Folder Description:

pos-tagger-bert-tensorflow
|____ pos_tagger_bert_tensorflow.ipynb  # Notebook with all actions required to download UD Treebank dataset and BERT model, fine-tune BERT, and evaluate POS tagger
|____ bert_pos.py           # Main code
|____ data                  # Train data
|____ middle_data           # Middle data (label id map)
|____ output                # Output (final model, predicted results)
|____ uncased_L-12_H-768_A-12	# BERT model downloaded from -> https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip
|____ run_pos.sh    		# Run model and evaluate results

Install packages:

pip install pyconll  # for UD treebank reading
pip install bert-tensorflow # for using bert model

Usage:

Preferably run notebook pos_tagger_bert_tensorflow.ipynb, or

bash run_pos.sh

What's in run_pos.sh:

#!/usr/bin/env bash

  python  bert_pos.py\
    --task_name="POS"  \
    --do_lower_case=False \
    --crf=False \
    --do_train=True   \
    --do_eval=True   \
    --do_predict=True \
    --data_dir=data   \
    --vocab_file=./uncased_L-12_H-768_A-12/vocab.txt  \
    --bert_config_file=./uncased_L-12_H-768_A-12/bert_config.json \
    --init_checkpoint=./uncased_L-12_H-768_A-12/bert_model.ckpt   \
    --max_seq_length=220   \
    --train_batch_size=16   \
    --learning_rate=2e-5   \
    --num_train_epochs=4.0   \
    --output_dir=./output/result_dir

perl conlleval.pl -o '[SEP]' -r -d '\t' < ./output/result_dir/label_test.txt

References:

[1] https://arxiv.org/abs/1810.04805

[2] https://github.com/google-research/bert

Acknowledgement

Natural Language Processing course is part of the MSc in Computer Science of the Department of Informatics, Athens University of Economics and Business. The course covers algorithms, models and systems that allow computers to process natural language texts and/or speech.

pos-tagger-bert-tensorflow's People

Contributors

soutsios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pos-tagger-bert-tensorflow's Issues

fill missing in data folder

FileNotFoundError Traceback (most recent call last)
in ()
----> 1 convert_ner_format(train_text, train_label, 'data/train.txt')
2 convert_ner_format(test_text, test_label, 'data/test.txt')
3 convert_ner_format(val_text, val_label, 'data/dev.txt')

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.