Code Monkey home page Code Monkey logo

pos-tagger-maithili's Introduction

BERT-CRF for Part-of-Speech Tagging

This repository contains a Part-of-Speech (POS) tagging system that combines the powerful BERT (Bidirectional Encoder Representations from Transformers) model with a Conditional Random Field (CRF) layer to improve the tagging accuracy by leveraging contextual information more effectively.

Model Description

The BERT-CRF model integrates a pre-trained BERT model with a CRF layer. BERT provides deep contextualized embeddings that capture complex syntactic and semantic information from text, while the CRF layer models the dependencies between tags in sequences, improving the coherence of predictions.

Components

  1. BERT Model: Extracts rich feature representations for each token.
  2. Dropout Layer: Reduces overfitting during training by randomly setting input elements to zero.
  3. Linear Layer: Maps the BERT output features to the space of tag labels.
  4. CRF Layer: Models the tag sequence, taking into account the conditional probabilities of tags given their neighbors in the sequence.

Prerequisites

  • Python 3.8+
  • PyTorch
  • HuggingFace Transformers
  • TorchCRF
  • sklearn

Installation

Set up a virtual environment and install the required packages:

python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`
pip install torch transformers sklearn TorchCRF
pip install -r requirements.txt

Data Format

The training and validation data should be formatted as follows, with each word and its tag separated by a tab, and sentences separated by a newline:

word2\ttag2
word3\ttag3

word1\ttag1
word2\ttag2
word3\ttag3

Training the Model

To train the model, run the script bert_crf.py

Modify model to change model parameters, training settings, or to integrate custom configurations for the BERT and CRF components.

Outputs

The script will output the model's performance on the validation dataset including metrics such as accuracy, precision, recall, and F1-score. It will also save the trained model for later use.

pos-tagger-maithili's People

Contributors

abhisekjha 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.