Two-Stage Product Recommender with Safe Model Promotion

Build a two-stage product recommender end to end: leakage-safe time windows, a PyTorch two-tower retriever with logQ correction, a FAISS HNSW index tuned against exact search, a LightGBM LambdaRank ranker, paired-bootstrap evaluation, a hash-verified ONNX bundle with a promotion gate and rollback, and a FastAPI service with fallbacks, shadow scoring and drift checks.

Machine Learning Engineer. Advanced.

What you will build and explain

  • Design retrieval-then-ranking and explain what each stage contributes, using candidate recall and paired lifts.
  • Build time-based splits and point-in-time features, and prove with tests that they do not leak.
  • Train a two-tower model with in-batch softmax and logQ correction, resumable from checkpoints.
  • Tune HNSW search by measuring recall against exact search, and rank candidates with LambdaRank.
  • Promote models only on paired, segment-aware evidence; serve only hash-verified bundles; roll back by alias.
  • Operate the API with readiness, labelled fallbacks, a latency budget, metrics, shadow scoring and PSI drift reports.

Before you begin

  • Write Python functions, classes and modules; use NumPy arrays and pandas DataFrames day to day.
  • Explain train/test splits, overfitting and precision/recall; PyTorch, ranking metrics and ANN search are taught.
  • Use a terminal and Git, run Docker containers and send JSON requests with curl.
  • Docker with the Compose plugin, 4 CPU cores and 8 GB of memory for Docker, and about 8 GB of free disk.

Who this is for

For engineers who write Python, use NumPy and pandas and have trained a model, and want to build the retrieval, ranking, evaluation and safe-release system around it.

Curriculum

Learning topics (12)
  1. Check your starting skills and prepare your machine

    This project asks you to build something most tutorials skip: the system around a recommendation model. You will train models, but most of the work is deciding what data a model may see, measuring whether it is better than a simple rule, packaging it so the serving code cannot load the wrong thing, and noticing when live traffic stops looking like the data you evaluated on.

  2. Follow the data from event log to served carousel

    Brindle Market wants its "Recommended for you" carousel to show products a particular shopper is likely to want, instead of last month's best-sellers. That sounds like one model. In practice it is a small system with three jobs that pull in different directions:

  3. Build leakage-safe time windows and point-in-time features

    A recommender is judged by one question: does it predict what a shopper will do next? Every choice in this lesson, from the synthetic data to the four time windows and the snapshots, exists to make the offline answer to that question honest. By the end you will be able to explain what leakage is, why a random train/test split leaks for recommenders, and how this project's snapshots make leakage impossible by construction.

  4. Train a two-tower retrieval model with logQ-corrected in-batch softmax

    The first stage of the recommender has a hard job: out of 6,000 products, pick about a hundred that this shopper might plausibly want, in a few milliseconds, for every page view. This lesson explains how a two-tower model makes that possible, how it is trained with in-batch negatives and logQ correction, and how this project makes training resumable and reproducible.

  5. Tune approximate nearest neighbour search against exact search

    Once every product has a vector, retrieval is a search problem: given the shopper's vector, find the 100 product vectors with the highest dot product. This lesson explains how FAISS's HNSW index answers that quickly, what it gives up in exchange, and how the project measures and controls that loss instead of guessing.

  6. Rank candidates with LightGBM LambdaRank and shared features

    Retrieval hands over about a hundred plausible products. Most shoppers will only look at the first few, so the order matters more than the set. This lesson explains learning to rank with LightGBM's LambdaRank, how its training data is built from a later time window, and why every ranking feature is computed by one shared function.

  7. Compare recommenders with paired bootstrap intervals and segments

    The product team's first question was whether a personalized system beats the current popularity rule. "The NDCG went up" is not an answer. This lesson explains the ranking metrics, the baselines the models must beat, how bootstrap intervals and paired comparisons express uncertainty, and why results are split into segments.

  8. Record and compare runs with MLflow

    After a few experiments, the hardest question is often "which settings produced that number?". This lesson explains what experiment tracking records, how this project connects several pipeline stages to one MLflow run, and what MLflow is deliberately not used for.

  9. Export to ONNX and package a hash-verified bundle

    A trained run lives in a folder of checkpoints, indexes and reports. None of it is ready to serve: the API has no PyTorch, files can change after evaluation, and nothing yet ties the served files to their evidence. This lesson explains the export stage: converting the user tower to ONNX and proving the conversion is faithful, and packaging a bundle whose ID covers every byte.

  10. Promote models by evidence and roll back by alias

    A model registry answers three questions: which models exist, which one is serving, and how did it get there? This lesson explains the project's small file registry, the promotion gate that decides whether a challenger may replace the champion, and why rollback is a pointer swap rather than a rebuild.

  11. Serve recommendations with readiness, fallbacks and a latency budget

    The storefront calls the recommendation API on every product page. It needs an answer quickly, every time, and it needs to know what kind of answer it got. This lesson explains how the FastAPI service loads and verifies the champion bundle, what happens to a request from validation to response, and how the fallback and the latency budget keep pages answered.

  12. Watch metrics, drift and a shadow challenger

    A recommender can fail without returning a single error: latency creeps up, the fallback quietly answers half the traffic, or shoppers start behaving differently from the data the model was evaluated on. This lesson covers the signals the API exposes, how to read them under load, how the population stability index detects drift, and how shadow scoring tries a challenger on real requests without risk.

