Single AI View of Customer: A retailers guide to Know Your Customer Better using Customer…

Single AI View of Customer: A retailers guide to Know Your Customer Better using Customer Embeddings and Customer Persona

Introduction

Understanding the customers is at the heart of any business — more so in the world of retail. To cater to diverse customer base poses challenges in maintaining consistent seamless shopping experiences and analyzing customer behavior for targeted marketing and personalization. Most of the solutions primarily emphasize product demand, neglecting customer perspectives and their heterogeneous nature, which hinders accurate recommendation. Capturing customer signals, if any, is limited to usage of demographic data, which is generic, a snapshot frozen in time and cannot be used for personalized solutions. There is always a plethora of customer data available to different retailers, but the challenge remains in making it most useful and concise so that insights do not get lost in lots of details. Also to add to it, there is always very meaningful latent information that is not readily available in data sources but is imperative in making the most influential data driven decisions regarding customers.

Figure 1. Illustration of Customer Jane

One of the ways to tackle the problem is to encode all the customer data in a vector space and derive as much information required from it, build different ML (Machine Learning) models using some framework to infer about customer. The key challenges that typically faced here are the scale and volume, constant refresh to keep up with the latest data, unsupervised nature of the problem which also amplified due to need of decoding new customer behaviors.

Why should you read this?

To solve the problem of knowing your customer better, beyond the raw data features and some analytical insights we want understanding related to their personality, interests, beliefs, taste etc. This latent information will help the retailers cater the customers with more accurate products as per their requirements and utility. This knowledge about the customer is referred to as Customer persona. To put things into perspective, let us look at Figure 1, and think about how this will help better? Take the example of the customer Jane who is buying ‘Almond Milk’ and thinking about utilizing this information. A retailer can think at a very granular level and whenever only ‘Almond Milk’ type of products is concerned they think Jane as a potential customer (without loss of generality think other factors like brand, price etc. are fixed or same for every scenario). On the contrary they can think very broadly about it and whenever it comes to ‘Milk’ they can think of Jane as a potential customer. But what if we bake in the information that Jane is ‘Vegan’ then the retailer would know exactly where to focus e.g., for any plant-based milk like ‘Soy Milk’, ‘Cashew Milk’, ‘Oat Milk’ retailer would consider Jane as potential customer. This is how it will help in understanding the product demand as well as Customer requirement better and retailer would know how much to zoom in to focus exactly on the right depth. One of the challenges is — there can be lots of personas and it can be exceedingly difficult to build independent models for each of them and it is infeasible to go customer wise and fetch all personas one by one.

In this blog post the following will be discussed: Firstly, combining multiple customer data sources together and consolidating them into a single data asset — this is customer embedding. Secondly, how utilizing this embedding as many personas as possible can be created. Thirdly, embeddings are important in general to solve any downstream problem related to customers. Additionally, certain key aspects and technical challenges will be pointed out and discussed along the way. Mainly, the outline of the approach will be explained rather than the in-depth methodology details.

Definitions

Embeddings:

In simple terms, an embedding is a mathematical representation of data in a lower-dimensional space, often designed to capture meaningful relationships between entities or data points. It is a way to consolidate a lot of information and simplify it to a machine friendly format. Customer embeddings are nothing but a numerical representation for each customer that consolidates various sources of customer data.

Persona:

‘Persona’ is defined as the aspect of customers’ characteristics perceived from the transactions done by the customer. These are the much finer traits associated with customers (as referred in Figure 2) — that are more like psychographics and unlike demographics, geographic or behavioral.

Figure 2. Customer Persona

This is the latent information about the customer and cannot be explicitly fetched from the data. L1 is defined as level 1 or higher-level personas e.g., pet owner and L2 as level 2 or granular personas connected to a L1 persona e.g., cat owner, dog owner or farm animal owner. More examples are given in figure 3.

Figure 3. Example of L1 and L2 Personas

Customer Embeddings

The key to unlocking as many customer personas is having a framework which is a Single framework or Service that can fetch any ‘persona’ of the customer without having to build separate models for different persona(s) and that would make it straight-forward to tag customers with new/modified persona(s). To do that we need to have features that are very much automated and independent of individual personas. That is why first we encode the customer level data in a vector space that is very generic and not tuned for any specific downstream task. Now we will talk about at a high level how customer embeddings are created. Typically, in literature you will find Cust2Vec [1] that mimics Doc2Vec [2] to encode customer data but there are limitations of using it, because it cannot take all kind of data sources but simple transactions sequentially loosing additional information. Also, even with this limitation the method is tested, but it fails miserably, mainly because of the enormous number of products with long tail distribution in sales or interaction. So, pre-trained transformer-based models to infer customer embeddings was considered as better alternative to try in scenario.

Figure 4. Customer Embeddings

Data:

All dimensions of customer data are considered for this approach. To summarise it follows customer transactions in store or online, what they have purchased, what brand they prefer what price point they purchase, where are they ordering from etc. Also, what are they searching, browsing, adding to cart, and abandoning it, not able to buy because of out of stock, what kind of membership they have and how much they are using it. All the interactions of customer are necessary to consider.

