Skip to content

Repository files navigation

NLP Multi-Label Classification with BERT / DistilBERT

Overview

This project implements multi-label text classification using BERT and DistilBERT with TensorFlow (TF-Keras) or PyTorch. It supports:

  • Tokenization with Hugging Face transformers
  • GPU acceleration (PyTorch / TensorFlow)
  • Multi-label classification
  • Training / validation evaluation and metrics

Recommended Setup

Option 1: Run Easily on Google Colab (Recommended)

Colab provides:

  • Pre-configured GPU / TPU
  • Compatible TensorFlow, PyTorch, CUDA, and Transformers
  • Avoids local installation headaches (drivers, CUDA version conflicts)

Steps:

  1. Open Colab
  2. Upload your notebook or clone the repo
  3. Go to Runtime → Change runtime type → Select GPU or TPU
  4. Install required packages:
!pip install -q transformers tf-keras sentencepiece
  1. Run your training cells, everything should work out-of-the-box.

Option 2: Run Locally with GPU (Version-Oriented Setup)

Colab abstracts all CUDA and driver issues, but if you want to run locally on your GTX 1650, follow this setup to ensure proper GPU acceleration and compatibility.

1️⃣ Prerequisites

  • GPU: NVIDIA GTX 1650 (or higher)
  • CUDA: 12.2 (recommended for TensorFlow 2.16) or 12.1 (for PyTorch 2.3)
  • NVIDIA Studio / Game Ready Driver installed and working
  • Python >= 3.10

2️⃣ Python Environment Setup

  1. Create a virtual environment:
python -m venv venv

# Linux/macOS
source venv/bin/activate

# Windows
venv\Scripts\activate

3️⃣ Install required packages

python -r requirements.txt

4️⃣ Verify GPU detection

# For PyTorch

import torch
if torch.cuda.is_available():
    print("CUDA is available. Using GPU for training.")
    print("Device:", torch.cuda.get_device_name(0))
else:
    print("CUDA is not available. Using CPU for training.")
# For Tensorflow

import tensorflow as tf
gpus = tf.config.list_physical_devices("GPU")
if gpus:
    print("TensorFlow sees GPU(s):", gpus)
else:
    print("TensorFlow does not detect GPU. Using CPU for training.")

5️⃣ Summary

  1. Ensures local GPU is properly leveraged.
  2. Version-aligned PyTorch/TensorFlow avoids CUDA mismatches.
  3. Smaller batch sizes or DistilBERT help manage VRAM limitations on GTX 1650.

About

This is a natural language processing (NLP) project where different approaches to text classification has been executed and compared with results.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages