Python · NLP · TensorFlow · API
AI & Machine Learning Case Study

The problem
The proliferation of misinformation online necessitates automated systems capable of flagging potentially false content before it spreads. This project aimed to build a robust Natural Language Processing (NLP) pipeline that could analyze the text of a news article and classify it as "Real" or "Fake" with a high degree of confidence.
The core challenge was not just training a model, but dealing with the nuances of language—sarcasm, context, and evolving terminology—and then packaging that model into a RESTful API that a frontend application could consume seamlessly.
Architecture & Stack
Data Pipeline: I started with a large dataset of labeled news articles. The preprocessing pipeline involved lowercasing, removing stop words, stemming (using NLTK), and tokenization.
Model Selection: I evaluated multiple approaches. Baseline models like Naive Bayes and Logistic Regression with TF-IDF vectorization provided a good starting point. However, to capture the sequence and context of words better, I implemented a deep learning approach using Long Short-Term Memory (LSTM) networks via TensorFlow/Keras.
Deployment: The trained model (weights and tokenizer) was serialized and loaded into a lightweight FastAPI backend. This provided a fast, documented endpoint where clients could POST text and receive a probability score.
Technical hurdles
When initially using standard Recurrent Neural Networks (RNNs) for text sequences, the model struggled to retain context from the beginning of long articles due to the vanishing gradient problem.
Switched the architecture to LSTM (Long Short-Term Memory) cells. LSTMs contain internal gating mechanisms (forget, input, output gates) that explicitly decide what information to retain over long sequences, vastly improving accuracy on longer texts.
The deep neural network quickly began to overfit the training data—achieving near 99% accuracy on the training set but performing poorly on the unseen validation set.
Introduced Spatial Dropout layers after the embedding layer and standard Dropout layers between the dense layers. This regularization technique prevented the network from becoming overly reliant on specific nodes, forcing it to learn more generalized patterns.
Results
The final LSTM model achieved highly reliable metrics on the test dataset, proving its viability for real-world application. The FastAPI backend provided sub-100ms inference times, making it suitable for real-time text analysis.
94%
Test Accuracy
0.93
F1-Score
<100ms
API Inference Time