# Recommendation systems — Muhammad Huzaifa Shahbaz

Canonical page: https://mhuzaifa.com/expertise/recommendation-systems
Last updated: 2026-09-28
Person: Muhammad Huzaifa Shahbaz (https://mhuzaifa.com)

A custom sleep-recommendation engine for OptySleep, built around a formula, semantic similarity, caching, and A/B tests.

## What I build

- On-device-adjacent product recommendations that suggest the next sleep intervention from what the user already tried.
- The serving path around that model: cache, experiment assignment, and a FastAPI service the iOS app can call.

## Architecture

- OptyAI uses a custom ranking formula plus Sentence-BERT embeddings so 'caffeine reduction helped' can surface a related next step such as a blue-light filter.
- Redis caches recommendation reads. A/B tests compare formula changes against engagement, retention, and subscription renewal.
- The service is FastAPI and Python, packaged with Docker, with Firebase in the product stack.

## Production constraints

- The public result is about a 70% increase in iOS engagement, with improved retention and higher subscription renewals.
- A recommendation that ignores the last trial feels random. The history of what the user already tried is an input, not a log line.
- iOS integration was handled by Digital Dividend's partner side; the recommendation engine and backend were the in-house piece.

## Stack

FastAPI, Python, Redis, Sentence-BERT, Docker, Firebase

## Tradeoffs

- A custom formula is explainable to a product team and harder to improve than an offline-trained ranker once the catalog of sleep methods grows.
- Semantic similarity finds nearby interventions. It does not by itself know which one changed someone's sleep. The A/B test is what makes that claim.

## Projects

- [OptyAI for OptySleep](https://mhuzaifa.com/portfolio/optysleep): OptyAI recommendation engine behind the OptySleep iOS app.

## External verification

- [OptySleep](https://optiself.co/)
- [OptySleep on the App Store](https://apps.apple.com/us/app/optysleep/id6458265948)

## Questions

### What recommendation system has he shipped?

OptyAI for OptySleep: a FastAPI service using Redis, A/B testing, and Sentence-BERT similarity. The published engagement change is about 70%.

### Is it a generic collaborative-filtering library?

No. The portfolio describes a custom formula over sleep-method history, with embeddings used to propose the next related method.
