all projects

Real-time NLP · Full stack

A sentiment engine you can watch think.

Quantized DistilBERT for real-time sentiment inference, paired with an interactive 3D particle interface. Type a sentence and a cloud of particles expands, contracts and changes colour with the prediction. Built as the capstone for my Natural Language Processing course.

loading 3D scene…

WebGL · move your cursor

0.00%

Accuracy

0.0000

ROC AUC

0.0M

Training tweets

<0 ms

GPU inference

// highlights

Whatmakesittick

01

FP32 → INT8 quantization

Dynamic INT8 quantization of the 66M-parameter DistilBERT gives a 2-3x speedup with minimal accuracy loss.

02

Particles that respond

Three.js particles turn green and expand for positive text, red and contract for negative, and yellow at maximum expansion for neutral.

03

Runs on any hardware

CUDA on NVIDIA GPUs, MPS on Apple Silicon and a CPU fallback, with training scripts tuned for each (FP16 mixed precision on CUDA, torch.compile on MPS).

04

Evaluated properly

320K held-out samples, with precision, recall, F1, ROC AUC, Cohen's Kappa (0.7697), log loss (0.2729), a confusion matrix and 300 DPI plots.

05

A real API

FastAPI backend with CORS, a health check and a /predict endpoint that returns the sentiment, confidence and inference time. Swagger docs come free.

06

Glassmorphism UI

A React 19 front end with live confidence scores and latency readouts beside the 3D visualisation.

// architecture

Howit'sbuilt

  1. 01React + Three.js3D particle UI
  2. 02FastAPIREST · /predict · /health
  3. 03Quantized DistilBERTINT8 · CUDA / MPS / CPU
  1. step 01

    Clean

    Remove URLs and usernames, lowercase, tokenize to 35 tokens. 70/10/20 train/val/test split.

  2. step 02

    Train

    DistilBERT (6 layers), 3 epochs, AdamW at 2e-5 with 10% warmup.

  3. step 03

    Quantize

    Dynamic INT8 quantization after training for fast inference.

  4. step 04

    Serve

    FastAPI loads the quantized model and exposes /predict and /health.

  5. step 05

    Visualise

    React and Three.js animate the prediction in real time.

// under the hood

Thedetails

POST /predict
curl -X POST "http://127.0.0.1:8000/predict" \
  -H "Content-Type: application/json" \
  -d '{"text": "I absolutely love this product!"}'

{
  "sentiment": "Positive",
  "confidence": 0.9567,
  "inference_time_ms": 24.32
}

Inference benchmarks (33M effective parameters, INT8)

DeviceLatencyThroughput
RTX 3080 (CUDA)8 ms125 samples/s
M1 Max (MPS)45 ms22 samples/s
Intel i9 (CPU)150 ms6.7 samples/s

// stack

Builtwith

  • Python
  • PyTorch
  • DistilBERT
  • FastAPI
  • React 19
  • Three.js
  • Vite
  • Tailwind