Methodology:

Customer sentences are created using the following process:

First, a customer-level summary of all customer activity is generated. This summary is presented in a tabular format and then transformed into a natural language format, referred to as a customer sentence.

Step 1: Data from various sources is aggregated and combined into a single source of raw features. This is structured in a nested JSON format, where key features are accessed as JSON keys. The addition of new data sources is facilitated through the incorporation of additional JSON keys. If data is unavailable for a given customer, the corresponding field is left blank. This step is known as the robust data aggregation and augmentation module.

Step 2: An order of relevance is introduced to the customer information within the JSON structure. This order reflects the uniqueness of the information to the customer. For instance, if bananas are purchased by most customers, this purchase would not be considered a unique customer characteristic. A novel method is employed to rank order information within each customer. Frequency-based methods that minimize intra-customer information sharing can be utilized for this ranking.

Step 3: The tabular information in the JSON structure is translated into a natural language structure. This translation is performed using a fine-tuned large language model. This step involves significant computational resources, training data creation, prompt engineering, and scaling challenges, the details of which are beyond the scope of this discussion. In essence, the information is converted into a more natural language format, resulting in what are termed customer sentences. These customer sentences provide comprehensive information about all customer activities.

Figure 5. Example of Embedding Generation using BERT. (512 input tokens, 768 Output dimension)

Generating Embeddings:

Embeddings are generated using transformer-based pre-trained models. BERT-like models can also be utilized. The customer sentence is passed to create a document vector. Numerous state-of-the-art techniques are available for the creation of document embeddings [3]. In this instance, a sentence transformer and an attached sequential auto-encoder were used to learn the latent representation. Several challenges, such as input token limitations, should be considered. Strategies must be devised to prevent information loss. Increased difficulty in inference scaling may be encountered if heavy models are employed. In this case, a customer base at a scale of 100 million necessitated numerous tweaks in tokenizer, parallel processing, and model loading capabilities. A tech stack comprising DASK, GPU, Tensor-RT, and ONNX was utilized to overcome scaling challenges. Incremental embedding generation is utilized, and hard refreshes are performed only during base model updates to maintain pace with the continuous data flow.

Customer Personas:

Decoding some specific personas with transactional data and other customer features is a known problem where the focus was narrowed to one or two types of personas. Otherwise, in some implementation it is observed only unsupervised methods [4] is used followed by profiling which never ensures finding a specific persona. The aim is to build a solution that avoids tunnel vision, making it generic and scalable to solve for any persona of consideration. Additionally, to further drill down and find more specific details related to the persona providing much better personalization e.g., if a customer is identified as a ‘pet owner’ and further if the customer owns a ‘dog’, ‘cat’ or anything else. It enables to create a comprehensive list of personas and, any additional persona attributes can be added without any necessity of manual intervention. A model is built using customer embeddings applied to the ground truth data. Inference is then performed for the complete customer base. The rigour behind this solution is that — customer close to each other in embeddings’ space likely to imitate each other’s behaviours. This solution works because (1) Embeddings and interaction between different dimensions can discover much complex patterns, and (2) Embedding can produce near exhaustive features and do not need manual feature engineering for new persona(s).

Figure 6. Persona Model

Persona Annotation Module:

This is basically ground truth generation for customer to train the model. Importantly, this module needs to be fully automated and parametrised in order to enable scaling across various persona identification tasks. A sample of customer is taken and passed through our novel annotation module which is a combination of heuristic metric and Gen-AI based framework to create ground truth data for the model to train. Although the latest trending LLM models are doing exceptionally good, to put guardrails on the hallucination we use heuristic metrics as well. Also, strictly positives labels are fetched as soft-labels and border line values are not considered as positive labels — the idea is to give ‘good examples’ for model to learn post which, during inference, model will be able to find the weak signals as well.

L1 and L2-Persona Model:

Level 1 persona is higher level classification e.g., sports fan, having food preference, pet owners etc. This is devised as binary classification model. Gradient boosting algorithm and deep learning based models are applied on the data in this scenario. Level 2 persona is sub-personas of L1, if someone loves sports so what kind of sports they like — football, cricket, golf etc. So, for L2 persona, it is devised as a multi-label classification problem and neural network model was built for it. It was observed to have a steady ROC-AUC value over 85% for more than 40 cases of personas we have developed. It has increased the previously benchmark of recall by 0.6–1.5x times — that means so customer personality traits are being captured in much better way. To build the models around100k to 1Mn samples were taken for cat-boost, for LightGBM smaller sample size works but for Deep Learning and XgBoost like models more samples work better. For inference pyspark and GPU was required.

Embeddings for downstream AI/ML problem solving:

Beyond customer personas, embeddings have much wider application. It can be utilised to understand customer behaviour, preferences, and potential future actions, enabling better decision-making and customer engagement. To summarise the following key aspects, it can be utilised for:

Unlocking Hidden Relationships:

