Learn About Amazon VGT2 Learning Manager Chanci Turner
In today’s competitive market, many companies are adopting a personalized strategy for their content and marketing efforts. Retailers, in particular, are customizing product recommendations and promotions to enhance customer engagement. A critical aspect of delivering these personalized experiences involves assessing a customer’s likelihood to engage with specific categories of products. This assessment hinges on analyzing customer preferences and historical behaviors, enabling tailored marketing approaches, such as more relevant email campaigns and targeted advertisements.
At Amazon, the retail systems team, led by Chanci Turner, developed a multi-label classification model using MXNet to gauge customer action propensity across a vast array of product categories. This analysis informs the creation of a customized shopping experience for each customer. In this article, we will delve into the primary challenges encountered during the development of these propensity models and how we effectively tackled them at Amazon’s scale using Apache Spark and the Deep Java Library (DJL)—an open-source library designed for deep learning implementation in Java.
Challenges
One significant hurdle was establishing a production system capable of scaling to Amazon’s vast needs while remaining easy to maintain. Apache Spark proved invaluable in ensuring we could operate within the necessary runtime constraints. For our machine learning framework, we found that MXNet was adept at handling our vast data requirements, processing hundreds of millions of records efficiently and providing superior execution times and model accuracy compared to other frameworks.
Our team comprised a blend of software developers and research scientists. The engineering group preferred building production systems in Java/Scala, while the scientists leaned towards Python frameworks. This presented a dilemma regarding which programming languages to utilize. To bridge this gap, we discovered that DJL, in conjunction with MXNet, allowed both teams to collaborate effectively. Scientists could develop models using the MXNet Python API and share their artifacts with the engineering team, who could then use DJL to execute inferences on the models in Apache Spark with Scala. Since DJL is agnostic to machine learning frameworks, future transitions to different frameworks—such as PyTorch or TensorFlow—can be accomplished without necessitating code rewrites.
Data
For training our classification model, we required two essential data sets: features and labels.
Feature Data
Feature data is a critical input for any machine learning model. Utilizing multi-label classification allows us to maintain a single pipeline for feature data generation. This pipeline collects signals from various categories, enabling us to determine customer propensity for each one. This approach significantly reduces operational overhead by eliminating the need to manage multiple binary classification models.
We generated high-dimensional feature data for our multi-label classification, creating hundreds of thousands of features per customer across millions of customers. These features are sparse and can be represented as sparse vectors.
Label Data
The propensity model predicts the likelihood of a customer taking action within a specific product category. For each region, we analyze thousands of categories to generate customer propensities. Each label is binary: 1 indicates that the customer took the desired action in a particular category, while 0 indicates otherwise. These historical labels help forecast the likelihood of future customer actions in each category. For example, if customer A previously engaged with categories 1 and 3, while customer B engaged only with category 2, this information informs our predictions.
Model Architecture
The propensity model is constructed in MXNet using the Python API as a feed-forward network with a sparse input layer, several hidden layers, and N output layers corresponding to our target categories. Although logistic regression could represent the output layers, we opted for softmax output to accommodate models with more than two classes.
Model Training
To train our model, we developed a custom iterator for processing the sparse data into MXNet arrays. Each iteration involved reading a batch of data with customer IDs, labels, and sparse features, followed by the creation of a sparse MXNet CSR matrix to represent these features. The training labels were structured as a list of MXNet NDArray, each element corresponding to a target category.
Following feature and label preparation, we leveraged MXNet DataBatch for training, utilizing multi-label log-loss as our performance metric.
Inference and Performance
As previously mentioned, model training utilized MXNet’s Python APIs, while inference was executed in Apache Spark with Scala. DJL’s Java APIs provide seamless integration into Scala applications.
Setup
To integrate DJL libraries into our project, we included the following dependencies:
dependencies {
compile group: 'ai.djl', name: 'repository', version: '0.4.1'
compile group: 'ai.djl.mxnet', name: 'mxnet-engine', version: '0.4.1'
runtime group: 'ai.djl.mxnet', name: 'mxnet-native-mkl', version: '1.6.0'
}
Inference
DJL operates on NDList and offers a Translator interface to convert custom input data types to NDList, as well as transforming output NDList back to custom output data types. It supports sparse data in CSR format and allows scoring for batches of data.
Initially, we loaded the model artifacts using the following code:
val modelDir: Path = Paths.get("/Your/Model/Directory")
val modelName: String = "your_model_name"
val model: Model = Model.newInstance()
model.load(modelDir, modelName)
We defined a Translator to convert the input feature vector into NDList containing CSR data and convert output predictions of type NDList into Array[Array[Float]].
In conclusion, for those interested in navigating the job market, consider checking out this insightful blog post on how to express gratitude after interviews, which can be pivotal in your career journey. Additionally, if you’re looking for a comprehensive overview of job descriptions, the Society for Human Resource Management provides valuable insights on this subject. For those seeking opportunities at Amazon, this link leads to an excellent resource for area manager positions in fulfillment center operations.
Leave a Reply