Project 06 / 10 · RAG & NLP

Sentiment Analysis — DistilBERT + BiLSTM

Transformer vs. recurrent architectures on 204K HuffPost headlines, with a live RSS pipeline surfacing hour-by-hour sentiment from 6 major outlets.

01 / Context

The problem

The project compares transformer and recurrent architectures under one three-class news-labeling setup, then carries the stronger model into a live multi-source news monitor.

02 / System workflow

From input to output

  1. 01Headline / RSS
  2. 02Tokenization
  3. 03DistilBERT inference
  4. 04Class probabilities
  5. 05Trend dashboard

03 / Architecture

Inside the system

A1

The deployed path tokenizes headlines to 64 WordPiece tokens, passes them through six DistilBERT layers, and classifies the pooled representation into negative, neutral, or positive sentiment.

A2

A three-layer BiLSTM with additive self-attention provides the comparison architecture on the same dataset and label scheme.

A3

FastAPI exposes single and batch inference while Streamlit provides manual analysis, batch review, source heatmaps, and hourly or daily trends.

04 / Engineering decisions

What shaped the build

Decision 01

Fair model comparison

DistilBERT and BiLSTM are evaluated on the same HuffPost dataset and label construction rather than unrelated benchmarks.

Decision 02

Operational input

RSS ingestion turns static model evaluation into continuous analysis across six news publishers.

Decision 03

Model delivery

The deployed checkpoint is downloaded and cached on first Streamlit boot, keeping the repository and hosted runtime manageable.

05 / Evidence

Measured, not implied

80.4%

Accuracy

Fine-tuned DistilBERT on the three-class task.

0.919

ROC-AUC

Deployed transformer performance.

+4.4pp

Model lift

Accuracy improvement over BiLSTM with self-attention.

06 / Delivery

What shipped

  • 01Streamlit Community Cloud hosts the interactive application.
  • 02Docker Compose runs the API and interface together for local or container deployment.
  • 03GitHub Actions packages and ships updates on each push.

Constraint documented

Neutral headlines are the hardest class, with F1 0.60, because broad category-derived labels cannot cleanly represent mixed sentiment.