Going beyond demographics: Traditional customer segmentation relies on basic demographics like age and location. Embeddings, however, capture nuanced relationships in customer behaviour, preferences, and interactions with products/services.

Revealing hidden connections: By analysing the proximity of customer embeddings, businesses can identify unexpected customer segments with similar interests, purchasing patterns, or responses to marketing campaigns.

Figure 7. Use-cases of Customer Embeddings

Understanding Customer Behaviour and Preferences:

Personalization at Scale: Customer embeddings enable you to understand individual customer preferences and behaviour patterns. This allows you to personalize recommendations, marketing messages, and product offerings, leading to higher engagement and conversion rates.

Segmentation: You can group customers with similar characteristics based on their embeddings, enabling targeted marketing campaigns and product development efforts.

Improving Customer Insights:

Customer Journey Mapping: Embeddings can help visualize customer journeys, revealing crucial touchpoints and identifying areas for improvement.

Predictive Analytics: By analysing customer embeddings, you can predict customer churn, future purchases, and other relevant behaviours, enabling proactive strategies.

Enhancing Customer Experience:

Personalized Recommendations: Tailored recommendations based on embeddings increase customer satisfaction and drive sales.

Proactive Incident Identification: By anticipating customer needs, you can provide timely and relevant support, minimizing frustration and improving loyalty.

Model Efficiency and Scalability:

Dimensionality reduction: Embeddings condense complex customer data into lower-dimensional vectors, making it easier to analyse and process large datasets.

Improved model performance: Using embeddings as input features can significantly enhance the accuracy and efficiency of machine learning models used for tasks like customer segmentation, churn prediction, and recommendation engines.

Optimizing Marketing Strategies:

Targeted Advertising: Customer embeddings allow you to target ads more effectively, maximizing ROI and reaching the right audience.

Content Personalization: Tailoring content based on individual preferences leads to higher engagement and brand loyalty.

Some interesting results:

Embeddings unlocking potential (future) behaviour:

It was observed through inference, there are some customer personas that is being captured which is not explicitly observed within the timeframe of the model development but in the immediate future. To understand and prove this behaviour more carefully, an experiment was devised which was out of time experiment for pet-owners and the model is able to capture 23.64% of ‘future’ pet-owners.

Figure 8. 2-dim TSNE plot of experimental customer base

Embeddings capturing evolving customer behaviour:

In image 6, there is a set of customers we observed in Q3 FY 22–23 who are not purchasing certain items, but a group started purchasing them in next quarter. Embeddings shows the similarity and changing behaviour for them even in lower dimensional representation it was able to capture such patterns.

Customer Persona in Action:

Suppose marketers want to run a campaign for some snacks which have healthy traits. To find the relevant customer base they can generate persona “Healthy Snacks Lover” and then they can generate personalised campaigns like following:

This can be made more influential by adding the active trends as well. For example, think about the Men’s T20 World Cup that concluded recently — if the campaign managers also want to attract them, then they will on top of “Healthy Snacks Lover” create ”Sports Enthusiast” or ”Cricket Fan” persona and can target them like following example:

Conclusions:

This is a novel solution that scales to find any personas related to customer from solely their interaction with the retailer. It is proven to work well for rare personas as well (5% event rate) and sentence transformers as a technique for embedding generations has proven to be much useful, accurate, and time & cost effective in comparison to Doc2Vec. The solution works well across the L1 and L2 personas, even for semi-cold start problems as in customers coming in new and have very less interaction with the retailer.

Acknowledgements:

This blog is the result of diligent works of a lot of individuals namely — Kethan Santhosh, Kaushik Sivashankar, Ishant Sahu, Srikant Sahoo, and it was only possible through the constant leadership and guidance of Abin Abraham and Satya Narayan. We also are indebted to Lahir Marni and Richard Ulrich for enabling scaling using GPUs.

References:

[1] Katsov, I. (n.d.). Grid Dynamics. Retrieved from https://blog.griddynamics.com/customer2vec- representation-learning-and-automl-for-customer- analytics-and-personalization/

[2] Le, Q., & Mikolov, T. (2014). Distributed Representations of Sentences and Documents. CoRR, 0–14.

[3] https://towardsdatascience.com/document-embedding-techniques-fed3e7a6a25d

[4] Mendez, M. (n.d.). Datagran. Retrieved from https://blog.datagran.io/posts/find-your-buyer-persona- with-machine-learning

Single AI View of Customer: A retailers guide to Know Your Customer Better using Customer… was originally published in Walmart Global Tech Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.

Introduction to Malware Binary Triage (IMBT) Course

Looking to level up your skills? Get 10% off using coupon code: MWNEWS10 for any flavor.

Enroll Now and Save 10%: Coupon Code MWNEWS10

Note: Affiliate link – your enrollment helps support this platform at no extra cost to you.

Article Link: Single AI View of Customer: A retailers guide to Know Your Customer Better using Customer Embeddings and Customer Persona | by Amlan Jyoti Das | Walmart Global Tech Blog | Mar, 2025 | Medium