🔗 Live Demo: https://hybrid-rec.vercel.app/
A production-grade recommendation engine leveraging Hybrid Reinforcement Learning and Transformer Architectures to optimize user engagement and long-term value (LTV).
This project implements a Multi-Stage Recommendation Pipeline designed to handle the full user journey, from cold-start to loyal engagement.
| Component | Model Architecture | Role |
|---|---|---|
| 1. Discovery Engine | Collaborative Filtering (VAECF) | Finds latent user preferences from implicit feedback (Clicks/Views). |
| 2. Similarity Engine | Content-Based (BERT) | Recommends "More like this" using semantic embeddings of product metadata. |
| 3. Sequence Engine | Transformer (SASRec-style) | Predicts next-item intent based on immediate user history. |
| 4. Decision Engine | Hybrid RL Agent (Transformer-DQN) | The Core Innovation. Optimizes the final ranking to maximize long-term reward (Purchase vs. Click). |
Our Transformer-based sequence model significantly outperforms standard baselines, achieving 100% Catalog Coverage through a tiered inference strategy.
| Metric | Score | Business Impact |
|---|---|---|
| Recall@10 | 8.72% | 1.04x lift vs. Popularity Baseline. Users see more relevant items. |
| Coverage@50 | 99.40% | The model recommends niche items, preventing "Popularity Bias." |
| Recall@50 | 13.00% | Strong candidate retrieval for the RL ranking stage. |
Data Source: MLflow Evaluation Logs
The Hybrid RL Agent was trained using a Sim-to-Real workflow in a custom Gymnasium environment.
- Stable Convergence: The agent successfully transitioned from exploration to exploitation, with epsilon decaying to 0.05.
- Reward Optimization: Cumulative reward stabilized, indicating the agent learned to prioritize high-value actions (Purchases) over low-value ones (Views).
(Epsilon Decay vs. Cumulative Reward over 400 Episodes)
- Training: TensorFlow/Keras, Cornac (for VAE), Gymnasium (RL Env).
- Tracking: MLflow & DagsHub (Experiment tracking).
- Serving: FastAPI (Asynchronous inference).
- Edge Optimization: TensorFlow Lite (TFLite) for <10ms inference latency.
- Containerization: Docker for reproducible deployment.
-
Clone the Repository
git clone [https://github.com/okefemi12/ecommerce-recommender-system.git](https://github.com/okefemi12/ecommerce-recommender-system.git) cd ecommerce-recommender -
Start the API (Docker)
docker build -t recommender-api . docker run -p 8000:8000 recommender-api -
Test the Endpoint
curl -X POST "http://localhost:8000/recommend" \ -H "Content-Type: application/json" \ -d '{"history": [101, 204, 305], "user_id": "user_123"}'
src/: Production FastAPI code and inference logic.notebooks/: Detailed Data Science experiments (EDA, Training pipelines).models/: Serialized model artifacts (TFLite, Keras).tests/: Unit and integration tests.
