Giter VIP home page Giter VIP logo

flan-t5-text-classifier's Introduction

flan-t5 Fine-tuning for Text Classification

This GitHub project is aimed at fine-tuning the flan t5 model for a text classification task using an E-commerce text dataset for 4 categories - "Electronics", "Household", "Books" and "Clothing & Accessories".

Evaluation Statistics

AutoModelForSequenceClassification

Text Classification model can be found on HuggingFace. The model is trained on the dataset and evaluated on the test set. The evaluation metrics are as follows:

The main advantage of this model is that together with prediction it outputs the confidence score for each class. This can be used to filter out the predictions with low confidence.

AutoModelForSeq2Seq

Text2Text Generation model can be found on HuggingFace. The model is trained on the dataset and evaluated on the test set. The evaluation metrics are as follows:

Dataset

The dataset is a classification-based E-commerce text dataset, which almost covers 80% of any E-commerce website. The dataset consists of product and description data for 4 categories. The dataset can be found here.

Project Features

The project employs the tokenizer of flan-t5 by Hugging Face, which helps in splitting the input text into a format that is understandable by the model.

An evaluation function has been implemented for post-processing the labels and predictions, which will also handle sequence length adjustments.

The project uses Seq2SeqTrainer and SequenceClassification for training the model. It also includes a helper function to preprocess the dataset.

Usage

To leverage the project you need to run the flan-t5-finetuning.py script which will trigger the training of the model.

The 'train' function fine-tunes the flan-t5 model, trains it with the dataset, outputs the metrics, creates a model card and pushes the model to Hugging Face model hub.

The preprocess function tokenizes the inputs, and also handles tokenization of the target labels. The compute_metrics function evaluates the model performance based on the F1 metric.

Getting Started

STEP 1: create and activate python virtual environment

python -m venv venv
source venv/bin/activate

STEP 2: install requirements with poetry

poetry install -vv

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This repository is licensed under MIT (c) 2023 GitHub, Inc.

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.