Brandless

End-to-end machine learning workflow at Brandless.

We pull a variety of data to train two separate models. One collaborative filter utilizing user-product purchase data (ALS on Apache Spark) and one content-based system using product metadata. Depending on the age of the product, we route between the two different models. Next, we calculate cosine similarities between the input and the available recommendations. Finally, we rank products based on similarity and other factors such as cross-category exposure.

Technology Stack

Brandless has a relatively small (and highly utilized) engineering team, so we needed a system that could be built and maintained by the data team. We had a fairly straightforward list of requirements:

After exploring a variety of different systems and tools, we landed on the following toolkit:

The solution feeds raw data from Amazon Redshift to Databricks Unified Analytics Platform, which trains recommendation system models and develop custom pre and post-processing logic. We use the Databricks notebook functionality to collaborate in real time on model development and logic. We also performs a bit of offline testing within the Databricks platform.

Next we push the data to our MLflow tracking server, which acts as a source of truth for our models. MLflow will store the model hyperparameters, metadata as well as actual model artifacts. Once we have two different models sitting on the tracking server, we use the MLflow deploy commands to push these models into Amazon Sagemaker.

Our environment is stored in a Docker container, and the custom-packaged model pipeline is sent into Amazon Sagemaker’s inference platform. This final step also enables us to run multiple models in parallel, as shown below.

Once we have pushed a model to production with Amazon SageMaker, we can use the A/B testing functionality to iterate through different models and understand which version performs best. We will push two different model variants to a single endpoint and use the UpdateEndpointWeightsAndCapacities functionality to set specific weights to each model variant. Users on Brandless.com will now be assigned model variants in a random occurrence. We record which variant each user receives as well as the actions taken after the recommendation system displays for the customer. Finally, we calculate model performance for each variant.

Discussion

Now that Brandless has been using the Databricks-MLflow-Amazon SageMaker combination, the deployment process has evolved and become more efficient over time.

It originated as a process that required manual checks as we trained the model, pushed to MLflow, and deployed to Amazon SageMaker. We now have a one-click process that automatically checks for errors at each step. We run this process roughly once a week.

Since our initial deployment, we have tested and iterated through approximately 10 different models in production. These versions have different model hyperparameters, utilize increasingly complex post-processing, or combine multiple models in a hierarchy.

We measure online performance by calculating the percentage of Brandless.com visitors that interact with our recommended product carousels. We have seen performance increases on all but one of these model versions, with an estimated 15% improvement overall in comparison to our original model.

The team has also used the Databricks-MLflow-Amazon SageMaker combination to move faster with development for other ML models. These use cases range from customer service improvements to logistics optimization, and all of the models follow the same process.

Challenges and Learnings

We ran into a couple of challenges along the way! Below, we outline a few of these and what we learned:

Links & References

Guest Blog: Using Databricks, MLflow, and Amazon SageMaker at Brandless to Bring Recommendation Systems to Production

This is a guest blog from Adam Barnhard, Head of Data at Brandless, Inc., and Bing Liang, Data Scientist at Brandless, Inc. Launched in July 2017, Brandless makes hundreds of high-quality items, curated for every member of your family and room of your home, and all sold at more accessible price points than similar products on the market.