<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Deepa Mohan on Medium]]></title>
        <description><![CDATA[Stories by Deepa Mohan on Medium]]></description>
        <link>https://medium.com/@mohdeepa?source=rss-42872b3ecd3a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Deepa Mohan on Medium</title>
            <link>https://medium.com/@mohdeepa?source=rss-42872b3ecd3a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:33:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohdeepa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Knowledge distillation of multilingual BERT for Walmart’s conversational AI assistant]]></title>
            <link>https://medium.com/walmartglobaltech/knowledge-distillation-of-multilingual-bert-for-walmarts-conversational-ai-assistant-98ca7c2c3835?source=rss-42872b3ecd3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/98ca7c2c3835</guid>
            <category><![CDATA[named-entity-recognition]]></category>
            <category><![CDATA[voice-commerce]]></category>
            <category><![CDATA[voice-assistant]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Deepa Mohan]]></dc:creator>
            <pubDate>Tue, 25 May 2021 19:41:24 GMT</pubDate>
            <atom:updated>2021-05-25T19:41:24.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oTN36mUvyTgKD8yd1jVzWQ.jpeg" /><figcaption>Walmart’s askSam AI assistant</figcaption></figure><h4>Introduction</h4><p><a href="https://medium.com/walmartglobaltech/tagged/voice-assistant">Walmart’s conversational AI assistant</a> has been enabling voice-based shopping through Google Assistant and Siri platforms for over two years. We extended the AI assistant for our <a href="https://corporate.walmart.com/newsroom/2020/07/29/helping-associates-succeed-at-work-while-elevating-customer-service-safety">store associates</a> as they could tremendously benefit from its Natural Language Understanding (NLU) capabilities and serve our customers better. The store managers have been using the assistant to get the location of products in the store, check stock for different items, query top sales for departments, and even check on fellow associate’s schedules.</p><p>The core component of our askSam AI assistant is the NLU pipeline which is an ensemble of robust, state-of-the-art machine learning models. Intent classification and <a href="https://en.wikipedia.org/wiki/Named-entity_recognition">Named Entity Recognition</a>(NER) are vital NLU tasks that enable understanding of our associates’ intent and extracting relevant entities in their text and speech queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1zittNha_PvBIeRX-9JycQ.gif" /><figcaption>Product Entity tagging in the Walmart askSam app</figcaption></figure><p>The voice assistant has been recently adopted by our store associates internationally as well. We had to extend our assistant’s NLU capabilities to be able to understand and converse with our Spanish speaking associates in the U.S. and Mexico. This lead to the development of a multilingual retail voice assistant that would enable us scale in more countries like Canada and Chile. The following table summarizes some of the Spanish voice queries commonly seen by our assistant and their corresponding NER tags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMNf7_LflIFT02PuH8XdiA.png" /><figcaption>Walmart askSam voice queries and NER tags</figcaption></figure><p>Our conversational assistant is an extremely latency sensitive application. It was very critical for us to investigate deep learning model architectures that were optimized for latency and memory footprint, so we could efficiently scale and serve over a million multilingual queries worldwide efficiently. In this blog, we discuss how we enabled fast NER specifically on Spanish and English queries with focus on multilingual <a href="https://blog.google/products/search/search-language-understanding-bert/">BERT</a> <a href="https://en.wikipedia.org/wiki/Knowledge_distillation">knowledge distillation</a>.</p><p>Most of the open-source <a href="https://arxiv.org/abs/1911.02116">multilingual transformer</a> models are massive, with over 110 million parameters and computationally expensive. Lack of labeled retail data in Spanish language, huge amount of unlabeled data from our Walmart Mexico catalog, diversity of native language accents, cost of deployment infrastructure were a few factors we considered in making architecture choices for our multilingual downstream NER task. Knowledge distillation of multilingual BERT helped us come up with a light weight, super fast production friendly version that retained over 97% of the F1 score compared to the teacher model for most product attribute related entities and showed around 4x inference speedup with 2x compression.</p><h4>Fine-tuning multilingual BERT</h4><p>We initially fine-tuned the pre-trained <a href="https://github.com/google-research/bert/blob/master/multilingual.md">multilingual BERT</a> released by Google research on our Spanish and English conversation data. For Spanish data, we prepared a dataset that consisted of manually curated voice query templates that is reflective of our associates’ usage patterns in the stores. Using Walmart products and brands offered by our Mexico Walmart catalog, paraphrasing techniques and language translation APIs, we were able to generate around one million labeled samples for English and Spanish. This was considered as a baseline experiment for our multilingual NER task. Though this model architecture performed surprising well for unseen Spanish queries in the live logs, we saw that the model latency was still very high compared to the production distilled BERT models that were deployed for our English NLU systems.</p><p>After researching several distillation techniques and cloud offerings, we found that the research published by Microsoft Research, <a href="https://arxiv.org/pdf/2004.05686.pdf">Xtremedistil</a>, showed promising results with respect to performance, model compression and speedup for the multilingual NER task. With close collaboration with the Microsoft Research team, we applied the multi-stage distillation techniques to the massive transformer models to derive student transformer models for our Walmart assistant’s Spanish NLU use case.</p><h4>Transformer Distillation architecture</h4><p>The distillation process detailed in the paper offers flexibility in selecting the following configurations:</p><ol><li>Architecture of the teacher model(mBERT, XLM-RoBERTa, etc.)</li><li>Architecture of the student model(TinyBERT, miniLM, BiLSTM, etc.)</li><li>Tokenizer(BERT WordPiece tokenizer, SentencePiece tokenizer, etc.)</li></ol><p>We experimented with both <a href="https://huggingface.co/bert-base-multilingual-cased">mBERT</a> and <a href="https://huggingface.co/transformers/model_doc/xlmroberta.html">XLM-RoBERTa</a> for the teacher model and <a href="https://arxiv.org/abs/1909.10351">TinyBERT</a> and <a href="https://arxiv.org/abs/2002.10957">miniLM</a> for the student model weighing the performance loss due to distillation and the allowable inference latency gains.</p><p>The training objectives of the teacher, number of layers in the deep network, number of attention heads, data that the teacher models were pre-trained on, amount of context they can keep, the embedding sizes and other hyper-parameters greatly influenced the distillation objectives of the student model.</p><h4>Tokenization</h4><p>We experimented with mBERT as teacher model with <a href="https://www.tensorflow.org/tutorials/tensorflow_text/subwords_tokenizer#applying_wordpiece">WordPiece</a> tokenizer as well as the S<a href="https://arxiv.org/pdf/1808.06226.pdf">entencePiece</a> tokenizer. We also evaluated XLM-RoBERTa with SentencePiece tokenizer. In-house normalization was also performed before the tokenizer for retail specific punctuations, ignoring language specific accents and case.</p><h4>Dataset</h4><p>We performed our distillation experiments on three different in-house labeled Walmart conversational datasets for NER namely, search refinement for shopping, multiple product entity recognition for text shopping, and askSam product search use case. The percentage of labeled english data was more than the labeled Spanish data due to constraints such as annotator availability, inaccuracies of language translation APIs for retail data, and bootstrapping our assistant for Spanish language understanding for the first time. Our entities were broadly classified into entities specific to product attributes such as product, brand, as well as generic entities such as zip code, time reference. We also leveraged the vast amount of unlabeled data from both our extended assortment and the same day delivery items in the Walmart Mexico catalog for the product specific entities.</p><h4>Distillation features</h4><p>The domain specific labeled data helped the teacher model to adapt to the retail domain NER task. The student model was also trained to minimize the c<a href="https://en.wikipedia.org/wiki/Cross_entropy">ross-entropy</a> loss using the labeled data. The unlabeled data was used to enable the student learn from the teacher by optimizing the following constraints.</p><p>1. Minimizing the <a href="https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence">KL</a> divergence between the internal representations of the teacher and the student — Representation loss on unlabeled data.</p><p>2. Minimizing the <a href="https://en.wikipedia.org/wiki/Mean_squared_error">MSE</a> loss by comparing the classification scores of the student with respect to the teacher logits — MSE logit loss on unlabeled data.</p><p>3. Leveraging mBERT embeddings of the teacher, non-linear projection and <a href="https://en.wikipedia.org/wiki/Singular_value_decomposition">SVD</a> on the embeddings to align the output spaces of the teacher and the student.</p><p>The loss functions discussed in the above section were optimized in the distillation process in a stage-wise fashion with gradual unfreezing so that a stage learns the parameters conditioned on those learned in previous stage. This way we leveraged both labeled and unlabeled data to best learn the student model parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*WmA_yIXRKtc49IhQFOQdfw.jpeg" /><figcaption>Distillation architecture</figcaption></figure><h4>Distillation experiment results</h4><p>The following table summarizes the performance and latency measurements on the distilled student model.</p><p><em>Teacher model: bert-base-multilingual-cased with WordPiece tokenizer</em></p><p><em>Datasets: In-house Walmart conversational AI datasets</em></p><p><em>Student models: TinyBERT_L-4_H-312_v2 and Multilingual-MiniLM-L12-H384.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iy6yGzW_fya5f3O8aBHqpQ.png" /><figcaption>Teacher, Student Model Metrics Comparison</figcaption></figure><h4>Student model performance</h4><p>The teacher and the student models were evaluated on a set of unseen queries from our live logs. We saw that for most of our product and generic entities, the performance drop was less than 4% on an average for english queries for the TinyBERT student. For Spanish queries we noticed a performance drop of around 9% for product entities on the TinyBERT student model. With the MiniLM student model we saw only about 2% drop in F1 score for product entities while we were still within the allowable latency margins. We saw more performance drop for generic entities in the Spanish language, this could be attributed towards low representation and support for these entities in the dataset and our live production logs.</p><h4>Student model latency</h4><p>The GPU (Tesla V100) inference latency was around 4ms for the TinyBERT model and around 8ms for the miniLM model. We were further able to improve the latency to less than 1ms by generating an <a href="https://onnx.ai/">ONNX</a> runtime without any drop in performance compared to the distilled student model.</p><h4>Student model footprint</h4><p>In terms of the memory footprint, we were able to reduce the size of the model by 4x using the TinyBERT student compared to the original 12 layer mBERT model and by 2x with the miniLM student.</p><h4>Summary</h4><p>With the multilingual transformer distillation process and the miniLM student model, we were able to bring down the inference latency of the multilingual BERT NER model architecture to less than a few milliseconds, while retaining more than 97% of the F1 score. This also resulted in significant cost benefits in compute and hence deployment infrastructure for our multilingual downstream NER task, enabling us to scale and serve our customers worldwide.</p><h4>Future Work</h4><p>As we expand in more geographies, we want to enable more languages on our assistant. From distillation perspective, we want to bridge the performance drop of our student models by experimenting with the following techniques:</p><ol><li>Experiment with the ratio of task specific labeled vs unlabeled data for native languages.</li><li>Distill from larger multilingual models and better performing teacher models.</li><li>Improved initialization of the student model.</li><li>Investigate SentencePiece tokenizer for specific languages.</li><li>Distill attention heads.</li><li>Custom distillation for joint classification tasks and other deep learning model architectures for NER.</li></ol><h4>References</h4><ul><li><a href="https://arxiv.org/abs/2004.05686">XtremeDistil: Multi-stage Distillation for Massive Multilingual Models</a></li><li><a href="https://arxiv.org/abs/1910.01108">DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter</a></li><li><a href="https://arxiv.org/abs/1503.02531">Distilling the Knowledge in a Neural Network</a></li></ul><h4>Acknowledgements</h4><p>Walmart Global Tech Conversational AI team and <a href="https://medium.com/u/ce33163d1ee">Iman Mirrezaei</a> , <a href="https://medium.com/u/42dcc11aa043">Adrian Sanchez</a>, and <a href="https://medium.com/u/4f942b6a9cd4">Simral Chaudhary</a> for helping with multiple experiments during this effort.</p><p><a href="https://www.microsoft.com/en-us/research/people/submukhe/">Subho Mukherjee</a> and <a href="https://www.linkedin.com/in/yukaishi/">Steven Shi</a> from Microsoft Research team for sharing learnings and best practices for distillation of massive multilingual models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98ca7c2c3835" width="1" height="1" alt=""><hr><p><a href="https://medium.com/walmartglobaltech/knowledge-distillation-of-multilingual-bert-for-walmarts-conversational-ai-assistant-98ca7c2c3835">Knowledge distillation of multilingual BERT for Walmart’s conversational AI assistant</a> was originally published in <a href="https://medium.com/walmartglobaltech">Walmart Global Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Joint Intent Classification and Entity Recognition for Conversational Commerce]]></title>
            <link>https://medium.com/walmartglobaltech/joint-intent-classification-and-entity-recognition-for-conversational-commerce-35bf69195176?source=rss-42872b3ecd3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/35bf69195176</guid>
            <category><![CDATA[voice-assistant]]></category>
            <category><![CDATA[voice-commerce]]></category>
            <category><![CDATA[named-entity-recognition]]></category>
            <category><![CDATA[dialog-system]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Deepa Mohan]]></dc:creator>
            <pubDate>Thu, 12 Dec 2019 00:22:58 GMT</pubDate>
            <atom:updated>2019-12-12T00:22:58.246Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/walmartlabs/building-a-conversational-assistant-platform-for-voice-enabled-shopping-6d174cdc4131">Previously</a>, we introduced our end to end E-commerce conversational AI system which is now live on Google Assistant as well as Apple’s Siri. Our AI system has enabled a complete end to end voice shopping experience for Walmart grocery. Our users can search for Walmart products, add them to cart, edit their cart before checkout, enquire status about the order and much more through voice. A key component of our NLU pipeline is Intent classification and Named Entity Recognition which primarily enables all of the above features and many others. In the following sections, we will dive deep into the intent and entity component of our NLU system. The picture below summarizes the overall conversation flow of our dialog system.</p><figure><img alt="Walmart Grocery Conversation Flow" src="https://cdn-images-1.medium.com/max/1024/1*Xe8qYW2BdcWc1U5PRCgoXw.png" /><figcaption>Walmart Grocery Conversation Flow</figcaption></figure><p><strong>Understanding the user query</strong></p><p>Walmart catalog has millions of products categorized over several departments. Voice queries are more natural and complete compared to the traditional keyword searches on the website. To make sure our system is optimized for voice search, we must understand the user’s intent, and also identify the entities in the query. This is a key aspect of goal-oriented <a href="https://www.slideshare.net/QiHe2/aaai-2019-tutorial-endtoend-goaloriented-question-answering-systems">dialog systems</a> and helps in the retrieval of the right products from the catalog as well as generate the right responses back to the user. Since there can be various attributes associated with a product including brand, type, size, quantity, and unit, we need to carefully identify such associations in the queries. Below is a snapshot of a sample conversation where the user is looking to order chocolate milk.</p><blockquote>Query: I’m looking for a pack of horizon chocolate milk</blockquote><blockquote>Intent: S<em>earch</em></blockquote><blockquote>Entities: <em>pack &lt;</em>unit<em>&gt;, horizon &lt;</em>brand<em>&gt;, chocolate milk &lt;product&gt;</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*6WK8gOuKkQPNCGXn0KJgGA.png" /></figure><p><strong>Intent and Entity Model Architecture</strong></p><p>We use state of the art <a href="https://en.wikipedia.org/wiki/Bidirectional_recurrent_neural_networks">BiLSTM</a> and BiLSTM-<a href="https://en.wikipedia.org/wiki/Conditional_random_field">CRF</a> based deep learning models in production for Intent Classification and Entity Recognition respectively. Recently, there have been various efforts towards generating contextual word embeddings. Such efforts resulted in the embeddings such as Elmo, InferSent and BERT. BERT shines out as it is observed to solve various NLU tasks as seen on the <a href="https:// super.gluebenchmark.com/leaderboard">superGLUE</a> benchmark leaderboard. Considering this, we have recently developed a BERT based joint Intent classification and NER model. With the joint model, we exploit the dependencies in the two tasks. The BERT model takes into account, the entire context of a word, enabling it to understand the queries better.</p><p><strong>Comparison of results with the previous models</strong></p><blockquote>Query: “<em>Search for Head and Shoulders Shampoo</em>”, Intent: <em>Search</em></blockquote><blockquote>Previous model: <em>Head and Shoulders</em> &lt;product&gt;, <em>shampoo</em> &lt;product&gt;</blockquote><blockquote>BERT model: <em>Head and Shoulders</em> &lt;brand&gt;, <em>shampoo</em> &lt;product&gt;</blockquote><p>The previous model was tagging <em>Head and Shoulders </em>as a product while the BERT model correctly tags this as a brand. The BERT model learns these attribute associations of the product without the need for additional features that have to be periodically scaled and maintained.</p><blockquote>Query: “A<em>dd multimeter to cart</em>”, Intent: <em>Add to cart</em></blockquote><blockquote>Previous model: <em>multimeter</em> &lt;brand&gt;</blockquote><blockquote>BERT model: <em>multimeter</em> &lt;product&gt;</blockquote><blockquote><em>The BERT model correctly tags products it has not previously seen in the training data. This helps us tremendously as we scale to support millions of products in the broad spectrum of our catalog.</em></blockquote><blockquote>Query: “B<em>ook a time for pickup tonight</em>”, Intent: <em>Set pickup slot</em></blockquote><blockquote>BERT model: <em>tonight</em> &lt;<em>timereference&gt;</em></blockquote><blockquote>Previous model: <em>tonight</em> &lt;<em>Out of domain</em>&gt;</blockquote><p>Correctly tagging the above query seamlessly helps our users set a pickup slot at a Walmart store at their convenient time.</p><p><strong>Improvements with BERT</strong></p><p>We attribute the improved performance on these queries to the powerful word-piece tokenization and positional embeddings that BERT uses. They help it generalize better for new products and use-cases. We have observed an improvement of about 7% in the F-1 scores of intent classification and entity recognition when compared to the previous models. ‘Add to cart’ intent is very important for an E-commerce NLU system. It shows the user’s real intent to purchase a product. We have observed an improvement of 4% in the F1-score for the intent ‘add to cartʼ with the BERT model.</p><p><strong>Future Work</strong></p><p>The latency of our inference pipeline is key to generating a timely response back to the user, keeping our overall conversation latency smaller and hence our users more engaged. As we have seen higher inference latencies with BERT than our previous models, we are striving to improve the BERT model inference latency using knowledge distillation and other techniques.</p><p>Our models are powering several other voice shopping use-cases such as question-answering for Walmart’s frequently asked questions and product discovery to name a few. Stay tuned for our future blogs and some exciting upcoming features that exploit other features of BERT such as Next Sentence Prediction, segment embeddings, etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35bf69195176" width="1" height="1" alt=""><hr><p><a href="https://medium.com/walmartglobaltech/joint-intent-classification-and-entity-recognition-for-conversational-commerce-35bf69195176">Joint Intent Classification and Entity Recognition for Conversational Commerce</a> was originally published in <a href="https://medium.com/walmartglobaltech">Walmart Global Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>