blackmangoo/NewsLens

Python

0

1 commits

updated May 31, 2026

See the code

README

📰 NewsLens — BERT-Powered News Topic Classifier

Real-time news headline classification using a fine-tuned BERT transformer model.

Python Transformers Streamlit


🎯 Objective

Fine-tune bert-base-uncased on the AG News dataset to classify news headlines into 4 topic categories:

  • 🌍 World — International affairs and geopolitics
  • 🏅 Sports — Athletic events and competitions
  • 💼 Business — Finance, markets, and corporate news
  • 🔬 Sci/Tech — Science, technology, and innovation

🔬 Methodology / Approach

  1. Data Loading & Preprocessing: Loaded the AG News dataset from Hugging Face Datasets. Tokenized all text using the bert-base-uncased tokenizer with padding and truncation to 128 tokens.
  2. Model Fine-Tuning: Fine-tuned bert-base-uncased (110M parameters) using the Hugging Face Trainer API with learning rate scheduling, weight decay, and early stopping.
  3. Evaluation: Computed accuracy, per-class precision/recall/F1, and a confusion matrix on the held-out test set.
  4. Deployment: Built a premium Streamlit UI for real-time headline classification with confidence visualization. Deployed on Hugging Face Spaces.

📊 Key Results

MetricScore
Test Accuracy~94%
Macro F1-Score~0.94
Training Epochs3

Results may vary slightly depending on hardware and random seeds.


🚀 Quick Start

Install Dependencies

pip install -r requirements.txt

Train the Model

python train.py

Launch the App

streamlit run app.py

🏗️ Project Structure

NewsLens/
├── app.py              # Streamlit UI for live inference
├── train.py            # Training & evaluation script
├── requirements.txt    # Python dependencies
└── README.md           # Project documentation

🛠️ Tech Stack

  • Hugging Face Transformers — BERT fine-tuning
  • Hugging Face Datasets — AG News dataset
  • PyTorch — Deep learning backend
  • scikit-learn — Evaluation metrics
  • Streamlit — Interactive web UI
  • Matplotlib / Seaborn — Visualization

📄 License

Built as part of the DevelopersHub Corporation AI/ML Engineering Internship.

blackmangoo/NewsLens

Python

0

1 commits

updated May 31, 2026

See the code

README

📰 NewsLens — BERT-Powered News Topic Classifier

Real-time news headline classification using a fine-tuned BERT transformer model.

Python Transformers Streamlit


🎯 Objective

Fine-tune bert-base-uncased on the AG News dataset to classify news headlines into 4 topic categories:

  • 🌍 World — International affairs and geopolitics
  • 🏅 Sports — Athletic events and competitions
  • 💼 Business — Finance, markets, and corporate news
  • 🔬 Sci/Tech — Science, technology, and innovation

🔬 Methodology / Approach

  1. Data Loading & Preprocessing: Loaded the AG News dataset from Hugging Face Datasets. Tokenized all text using the bert-base-uncased tokenizer with padding and truncation to 128 tokens.
  2. Model Fine-Tuning: Fine-tuned bert-base-uncased (110M parameters) using the Hugging Face Trainer API with learning rate scheduling, weight decay, and early stopping.
  3. Evaluation: Computed accuracy, per-class precision/recall/F1, and a confusion matrix on the held-out test set.
  4. Deployment: Built a premium Streamlit UI for real-time headline classification with confidence visualization. Deployed on Hugging Face Spaces.

📊 Key Results

MetricScore
Test Accuracy~94%
Macro F1-Score~0.94
Training Epochs3

Results may vary slightly depending on hardware and random seeds.


🚀 Quick Start

Install Dependencies

pip install -r requirements.txt

Train the Model

python train.py

Launch the App

streamlit run app.py

🏗️ Project Structure

NewsLens/
├── app.py              # Streamlit UI for live inference
├── train.py            # Training & evaluation script
├── requirements.txt    # Python dependencies
└── README.md           # Project documentation

🛠️ Tech Stack

  • Hugging Face Transformers — BERT fine-tuning
  • Hugging Face Datasets — AG News dataset
  • PyTorch — Deep learning backend
  • scikit-learn — Evaluation metrics
  • Streamlit — Interactive web UI
  • Matplotlib / Seaborn — Visualization

📄 License

Built as part of the DevelopersHub Corporation AI/ML Engineering Internship.