Giter VIP home page Giter VIP logo

gan-bnbert's Introduction

Overview

This repository contains the implementation of a GAN-BERT model for text classification tasks. The model leverages a Transformer encoder combined with a Generative Adversarial Network (GAN) framework to enhance performance on labeled and unlabeled data. The core components include an encoder (BanglaBERT), a discriminator, and a generator, designed to work together to classify text data more effectively. The corresponding paper is available at [Researchgate: Bengali Intent Classification with Generative Adversarial BERT (https://www.researchgate.net/publication/378530127_Bengali_Intent_Classification_with_Generative_Adversarial_BERT).

Abstract

Intent classification is a fundamental task in natural language understanding, aiming to categorize user queries or sentences into predefined classes to understand user intent. The most challenging aspect of this particular task lies in effectively incorporating all possible classes of intent into a dataset while ensuring adequate linguistic variation. Plenty of research has been conducted in the related domains in rich-resource languages like English. In this study, we introduce BNIntent30, a comprehensive Bengali intent classification dataset containing 30 intent classes. The dataset is excerpted and translated from the CLINIC150 dataset containing a diverse range of user intents categorized over 150 classes. Furthermore, we propose a novel approach for Bengali intent classification using Generative Adversarial BERT to evaluate the proposed dataset, which we call GAN-BnBERT. Our approach leverages the power of BERT-based contextual embeddings to capture salient linguistic features and contextual information from the text data, while the generative adversarial network (GAN) component complements the model's ability to learn diverse representations of existing intent classes through generative modeling. Our experimental results demonstrate that the GAN-BnBERT model achieves superior performance on the newly introduced BNIntent30 dataset, surpassing the existing Bi-LSTM and the stand-alone BERT-based classification model.

Technical Novelty

The model's novelty lies in the integration of GANs with BERT architecture to improve text classification. Key aspects include:

  • Transformer Encoder: Utilizes a pre-trained BERT model (csebuetnlp/banglabert) for initial text embeddings.
  • GAN Framework: Incorporates a generator to produce synthetic samples and a discriminator to distinguish between real and generated samples.
  • Joint Training: Simultaneously trains the encoder, generator, and discriminator, allowing the model to leverage both labeled and unlabeled data effectively.
  • Data-Efficient Learning: Integration of GAN allows the model to learn to classify even with small number of training data

Use Cases

The model can be applied to various text classification tasks such as:

  • Intent detection in conversational AI
  • Sentiment analysis
  • Topic classification
  • Any other NLP task requiring robust text classification

Installation

To install the necessary dependencies, clone the repository and install the required packages:

https://github.com/JahidBasher/GAN-BnBERT.git
cd GAN-BnBERT
pip install -r requirements.txt

Training

To train the model, follow these steps:

  • Prepare your dataset in the required format.
  • Update the configuration in config.py as needed.
  • Run the training script:
python main.py

This will train the model for the specified number of epochs and save the checkpoints in the defined artifact path.

Inference

To perform inference with the trained model, you need to set the mode to 'inference' and use the val_step function from the Trainer class:

from config import Config
from trainer import Trainer

cfg = Config()
trainer = Trainer(
    config=cfg,
    encoder=encoder,
    discriminator=discriminator,
    generator=generator,
    train_loader=train_dataloader,
    val_loader=test_dataloader,
    device="cuda"
)
trainer.to_device()
trainer.configure_optimizer()
results = trainer.val_epoch(test_dataloader, mode='inference')

Colab:

BibTex

@inproceedings{inproceedings,
author = {Hasan, Mehedi and Ibna Basher, Mohammad Jahid and Shawon, Md},
year = {2023},
month = {12},
pages = {1-6},
title = {Bengali Intent Classification with Generative Adversarial BERT},
doi = {10.1109/ICCIT60459.2023.10440989}
}

gan-bnbert's People

Contributors

jahidbasher avatar

Stargazers

Mehedi Hasan Abir avatar MarsMC 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.