Deep Learning · 2026
News Classification (LSTM)
End-to-end NLP pipeline in PyTorch classifying news into World, Sports, Business and Sci/Tech: preprocessing, vocabulary, training, evaluation, inference and a REST API.
Model
- Embedding layer → LSTM encoder → classification head
- Vocabulary built from the training corpus with min-frequency pruning
- Four-class softmax output
Dataset
AG News — headlines and descriptions labeled World, Sports, Business, Sci/Tech.
Results & metrics
- Classes
- 4
- Test accuracy
- ~0.90
- Serving
- REST API
Deployment steps
- 1Preprocess text and build the vocabulary
- 2Train the LSTM, track best validation accuracy
- 3Serialize model + vocab for inference
- 4Expose POST /classify through FastAPI
Tech stack
- PyTorch
- LSTM
- NLP
- REST API