Model Card: BERT Fine-Tuned for Frugal AI Challenge - Text Task
Model Overview
This model is a fine-tuned version of the bert-base-uncased transformer model, specifically tailored for multi-class text classification. It was developed as part of the Frugal AI Challenge to classify text into eight distinct categories. The model incorporates a custom classification head and leverages class weighting to address dataset imbalance.
Dataset
Source: Frugal AI Challenge Text Task Dataset
Classes: 8 unique labels representing various categories of text
Preprocessing: Tokenization using BertTokenizer with padding and truncation to a maximum sequence length of 128.
Model Architecture
Base Model: bert-base-uncased
Classification Head: Custom head with weighted cross-entropy loss to handle class imbalance.
Number of Labels: 8
Training Details
Optimizer: AdamW
Learning Rate: 2e-5
Batch Size: 16 (for both training and evaluation)
Epochs: 3
Weight Decay: 0.01
Evaluation Strategy: Performed at the end of each epoch
Hardware: Trained on GPUs for efficient computation
Performance Metrics (Validation Set)
The model achieved the following performance metrics on the validation set:
The training and validation loss evolution over epochs is shown below:
Training Loss
Validation Accuracy
The validation accuracy evolution over epochs is shown below:
Validation Accuracy
Confusion Matrix
The confusion matrix below illustrates the model's performance on the validation set, highlighting areas of strength and potential misclassifications:
Confusion Matrix
Key Features
Class Weighting: Addressed dataset imbalance by incorporating class weights during training.
Custom Loss Function: Used weighted cross-entropy loss for better handling of underrepresented classes.
Evaluation Metrics: Accuracy, precision, recall, and F1-score were computed to provide a comprehensive understanding of the model's performance.
Usage
This model can be used for multi-class text classification tasks where the input text needs to be categorized into one of the eight predefined classes. It is particularly suited for datasets with class imbalance, thanks to its weighted loss function.
Example Usage
python
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
23# Load the fine-tuned model and tokenizer4model = AutoModelForSequenceClassification.from_pretrained("ParisNeo/bert-frugal-ai-text-classification")5tokenizer = AutoTokenizer.from_pretrained("ParisNeo/bert-frugal-ai-text-classification")67# Tokenize input text8text ="Your input text here"9inputs = tokenizer(text, return_tensors="pt", padding="max_length", truncation=True, max_length=128)1011# Perform inference12outputs = model(**inputs)13predicted_class = outputs.logits.argmax(-1).item()1415print(f"Predicted Class: {predicted_class}")
Limitations
Dataset-Specific: The model's performance is optimized for the Frugal AI Challenge dataset and may require further fine-tuning for other datasets.
Class Imbalance: While class weighting mitigates imbalance, some underrepresented classes may still have lower performance.
Sequence Length: Input text is truncated to a maximum length of 128 tokens, which may result in loss of information for longer texts.
Citation
If you use this model in your research or application, please cite it as:
@model{ParisNeo_bert_frugal_ai_text_classification,
author = {ParisNeo},
title = {BERT Fine-Tuned for Frugal AI Challenge - Text Task},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/ParisNeo/bert-frugal-ai-text-classification}
}
Acknowledgments
Special thanks to the Frugal AI Challenge organizers for providing the dataset and fostering innovation in AI research.