Git Product home page Git Product logo

vietnamese_ner_bert's Introduction

Vietnamese Named-Entity Recognition

Introductions

This is a Pytorch implementation of Named Entity Recognition (NER) for Vietnamese. Pretrained model from BERT Hugging Face and Underthesea Toolkit for sentence segmentation to pre-process input raw text is used.

Installation

Requirements:

  • Python 3.7
  • Pytorch 1.7

Install dependencies:

pip install -r requirements.txt

You can review the requirements.txt's comment for an appropriate Pytorch version.

Dataset format

The input data is from VietAI Advanced NLP-02 class.

Its format follows CoNLL-2003 format with four columns separated by a tab character, including of Word, POS tag, Chunking tag, Named-Entity tag, and nested Named-Entity. However, I did not use the nested named entity column due to the requirement of VietAI Advanced NLP-02 class.

The data consists of 4 entities:

  • PER: person.
  • ORG: organization.
  • LOC: location.
  • MISC: miscellaneous.

and

  • O: others

Note: Structure of the dataset

├── data
|  └── raw_data
|   └── test
|   └── train

Each word is put on a separate line and there is a start-of-sentence and end-of-sentence labels before and after each sentence, respectively. The table below describes an example Vietnamese sentence in dataset.

Word POS Chunk NER
Dương Np B-NP B-PER
V B-VP O
một M B-NP O
chủ N B-NP O
cửa N B-NP O
hàng N I-NP O
lâu A B-AP O
năm N B-NP O
E B-PP O
Np B-NP B-LOC
Nội Np I-NP I-LOC
. CH O O

Run the code

Train

  1. Create data in .csv format: python create_data.py (The train dataset is split into Train-70% and Validation-30%)

  2. Train the model: python train.py --data_dir new_data/ --model_name_or_path bert-base-multilingual-cased --output_dir outputs

  3. Convert the outputs of the model to the required format for submission: python create_output.py

Predict

You can visualize the prediction: python predict.py --pretrain_dir outputs/

Results

The overall performance of the model on validation dataset:

Models F1-Score
O MISC PER ORG LOC F1-Score IOB-tag
BERT 99.79% 95.87% 96.66% 84.78% 93.89% 92.43%

vietnamese_ner_bert's People

Contributors

phkhanhtrinh23 avatar

Stargazers

kan_cin avatar chienbd avatar toy avatar  avatar Karen Lam avatar

Watchers

Kostas Georgiou avatar  avatar

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.