MCPcopy Index your code
hub / github.com/VanekPetr/flan-t5-text-classifier

github.com/VanekPetr/flan-t5-text-classifier @v0.4.46

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.46 ↗ · + Follow
12 symbols 86 edges 5 files 11 documented · 92% updated 20mo agov0.4.46 · 2024-07-30★ 441 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.

Core symbols most depended-on inside this repo

Shape

Function 12

Languages

Python100%

Modules by API surface

classifier/AutoModelForSeq2SeqLM/flan-t5-finetuning.py4 symbols
classifier/AutoModelForSequenceClassification/flan-t5-finetuning.py3 symbols
classifier/AutoModelForSequenceClassification/classify_and_evaluate.py2 symbols
classifier/AutoModelForSeq2SeqLM/classify_and_evaluate.py2 symbols
classifier/data_loader.py1 symbols

For agents

$ claude mcp add flan-t5-text-classifier \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page