Practical build steps (10)
  1. Prepare Docker and build the images

    You start with the source folder and Docker. By the end of this step you have the two images the lab uses (one for the offline pipeline, one for the API) and a running MLflow server for recording experiments. Nothing has been generated or trained yet.

  2. Generate, validate and split the data

    Starting from built images and a running MLflow server, you create Brindle Market's synthetic event log, check it against the data contract and cut it into time windows with a point-in-time snapshot at each cutoff. These snapshots are the only way later stages see the data, so this step decides what every model is allowed to know.

  3. Train the retrieval model and practise resuming

    With the snapshots in place, you train the two-tower retrieval model. You stop it deliberately after the first epoch and resume it, to see that checkpoints make an interrupted run continue rather than start over. MLflow records the loss and validation recall of every epoch.

  4. Build the index and train the ranker

    The trained item tower embeds all 6,000 products, FAISS builds an HNSW index over them, and a sweep measures how many of the exact nearest neighbours each efSearch setting finds. Then retrieval proposes candidates for every ranker-window customer and LightGBM learns to order them from what those customers did next.

  5. Evaluate against the baselines

    This is the step that answers the product team's first question: is the personalized system better than the current popularity rule, by how much, for which customers, and how certain is that? The evaluation runs all four strategies on the untouched test window and records per-customer results with bootstrap intervals and segments.

  6. Export, register and promote the bundle

    An evaluated run is not yet something the API can serve. Export converts the user tower to ONNX and checks it, measures the request path in-process, records a reference traffic profile and hashes every file into a manifest. Registration stores a verified copy as challenger, and promotion applies the gate before making it champion.

  7. Start the API and request recommendations

    The API container starts, verifies the champion bundle and loads it, and only then reports ready. You send requests for a known customer, an anonymous session and an unknown visitor, and force a degraded response by shrinking the latency budget, so you see every strategy the API can return.

  8. Load test, read metrics and check drift

    With the API ready, you send generated traffic, read the latency summary and the Prometheus metrics, and run the drift report. Then you send traffic shaped like the start of the garden season and run the drift report again to watch it change, and interpret what the alert does and does not mean.

  9. Release a challenger, shadow it and roll back

    A recommender is never finished; this step practises the release loop. You retrain without the logQ correction on the same dataset, register the result as challenger, shadow it on live requests, and let the promotion gate decide. Finally you practise a rollback and return the registry to the original champion.

  10. Remove the lab

    Cleanup removes everything this project created: its containers, network, volumes (datasets, runs, registry, logs and MLflow data) and images. It works from any state, including a build that stopped part-way, and leaves other Docker resources on your machine alone.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

Everything runs locally in Docker; no cloud account, GPU or paid service is used. Expect about 1-2 GB of downloads for images and packages, a few GB of disk while the lab exists, and some CPU time for training. The optional CI workflow uses GitHub Actions minutes on your own repository. This is a learning reference, not a hosted lab or a production-readiness guarantee.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party packages installed from the lock files, such as PyTorch, FAISS, LightGBM, ONNX Runtime, MLflow and FastAPI, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy