<?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 Siddharth Sharma on Medium]]></title>
        <description><![CDATA[Stories by Siddharth Sharma on Medium]]></description>
        <link>https://medium.com/@siddharth-1729-65206?source=rss-38f9b73a928c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_gevkYrX0Zl3ElN-.</url>
            <title>Stories by Siddharth Sharma on Medium</title>
            <link>https://medium.com/@siddharth-1729-65206?source=rss-38f9b73a928c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:35:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@siddharth-1729-65206/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[AWS Blog In Collaboration With Nvidia — Optimizing Inference For Seq2Seq And Encoder Only Models…]]></title>
            <link>https://siddharth-1729-65206.medium.com/aws-blog-in-collaboration-with-nvidia-optimizing-inference-for-seq2seq-and-encoder-only-models-ef0567a6b900?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef0567a6b900</guid>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[low-latency]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[model-inference]]></category>
            <category><![CDATA[bart]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Wed, 22 Nov 2023 21:43:51 GMT</pubDate>
            <atom:updated>2023-11-22T21:43:51.987Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://smashinggradient.com/2023/11/22/aws-blog-in-collaboration-with-nvidia-optimizing-inference-for-seq2seq-and-encoder-only-models-using-nvidia-gpu-and-triton-model-server/">AWS Blog In Collaboration With Nvidia — Optimizing Inference For Seq2Seq And Encoder Only Models Using Nvidia GPU And Triton Model Server</a></h3><p>Posted on <a href="https://smashinggradient.com/2023/11/22/aws-blog-in-collaboration-with-nvidia-optimizing-inference-for-seq2seq-and-encoder-only-models-using-nvidia-gpu-and-triton-model-server/">November 22, 2023</a> by <a href="https://smashinggradient.com/author/siddharthsharma1/">Siddharth Sharma</a></p><p><strong>Blurb</strong>:</p><p>Deep Learning Transformer models are complex in architecture and can have hundreds of millions (or even billions) of parameters, which leads to slow real time inference. Real time low latency inference of Deep Learning models is a critical requirement to enable their usage in production setting.</p><p>Our AWS blog shares the technical details of how we achieved this milestone by using Nvidia A10G GPUs, <a href="https://github.com/triton-inference-server/server">Triton Model Server</a> and <a href="https://developer.nvidia.com/tensorrt#:~:text=NVIDIA%20TensorRT%2DLLM%20is%20an,knowledge%20of%20C%2B%2B%20or%20CUDA.">TensorRT Model Format.</a> The blog also highlights the cost and latency savings made using the developed infrastructure compared to native Sagemaker CPU based hosting. We have used the developed infra for hosting BART Encoder-Decoder Model (for Spelling Correction) and Sentence Transformer Encoder Only model (for Vector Search).</p><p><strong>Blog Link</strong>:</p><p><a href="https://aws.amazon.com/blogs/machine-learning/how-amazon-music-uses-sagemaker-with-nvidia-to-optimize-ml-training-and-inference-performance-and-cost/">How Amazon Music uses SageMaker with NVIDIA to optimize ML training and inference performance and cost</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef0567a6b900" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compressing LLMs With Low Rank Decomposition Of Attention Matrices]]></title>
            <link>https://siddharth-1729-65206.medium.com/compressing-llms-with-low-rank-decomposition-of-attention-matrices-ed13e9e8563a?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed13e9e8563a</guid>
            <category><![CDATA[svd]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[flan-t5]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[compression]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Wed, 22 Nov 2023 21:40:36 GMT</pubDate>
            <atom:updated>2023-11-22T21:40:36.065Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Colab Link To Reproduce Experiment:</strong> <a href="https://colab.research.google.com/drive/1aaveVFlSYwmdjqllHn94PnAo8JBY7-ap">LLM Compression Via Low Rank Decomposition.ipynb</a></p><p><strong>Models Used</strong>: Flan-5-Base, Lan-T5-</p><h3>Context</h3><p>A neural network contains many dense layers which perform matrix multiplication. In the case of Transformers, Attention module has Key, Query, Value and Output matrices (along with the FF layer) that are have typically full rank. Li. et al. [3] and Aghajanyan et al.[4] shows that the learned over-parametrized models in fact reside in low intrinsic dimension. In popular Parameter Efficient Fine Tuning(PEFT) technique LoRA, the authors took inspiration from [3] and [4] to hypothesize that the change in weights during model adaptation also has a low intrinsic rank.</p><p>In real production models, the model capacity is often constrained by limited serving resources and strict latency requirements. It is often the case that we have to seek methods to reduce cost while<br>maintaining the accuracy. To tame inference time latency, low rank decomposition of weight matrices have earlier been used in applications like DCN V2[5].</p><h3>Low Rank Decomposition</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dx1tve1xIQLBbZLXEACniw.png" /></figure><p>In the above image a m x n weight W is decomposed into m x k matrix A and k x n matrix B. In linear algebra, the <strong>rank</strong>[6] of a matrix W is the dimension of the vector space generated by its columns. This corresponds to the maximal number of <a href="https://en.wikipedia.org/wiki/Linearly_independent">linearly independent</a> columns of W. Over parametrized weight matrices can contain linearly dependent columns, hence they can be decomposed into product of smaller matrices.</p><p>One of the most popular method to perform low rank decomposition is <strong>Singular Value Decomposition</strong>[7].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xdIYn1wzwZiuKeFt64bsfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mdo40LXO_GQC6nZVpJzaKw.png" /></figure><p>In this post I further explore effects of taking low rank decomposition of attention weight matrices (Query, Key, Value and Output) on T5-base performance.</p><h3>Spectrum Decay</h3><p>This section plots the Singular values of Query matrix of last decoder layer of flan-base (~220 million params) and flan-large (~700 million params) models.</p><pre>Flan Base Weight Matrix (768 x 768)  = decoder.block[11].layer[0].SelfAttention.q.weight</pre><pre>Flan Large Weight Matrix (1024 x 1024) = decoder.block[23].layer[0].SelfAttention.q.weight</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*LX6-TsauYsKJ2NjI.png" /></figure><p>The above plot shows the singular value decay pattern of the learned weight matrices from flan-t5-base and flan-t5-large. The above plot shows a much faster spectrum decay pattern than a linear decline, reinforcing our hypothesis that Large Language Models have intrinsic low rank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*kA0SGvdVKqHPARUO.png" /><figcaption>Decay in Frobenius Norm of difference between original weight matrix and approximate matrix create from low rank decomposition</figcaption></figure><p>The above plot shows Frobenius norm of difference between attention Query weight matrix of decoder’s last layer and it’s approximation from low rank decomposition (r varies from 32 to 768 for flan-t5-base and 32 to 1024 for flan-t5-large)</p><h3>Low Rank Layers</h3><p>The Low Rank Layer creates SVD of weight matrix of attention matrices of original model. Then we use a configurable parameter “r” to decide the rank of matrix to use.</p><p>Config to choose rank and targeted params</p><pre>@dataclass<br>class LowRankConfig:<br>    rank:int<br>    target_modules: list[str]</pre><pre>#low rank decomposition of SelfAttention Key, Query and Value Matrices<br>config = LowRankConfig(<br>    rank= 384,<br>    target_modules=[&quot;k&quot;, &quot;q&quot;, &quot;v&quot;, &quot;o&quot;]<br>)</pre><p>Code pointer creating <strong>low rank layers</strong></p><p>The module below accepts a full rank layer (we experimented with Linear Layers) and rank parameter “r”. It performs SVD of the weight matrix and then save the low rank matrices U, S and Vh.</p><p>This module can be further optimized by precomputing product of U and S or S and Vh.</p><pre>class LowRankLayer(nn.Module): &quot;&quot;&quot;given a linear layer find low rank decomposition&quot;&quot;&quot; <br>  <br>  def __init__(self, rank, full_rank_layer): <br>    super().__init__() <br>    self.rank = rank<br>    U, S, Vh = torch.linalg.svd(full_rank_layer.weight)<br>    S_diag = torch.diag(S)<br>    self.U = U[:, :self.rank]<br>    self.S = S_diag[:self.rank, :self.rank]<br>    self.Vh = Vh[:self.rank, :]<br>  <br>  def forward(self, x):<br>    aprox_weight_matrix = self.U @ self.S @ self.Vh<br>    output = F.linear(x, aprox_weight_matrix)<br>    return output</pre><p>After this step we replaces the targeted layers with the new Low Rank Layers.</p><h3>Effect On Model Size</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-rI2UMNLdCz4SBe-QYyOg.png" /></figure><h3>Projecting Random Vectors</h3><p>An intuitive way to see the effect of low rank approximation technique is to project a random vector (input) on the original matrix and the one created from low rank approximation</p><pre>#low rank approximation of model_t5_base.encoder.block[0].layer[0].SelfAttention.q<br># 768 to 384 dim reduction <br>query_attention_layer = model_t5_base.encoder.block[0].layer[0].SelfAttention.q<br>low_rank_query_attention_layer = LowRankLayer(384, model_t5_base.encoder.block[0].layer[0].SelfAttention.q)</pre><p>Now we would find projection of the random 768 length tensor on query_attention_layer and low_rank_query_attention_layer</p><pre>random_vector = torch.rand(768)<br>original_projection = query_attention_layer(random_vector)<br>low_rank_projection = low_rank_query_attention_layer(random_vector)</pre><p><strong><em>Now we would find Cosine Similarity between the two vectors</em></strong></p><pre>cosine_sim = torch.nn.CosineSimilarity(dim=0)<br>cosine_sim(low_rank_projection, original_projection)<br>Output: tensor(0.9663, grad_fn=&lt;SumBackward1&gt;)</pre><p>This show that the effect of original Query matrix and its low rank approximation on a random input is almost same.</p><h3>Evaluation</h3><p>In this section we compare performance of low rank approximation on performance w.r.t Summarization Task (<a href="https://huggingface.co/datasets/samsum"><strong>Samsum data set</strong></a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ZXMrzwttw8U_pJVlryQig.png" /></figure><p>As we can see from the above table, there is almost no drop in performance of the compressed model on summarization task.</p><h3>References</h3><ol><li>LoRA: Low-Rank Adaptation of Large Language Models</li><li><a href="https://arxiv.org/pdf/2004.09031.pdf">Learning Low-rank Deep Neural Networks via Singular Vector Orthogonality Regularization and Singular Value Sparsification</a></li><li><a href="https://arxiv.org/pdf/1804.08838.pdf">Measuring the Intrinsic Dimension of Objective Landscapes</a></li><li><a href="https://arxiv.org/abs/2012.13255">Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning</a></li><li><a href="https://arxiv.org/abs/2008.13535">DCN V2: Improved Deep &amp; Cross Network and Practical Lessons for Web-scale Learning to Rank Systems</a></li><li><a href="https://en.wikipedia.org/wiki/Rank_(linear_algebra)">https://en.wikipedia.org/wiki/Rank_(linear_algebra)</a></li><li><a href="https://en.wikipedia.org/wiki/Singular_value_decomposition">https://en.wikipedia.org/wiki/Singular_value_decomposition</a></li><li><a href="https://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm">https://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed13e9e8563a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summary Of Adapter Based Performance Efficient Fine Tuning (PEFT) Techniques For Large Language…]]></title>
            <link>https://siddharth-1729-65206.medium.com/summary-of-adapter-based-performance-efficient-fine-tuning-peft-techniques-for-large-language-fa65d0c2d55f?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa65d0c2d55f</guid>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Fri, 21 Apr 2023 22:24:37 GMT</pubDate>
            <atom:updated>2023-04-21T22:25:38.362Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://smashinggradient.com/2023/04/11/summary-of-adapter-based-performance-efficient-fine-tuning-peft-techniques-for-large-language-models/">Summary Of Adapter Based Performance Efficient Fine Tuning (PEFT) Techniques For Large Language Models</a></h3><p>The two most common transfer learning techniques in NLP were feature-based transfer (generating input text embedding from a pre-trained large model and using it as a feature in your custom model) and fine-tuning (fine tuning the pre-trained model on custom data set). It is notoriously hard to fine tune Large Language Models (LLMs) for a specific task on custom domain specific dataset. Given their enormous size (e.g. GPT3 175B parameters ,<a href="https://huggingface.co/google/flan-t5-xxl"> Google T5 Flan XXL </a>[1] 11B parameters, Meta <a href="https://ai.facebook.com/blog/large-language-model-llama-meta-ai/#:~:text=Introducing%20LLaMA%3A%20A%20foundational%2C%2065%2Dbillion%2Dparameter%20language%20model">Llama[2] </a>65 billion parameters) ones needs mammoth computing horsepower and extremely large scale datasets to fine tune them on a specific task. Apart from the mentioned challenges, fine tuning LLMs on specific task may lead them to “forget” previously learnt information, a phenomena known as <a href="https://en.wikipedia.org/wiki/Catastrophic_interference#:~:text=Catastrophic%20interference%2C%20also%20known%20as,information%20upon%20learning%20new%20information."><strong>catastrophic forgetting</strong></a>.</p><p>In this blog I will provide high level overview of different Adapter[4] based parameter efficient fine tuning techniques used to <a href="https://github.com/huggingface/peft">fine tune LLMs.</a> PEFT based methods make fine-tuning large language models feasible on consumer grade hardware using reasonably small datasets, e.g. <a href="https://crfm.stanford.edu/2023/03/13/alpaca.html">Alpaca</a>[3] used 52 k data points to fine tune Llama 7B parameter model on multiple tasks in ~3 hours using a Nvidia A100 GPU[5].</p><p><strong>HuggingFace </strong><a href="https://github.com/huggingface/peft"><strong>PEFT</strong></a> module has 4 types of performance efficient fine-tuning methods available under <em>peft.PEFT_TYPE_TO_CONFIG_MAPPING</em></p><pre>{<br>&#39;PROMPT_TUNING&#39;: peft.tuners.prompt_tuning.PromptTuningConfig,<br> &#39;PREFIX_TUNING&#39;: peft.tuners.prefix_tuning.PrefixTuningConfig,<br> &#39;P_TUNING&#39;: peft.tuners.p_tuning.PromptEncoderConfig,<br> &#39;LORA&#39;: peft.tuners.lora.LoraConfig<br>}</pre><p>In this post I would go over theory of PROMPT_TUNING, PREFIX_TUNING and Adapter based techniques including LORA.</p><p>Before we dive into nitty-gritty of Adapter based techniques, let’s do a quick walkthrough of some other popular Additive fine tuning methods. “The main idea behind additive methods is augmenting the existing pre-trained model with extra parameters or layers and training only the newly added parameters.”[6]</p><h3>1. Prompt Tuning</h3><p>Prompt tuning[7] prepends the model input embeddings with a trainable tensor (known as “soft prompt”) that would learn the task specific details. The prompt tensor is optimized through gradient descent. In this approach rest of the model architecture remains unchanged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*HUuDcPlHcwuwDkqJCFG5Kw.png" /></figure><h3>2. Prefix-Tuning</h3><p>Prefix Tuning is a similar approach to Prompt Tuning. Instead of adding the prompt tensor to only the input layer, prefix tuning adds trainable parameters are prepended to the hidden states of all layers.</p><p>Li and Liang[8] observed that <strong><em>directly optimizing the soft prompt leads to instabilities during training</em></strong>. Soft prompts are parametrized through a feed-forward network and added to all the hidden states of all layers. <strong><em>Pre-trained transformer’s parameters are frozen</em></strong> and only the prefix’s parameters are optimized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*ujMoXUV7Z93j-DjJ1QRA1A.png" /><figcaption>[8] <a href="https://arxiv.org/pdf/2101.00190.pdf">Prefix-Tuning: Optimizing Continuous Prompts for Generation</a></figcaption></figure><h3>3. Overview Of Adapter Based Methodology</h3><p><strong>What are Adapters ?</strong></p><p>As an alternative to Prompt[7] and Prefix[8] fine tuning techniques, in 2019 Houlsby et.al.[9] proposed transfer learning with Adapter modules. “Adapter modules yield a compact and extensible model; they add only a few trainable parameters per task, and new tasks can be added without revisiting previous ones. The parameters of the original network remain fixed, yielding a high degree of parameter sharing.”[9]. Adapters are new modules added between layers of a pre-trained network. In Adapter based learning <strong><em>only the new parameters are trained while the original LLM is frozen</em></strong>, hence we learn a very small proportion of parameters of the original LLM. This means that <strong><em>the model has perfect memory of previous tasks</em></strong> and used a small number of new parameters to learn the new task.</p><p>In [9], Houlsby et.al. highlights benefits of Adapter based techniques.</p><ol><li>Attains high performance</li><li>Permits training on tasks sequentially, that is, it does not require simultaneous access to all datasets</li><li>Adds only a small number of additional parameters per task.</li><li>Model retains memory of previous tasks (learned during pre-training).</li></ol><p>Tuning with adapter modules involves adding a small number of new parameters to a model, which<br>are trained on the downstream task. Adapter modules perform more general architectural modifications to re-purpose a pre-trained network for a downstream task. The adapter tuning strategy involves injecting new layers into the original network. <strong><em>The weights of the original network are untouched</em></strong>, whilst the new adapter layers are initialized at random.</p><p>Adapter modules have <strong>two main features</strong>:</p><ol><li>A small number of parameters</li><li><strong>Near-identity initialization.</strong></li></ol><ul><li>A near-identity initialization is required for stable training of the adapted model</li><li>By <strong><em>initializing the adapters to a near-identity function, original network is unaffected when training starts</em></strong>. During training, the adapters may then be activated to change the distribution of activations throughout the network.</li></ul><p><strong>Adapter Modules Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/0*3StSKeke1jeuh_07" /><figcaption><em>[9] Two Adapter Modules Inserted In a Transformer Layer</em> (“<em>During adapter tuning, the green layers are trained on the downstream data</em>“)</figcaption></figure><p>Two serial adapters modules are inserted after each of the transformer sub-layers (Attention and Feed Forward Layers). The adapter is always applied directly to the output of the sub-layer, after the projection back to the input size, but before adding the skip connection back. The output of the adapter is then passed directly into the following layer normalization.</p><p><strong>How Adapters Minimize Adding New Parameters?</strong></p><p><strong>Down Project And Up Project Matrices</strong></p><p>Adapter modules creates a <strong><em>bottleneck architecture</em></strong> where the adapters first project (<strong><em>feed forward down-project weight matrix</em></strong> in the above image) the original d-dimensional features into a smaller dimension, m, apply a nonlinearity, then project back (<strong>feed-forward up-project</strong> <strong><em>weight matrix</em></strong>) to d dimensions. The total number of parameters added per layer, including biases, is 2m*d + d + m. By setting m &lt;&lt; d, the number of parameters added per task are limited (less than 1%).</p><p>Given an input x, the Adapter modules output at layer l would be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*jV5VoU5uV3-gqLTI" /></figure><p>Where</p><ul><li>x is a d dimensional input</li><li>LNl is layer normalization for the lth Adapter layer</li><li>Ul is feed-forward up-project m * d <em>weight matrix</em></li><li>Dl is <em>feed forward down-project d * m weight matrix</em></li><li>GeLU : activation funciton</li><li>+ : residual connection</li></ul><p>The bottleneck dimension, m, provides a simple means to trade-off performance with parameter efficiency. The adapter module itself has a skip-connection internally. With the skip-connection, if the parameters of the projection layers are initialized to near-zero, the module is initialized to an<br>approximate identity function. Alongside the layers in the adapter module, we also train new layer normalization parameters per task.</p><p><strong>Pruning Adapters from lower layers</strong></p><p>In [9] authors suggest that Adapters on the lower layers have a smaller impact than the higher-layers. Removing the adapters from the layers 0 − 4 on MNLI barely affects performance. Focusing on the upper layers is a popular strategy in fine-tuning. One intuition is that the lower layers extract lower-level features that are shared among tasks, while the higher layers build features that are unique to different tasks.</p><p><strong>To read the complete blog (that includes LLaMA Adapters and LORA: LOW-RANK ADAPTATION OF LARGE LANGUAGE MODELS) please visit</strong></p><p><a href="https://smashinggradient.com/2023/04/11/summary-of-adapter-based-performance-efficient-fine-tuning-peft-techniques-for-large-language-models/">https://smashinggradient.com/2023/04/11/summary-of-adapter-based-performance-efficient-fine-tuning-peft-techniques-for-large-language-models/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa65d0c2d55f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Ranking Architectures]]></title>
            <link>https://siddharth-1729-65206.medium.com/neural-ranking-architectures-22bfba530c55?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/22bfba530c55</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[ad-rank]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[product-ranking]]></category>
            <category><![CDATA[neuralarchitecturesearch]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Thu, 19 Jan 2023 09:43:06 GMT</pubDate>
            <atom:updated>2024-06-30T01:18:52.334Z</atom:updated>
            <content:encoded><![CDATA[<p>Glimpses On Implicit/Explicit, Dense/Sparse, Gated/Non Gated, Low Rank And Many More Layered Interactions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gl1FgoxQ9SIzWX9g2PNgxw.png" /><figcaption>101 Ranking Model Architecture</figcaption></figure><p>Neural ranking models are the most important component in <a href="https://smashinggradient.com/2021/09/16/talk-on-multi-stage-ranking/">multi stage retrieval and ranking</a> pipeline. Whether it is e-commerce search, ads targeting, music search or browse feed ranking, ranking model will have the final say in selecting the most relevant entity for a given request. Improvement in ranking model’s architecture (as well as feature space) can have a direct impact on boosting the business KPI.</p><p>In this post I would discuss brief history of development around ranking model architectures. I woulds show how the core model architecture evolved with each major break-though in neural architecture development.</p><h3>Part 1 — Genesis</h3><p>In this section I would quickly go over some early model architectures and would discuss some key issues involved with them.</p><p><strong>A. Issues With Wide Only Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*fmT90K5Y_g7DCQngP0SirA.png" /></figure><p>Wide only model (no representation learning) learns weights for individual features and their corresponding interactions. Key issue with this approach is that</p><ul><li>There is no generalization.</li><li>We can’t learn interactions in absence/sparsity of training data</li><li>Shallow Architecture — Single layer model, no feature transformation</li></ul><p>B. <a href="https://www.csie.ntu.edu.tw/~b97053/paper/Rendle2010FM.pdf"><strong>Factorization Machine, Steffen Rendle, 2010</strong></a></p><p>Given a real valued feature vector x ∈ Rn where n denotes the number of features, FM estimates the target by modeling all interactions between each pair of features</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*-OlbR9V9td9t3kdmnSoBHw.png" /></figure><ul><li><em>w0 is the global bias</em></li><li><em>wi denotes the weight of the i-th feature</em></li><li><em>wij denotes the weight of the cross feature xi * xj</em></li><li><em>(factorization) -&gt; wij = vTi vj , where vi ∈ Rk denotes the embedding vector</em></li></ul><p>In this architecture we project sparse features onto low dimensional dense vectors and learn feature interactions. Along with learning weights over individual sparse features (id based features, gender, categories etc), we learn their interactions via pair wise dot product of their representations.</p><p><strong>Advantages of Factorization Machines</strong></p><ul><li>Can generalize better</li><li>Can handle sparsity w.r.t training data e.g. even if we have never seen interaction between Age 12 and Ad Category Gaming in training data, at inference time we can learn their interaction value by using corresponding embedding’s dot product</li></ul><p><strong>Disadvantages of Factorization Machines</strong></p><ul><li>Shallow Structure — Limited Capacity Model (low representation power)</li><li>Lacks feature transform capability</li><li>Lacks ability to use embeddings based features (we can’t use pretrained embeddings for a feature)</li></ul><p><strong>C. Wide &amp; Deep — Poor Man’s Ranking Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*6zDMNX54AR8h5etO5lVZdA.png" /><figcaption><a href="https://arxiv.org/abs/1606.07792"><strong>Wide &amp; Deep Learning for Recommender Systems (2017</strong></a><strong>)</strong></figcaption></figure><p>This architecture has two key components, a wide part (dealing with float value and binary features) and a deep part (learns representations of sparse id based features). Wide part focuses on memorization and deep part on generalization. By jointly training a wide linear model (for memorization) alongside a deep neural network (for generalization), one can combine the strengths of both.</p><p><strong>Wide Network</strong></p><ul><li>Manually created handcrafted interaction features</li><li>Helps in “Memorization” of important interactions</li><li>No Dense Sparse Interaction — Sparse (embedding) features interact in deep part of the network but they don’t interact with the dense part of the network</li><li>No transformations for the dense feature layer</li><li>Uses FTRL for optimization</li></ul><p><strong>Deep Network</strong></p><ul><li>Fully connected Network</li><li>Uses different optimizer than wide part (AdaGrad)</li><li>No explicit interactions : We have a fully connected network which created implicit interactions between features e.g. we can’t learn explicit interaction between category embedding and user embedding for an e-commerce product to learn user proclivity for that category.</li></ul><p><strong>D. Attention Factorization Machines</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3cdqx8uJFEgdAdNkl4E9tA.png" /><figcaption>Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks</figcaption></figure><p>Like factorization machines, this method performs pair wise interactions between representations of features. But to improve over that method it uses attention based pooling mechanism to assign higher weights to most relevant interactions.</p><p><strong>E. Deep &amp; Cross — </strong><a href="https://arxiv.org/abs/1708.05123"><strong>Deep &amp; Cross Network For Ad Click Predictions</strong></a></p><p>This architecture introduces the notion of “explicit” feature interactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*_-4OG8YamN1jrWaaOgQ6Lw.png" /><figcaption>Implicit &amp; Explicit Interactions</figcaption></figure><p><strong><em>Implicit Cross</em></strong> (think image representation) : Interaction is learned through end to end function without any explicit formula modeling such cross. The aim is to learn a high level representation e.g. a feature map in CNNs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PZoTX8sMeNtQY4RkEMgGAQ.png" /><figcaption>Explicit Feature Crosses</figcaption></figure><p><strong>Explicit Cross</strong> (think gender * age * music genre interaction) : Modeled by an explicit formula with controllable interaction order. Aim is to learn weights over these explicit feature crosses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*lr5EKXKAkOcFCQ5qRrNOew.png" /><figcaption>Deep And Cross Network</figcaption></figure><p><strong>Deep &amp; Cross </strong>: Leverage implicit high-order crosses learned from DDNs, with explicit and bounded-degree feature crosses which have been found to be effective in linear models. One part of the network (left part) focuses on creating explicit feature crosses via a controllable function while the other part of the network (right part) is a deep network that learns implicit feature interactions.</p><p><strong>Cross Network In Details</strong></p><p>In the cross network we use following interaction formula</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*oRybp9s1LzjX7p4CUNAnWA.png" /></figure><p>Here each layer would create interaction between output of previous layer and first layer (input layer), then we add the previous layer output as a residual skip connection. As we add more layers, we would generate higher order explicit interactions. We are learning previous layer’s interactions (layer L)via residual connection and adding more information to it via generating another higher order (L+1) interaction via taking element wise product of input vector with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*ZEuRB1gSuWUcwYOB7XlpZQ.png" /></figure><p>In the above image x0 is the input feature vector. x’ is output of last layer. x0 * x’ * w will perform a weight interaction . Weight matrix will learn which interactions are most important. First we will transform the xi layer (select most important crosses) and then interact it further with input vector to generate crosses of i+1 order.</p><p><strong>Intuitive Explanation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*xlE9ssB6z37_LXRNaSTkyg.png" /><figcaption>Toy Example</figcaption></figure><p>In the above examples we have one user and one query feature in input vector (x0). Weight matrix is a binary matrix. The first order feature cross will generate user x query and query x user feature. As we add more layers we would have higher order features.</p><p><strong>F: DCN V2 — DCN On Steroids</strong></p><p><a href="https://arxiv.org/pdf/2008.13535.pdf">DCN V2: Improved Deep &amp; Cross Network and Practical Lessons for Web-scale Learning to Rank Systems</a></p><p>With the aim to speed up learning and inference of DCN, the authors of DCN v2 introduces low rank factorization technique to cross feature computation. In DCN we were learning a weight matrix at each layer to transformer input of previous layer before performing Hadamard product with input vector. This process is computationally intensive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDzOFPmKLzCH9dOg_mcQ4Q.png" /><figcaption>Low Rank Factorization Of Weight Matrix</figcaption></figure><p>DCN V2 computes low rank factorization of the weight matrix and learns matrix U and V (in the above image) as part of training. This process drastically reduces number of parameters of the model and speeds up training as well as inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQ5wo1Y_uMcCDz4YwaLKUg.png" /><figcaption>Low Rank Factorization</figcaption></figure><h3>Part 2 Handcrafting Ranking Model Architecture</h3><p>In this section we would take learning from part 1 and use them to create ranking model architecture.</p><p><strong>A. Baseline Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kddAYBGu8S2w1YM7D-dDhw.png" /><figcaption>Baseline model</figcaption></figure><p>In this architecture we have try to divide the model layers into following components</p><ul><li><strong>Input Layer</strong> — contains float value features, categorical id based features and embedding based features</li><li><strong>Feature interaction layer</strong> : this can be performed in various ways as discussed in <a href="https://smashinggradient.com/2023/01/07/feature-fusion-for-the-uninitiated/">earlier posts</a></li><li><strong>Transformations : </strong>Higher layers to transform the interacted features</li></ul><p><strong>Dense Features (float value features) transformation</strong></p><p>In the baseline model we transform the dense features via a fully connected (FC) layer with non linearity to generate dense representations. The output of this layer is concatenated with feature interaction layer.</p><p><strong>Sparse Feature Interactions</strong></p><p>We can drive the intuition for this step from Factorization Machines discussed in Part 1.B</p><p>In this layer we take pair wise dot product of embeddings of all sparse (id based ) features e.g. user embedding * product embedding, user embedding * brand embedding etc.</p><p>After concatenating the output of the above two steps we further transform them to learn generalized representation. Finally a sigmoid unit decides the click probability.</p><h4>B. Dense Sparse Interactions</h4><p>In the last architecture we performed sparse feature interactions but skipped dense — sparse interactions. Dense features contain bias information e.g. age, gender of user, price of product, popularity score, trending score etc. of the product. When interacted with sparse features, we can gain valuable higher order features. The idea for this type of interactions was first discussed in <a href="https://arxiv.org/abs/1703.04247">DeepFM: A Factori</a><a href="https://arxiv.org/pdf/1703.04247.pdf">zation-Machine based Neural Network for CTR Prediction</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QCfABL4QtLA12Xxi9PnXZQ.png" /><figcaption>Dense Sparse Interactions</figcaption></figure><p><strong>C. Dense Gating</strong></p><p>As discussed in the above architecture, dense features have very critical information that acts like bias for the model. But given the context, important of different dense features can vary e.g. in Ad ranking model, if ads category is gaming then age of the user can be very relevant dense feature. To provide these features higher weight we will use Dense Gating mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E93wNXDA36iWmH8o3mIWiw.png" /><figcaption>Gating Network For Dense Features</figcaption></figure><p>The gating network will learn to select the most important dense features and then transform them to generate dense representation. By introducing the dense gating mechanism, we can control the activation of each dense feature differently before we apply the shared weight matrix.</p><h4>D. Memorization — Adding feature interaction output to final layer</h4><p>Final layer is usually considered as an approach to memorize specific patterns for the model (in contrast, deep neural network before the final layer is more about generalization power).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PcUotstTJFqTAfSt69qPuw.png" /><figcaption>Skip Connection Of Feature Interaction Layer With Final Layer</figcaption></figure><h3>E. Further Optimization</h3><p>We can perform many other optimizations to the above architecture e.g.</p><ul><li>Increase size of sparse embeddings</li><li>Increase dense feature projection</li><li>Increase Over Arch layer dimensions</li><li>Increase Final layer dimensions</li><li>Layer Normalization</li><li>Position Weighted Features</li><li><a href="https://arxiv.org/pdf/1708.04617.pdf">Attention Factorization Machines</a> : uDifferent feature interaction might have different importance for the prediction task. (User gender = male) * (User watch history contains genre rock) might be more important than (User gender = male) * (Query Text Embedding)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22bfba530c55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anatomy Of A Model Inference Service]]></title>
            <link>https://siddharth-1729-65206.medium.com/anatomy-of-a-model-inference-service-fd37fac22e96?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd37fac22e96</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[low-latency]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[model-inference]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Sat, 14 Jan 2023 00:22:39 GMT</pubDate>
            <atom:updated>2023-01-14T00:22:39.217Z</atom:updated>
            <content:encoded><![CDATA[<h3>Context :</h3><p>This document discusses the high level architecture and components required to create a model prediction service. Here we won’t be discussing and comparing particular frameworks in detail. The underlined intention is to provide a holistic view of model serving pipelines, APIs needed and complexities involved. This document would help the reader understand the key components involved in building model serving infrastructure, process flow and areas where out of box frameworks (like TorchServe) can help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zge7A7ZL_F_CdOe6-hQ1XQ.png" /></figure><p><em>(All the diagrams in the document are from pre-print edition of </em><a href="https://www.manning.com/books/software-engineers-guide-to-deep-learning-system-design"><em>Deep Learning System Design Book</em></a><em> )</em></p><h3>What is a model?</h3><p>A deep learning model as an executable program, which contains a prediction algorithm and the required data to make a prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x1JD-f_EEsuhoHJdxdufIg.png" /></figure><p><strong>Model Artifact</strong>: Artifacts include code that trains models and produces inferences, and any generated data<br>such as trained models, inferences, and metrics.</p><ul><li>Model Graph</li><li>Model Weights</li><li>Vocabulary</li><li>Embeddings</li></ul><p><strong>Model Metadata</strong> : Metadata is any piece of data that describes an artifact, or describes relationships between artifacts.</p><ul><li>Owner</li><li>Timestamp</li><li>Model id</li><li>Version</li><li>Training Data Version</li><li>Model Artifact Storage URL</li></ul><h3>Model Prediction Service</h3><h4>Model Prediction Workflow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9kT4hevBdWWY56bSseMqA.png" /></figure><h3>Common model serving strategies</h3><ol><li><strong>Monolith Design</strong> : Load model and run model prediction inside the user application’s process. For example, a flower identity check mobile app can load an image classification model directly in its local process, and predict plant identity from the given photos. The entire model loading and serving happens within the model app locally (on the phone), without talking to other processes or remote servers.</li><li><strong>Model Service</strong>:</li><li>Model service means running model serving at server side. For each individual model, each version of a model or each type of model, we build a dedicated web service for it. This web service exposes the model prediction api over HTTP or gRPC interfaces.</li><li>The model service manages the full life cycle of model serving, including fetching model file from model artifact store, loading model, executing model prediction algorithm for customer request and unloading the model to reclaim the server resources.</li><li><strong>Model server</strong></li><li>The model server approach is designed to handle multiple types of models in a blackbox manner. Regardless of the model algorithm and model version, the model server can serve these models with an unified web prediction api.</li><li>Many open source model serving libraries and services, such as <strong><em>Tensorflow serving, TorchServe and Nvidia Triton</em></strong>, offer model server solutions. What we need to do is to build customized logic on top of these tools to solve our own business needs, which includes managing model request routing, model access API, model model files, model metadata and input/output data processing.</li></ol><h3>Single Model Service</h3><p><strong>Objective</strong>:<em> Only build the necessities to get models into production as quickly as possible, and lower down the operation cost.</em></p><p>When the backend predictor service first starts, the predictor will first load the model and<br>get the model ready to execute from its web API. Backend application will receive the request and call<br>the predictor’s web API for face swapping. Then the predictor pre-process the user request<br>data (images), executes the model prediction algorithm and post-process the model output back to the application backend. model. The key component in this design is the predictor, it is a web service and often runs as a docker container.</p><p><strong>Pros</strong></p><ul><li>quick to bootstrap and easy to develop</li><li>minimalistic design</li></ul><p><strong>Cons</strong></p><ul><li>can serve only one type of model</li><li>can serve only one version of model</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qRyvnKqGTapJqZIOicYF5w.png" /></figure><h3>Multi-Tenant application</h3><p>To build such an omnipotent model serving system, we need to consider lots of things. Such as model file format, model libraries, model training frameworks, model caching, model versioning, one unified prediction api that suits for all model types, model flow execution, model data processing and model management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVUeX69-nYX1lF9UEeB5Ow.png" /></figure><h4>Components</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DlXisYIwIxKYRjvKITJo2g.png" /></figure><h3>Model Serving Deep Dive</h3><h4>A. High Level Model Serving End-To-End Workflow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*znpBi5XEWF9Vh0aEV7TJUQ.png" /></figure><p>This sample service consists of a frontend interface component and a backend predictor. <strong><em>The frontend component does</em></strong> <strong><em>three things:</em></strong></p><ol><li>Hosting the public prediction api</li><li>Downloading model files from metadata store to a shared disk volume</li><li>Forwarding the prediction request to the backend predictor.</li></ol><p>The <strong><em>backend predictor</em></strong> is a self-built predictor container, which responds to load intent classification models and executes these models to serve prediction requests.</p><p>This prediction service has two external dependencies: the metadata store service and a shared disk volume. Metadata store keeps all the information about a model, such as model algorithm name, model version and model url that points to the cloud storage of real model files. Shared volume enables model file sharing between the frontend service and the<br>backend predictor.</p><p>B. <strong>The frontend service</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGpHbgKGdbRJ5D4qjddJPw.png" /></figure><p><strong>Process Flow</strong></p><ol><li>User sends an prediction request with modelID “A” to the web interface;</li><li>The web interface calls predictor connection manager to serve this request;</li><li>Predictor connection manager queries the metadata store to get model metadata by searching model id equals “A”, the returned model metadata contains model algorithm type and model file url;</li><li>Based on the model algorithm type, predictor manager picks the right predictor backend client to handle the request. In this case, it chooses CustomGrpcPredictorBackend since we are demoing a self-built model serving container for intent classification;</li><li>CustomGrpcPredictorBackend client first checks the existence of the model file in the shared model file disk for model “A”. If the model hasn’t been downloaded before, it then uses the model url (from model metadata) to download model files from cloud storage to the shared file disk;</li><li>The CustomGrpcPredictorBackend client then calls the model predictor which is pre-registered with this backend client in the service configuration file. In this example, the CustomGrpcPredictorBackend will call our self build predictor</li></ol><p><strong>Predictor Connection Manager</strong><br>One important role of the frontend service is routing prediction requests. Given a prediction request, the frontend service needs to find out the right backend predictor to handle based on the model algorithm type required in the request. This routing is done in the PredictorConnectionManager. In our design, the mapping of model algorithms and predictors is pre-defined in environment properties. When service starts, PredictorConnectionManager will read the mapping so the service knows which backend predictor to use for which model algorithm type.</p><p><strong>C. Backend Predictor Service</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*miqvgK9jikZHbqtwUaGrvQ.png" /></figure><p>We can see this self-built classification predictor as an independent micro service, which can serve multiple models simultaneously. It has a gRPC web interface and a model manager. The model manager is the heart of the predictor, it does multiple things, including loading model files, initializing the model, caching the model in memory and<br>executing the model with user input.</p><h3>Torch Serve</h3><p><a href="https://pytorch.org/serve/">TorchServe</a> is a performant, flexible and easy to use tool for serving PyTorch eager mode and torch scripted models. Similar to Tensorflow serving, TorchServe takes a model server approach to serve all kinds of PyTorch models with an unified API. The difference is TorchServe provides a set of management api that makes model management very convenient and flexible. For example, we can programmatically register and unregister models or different versions of a model. And we can also scale up and scale down serving workers for models and versions of a model.</p><p><strong>AWS Support: </strong><a href="https://aws.amazon.com/blogs/machine-learning/deploying-pytorch-models-for-inference-at-scale-using-torchserve/">https://aws.amazon.com/blogs/machine-learning/deploying-pytorch-models-for-inference-at-scale-using-torchserve/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajB0xFTK57Eg9txQZRFw3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UjJl-rA8K6cCzYk_kqFqaA.png" /></figure><p>In the above image we can see two gray boxes are added, they are TorchServe GRPC predictor backend client (TorchGrpcPredictorBackend) and TrochServe server. The TorchGrpcPredictorBackend response to download model files and send prediction requests to the TorchServe container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5w5-CEfXSq73YcOmzqBdkg.png" /></figure><p>TorchServe is a tool built by the PyTorch team for serving PyTorch models (eager mode or torch scripted). TorchServe runs as a blackbox, and it provides HTTP and gRPC interfaces for model prediction and internal resource management. The above figure visualizes the workflow for how we use TorchServe in this sample.</p><p><strong>Minimalistic Design Without Need For Frontend And Backend Services</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHfy9-eDRPklQjCEgfYnGQ.png" /></figure><p>A TorchServe server is composed of three components: frontend, backend and model store. Frontend handles the request/response of TorchServe. It also manages the life cycles of the models. Backend is actually a list of model Workers, these workers are responsible for running the actual inference on the models. Model Store is a directory in which all the<br>loadable models exist, it can be a cloud storage folder or local host folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOEspqG28oOW_s_fwxdASA.png" /></figure><p>The figure above draws two workflows: <strong>model inference </strong>and<strong> model management</strong>.</p><p>For <strong>model inference</strong>, first, the user sends a prediction request to the inference endpoint for a model,<br>such as /predictions/{model_name}/{version}; next, the inference request gets routed to<br>one of the worker processes which already loaded the model. Then, the worker process will<br>read model files from the Model store and let the model handler load the model, pre-process<br>input data and run the model to get a prediction result.</p><p>For <strong>model management</strong>, a model needs to be registered before users can access it. This<br>is done by using the management api. We can also scale up and down the worker process<br>count for a model. We will see an example in the sample usage section below.</p><p><strong>Features</strong></p><ul><li>Can serve multiple models, or multiple versions of the same model.</li><li>Unified gRPC and HTTP endpoints for model inference.</li><li>Support batching prediction request and performance tuning.</li><li>Support workflow to compose Pytorch models and Python functions in sequential and parallel pipelines.</li><li>Provide management api to register/unregister model and scale up/down workers.</li><li>Model versioning for A/B testing and experimentation.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd37fac22e96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Feature Fusion For The Uninitiated]]></title>
            <link>https://siddharth-1729-65206.medium.com/feature-fusion-for-the-uninitiated-4c5938db28b7?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c5938db28b7</guid>
            <category><![CDATA[ránking]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Fri, 13 Jan 2023 07:18:35 GMT</pubDate>
            <atom:updated>2023-01-13T07:18:35.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*xPgnQTUREM8pIdNl" /><figcaption>Feature Fusion</figcaption></figure><p>Consider a typical e-commerce product. It would have a variety of content specific features like product title, brand, thumbnail etc and other engagement driven features like number of clicks, click through rate etc. Any machine learning model ingesting features of this product(e.g. product ranker, recommendation model etc.) would have to deal with the problem of merging these distinct features. Broadly speaking we can divide these features in following categories</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*J2sfafThARTmAm9N7-YwFA.png" /></figure><p>In a Neural Network if we step beyond the input layer, a common problem faced is around fusing (merging) these features and creating a unified embedding of the entity (e-commerce product in our case). This unified embedding is then further transformed in higher layers of the network. Considering the variety of features (float value features, embedding based features, categorical features etc), performance of the model depends on when and how we process these features.</p><p>In rest of the post we would discuss various feature fusion techniques.</p><h3>Embedding Feature Fusion Techniques</h3><p>For the sake of simplicity we would first consider the case of how to handle multiple embeddings in the input feature layer. Later on we would include architectural techniques to merge dense (float value features). As an example if we are building a music recommendation model, one of the input to the recommender may be embeddings of last k songs listened by the user or embeddings of genres of last k songs listened. Now we would want to fuse(merge) these embeddings to generate a single representation for this feature. Next section would discuss techniques to combine these embeddings in the input layer and generate a unified embedding.</p><h3>Method 1 — Concatenate And Transform</h3><p>In the diagram below, input layer can have text, images and other types of features. Respective encoder would process the corresponding input (e.g. pre-trained Resnet can generate image embedding, pre trained BERT can generate text embedding etc) and generate an embedding. These embeddings are represented as vector-1, vector-2 and vector-3.</p><p>In concatenation based fusion technique we would concatenate embeddings belonging to each modality and then pass it through a fully connected network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*EEf4FG3nzwMjV14w" /></figure><h3>Method 2 — Pooling</h3><p>Another light weight technique is use techniques like mean and max pooling. In the image below, Youtube session recommender is fusing embeddings of watched videos in a session using average of their embeddings.</p><figure><img alt="Deep Neural Networks for YouTube Recommendations" src="https://cdn-images-1.medium.com/max/1024/0*Nq7XG9wuABPXl0f2" /><figcaption><a href="https://research.google/pubs/pub45530/">Deep Neural Networks for YouTube Recommendations</a></figcaption></figure><h3>Method 3 — Pair Wise Dot Product</h3><p>In this method we would take pairwise dot product of each embedding (vectors in the image below). After the pair wise dot products we would further use MLP (or Full connected) layers to transform it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AiZTEELyQe8wBepx" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/0*q64pZqeZUMhSDTu0" /><figcaption>Pair Wise Dot Product</figcaption></figure><p>One of the drawback of this technique is its computational complexity. Due to quadratic computational complexity, the number of dot products grow quadratically in terms of the number of embedding vectors. With increasingly input layer, <strong><em>the connection of dot products with fully connected layer can become an efficiency bottleneck and can constrain model capacity.</em></strong></p><p>To overcome this issue we can resort to<strong> Compressed Dot Product Architecture </strong>discussed in the next section</p><h3>Method 4 — Compressed Dot Product Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*5_9zV9wqt7RkfYWA" /><figcaption>Dot Product Of Embeddings As Matrix Multiplication</figcaption></figure><p>In the above figure we have showcased pairwise dot product fusion as matrix multiplication. Consider X as a matrix of feature embeddings. Here we have 100 features and each feature embedding is of length 64. Pair wise dot product can be view as a product of feature matrix and its transform.</p><p>The compression technique exploits the fact that the dot product matrix XX has rank d when d &lt;= n, where d is the dimensionality of embedding vectors and n is the number of features.</p><p>Thus, XXT is a low rank matrix that has O(n*d) degree of freedom rather than O(n2). In other words, <strong>XXT is compressible</strong>. This is true for many current model types that have sparse input data. This allows compression of the dot product without loss of information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*oHi8fF3VASvQl8j2" /><figcaption><a href="https://www.tdcommons.org/cgi/viewcontent.cgi?article=3891&amp;context=dpubs_series">Dot Product Matrix Compression for Machine Learning</a></figcaption></figure><ul><li>X is an n*d matrix of n d-dimensional embedding vectors (n=100;d=64).</li><li>Per techniques described herein, instead of calculating flatten(XXT), flatten(XXTY) is calculated.</li><li>Y is an n*k matrix (in the example k=15).</li><li>Y is a learnable parameter and is initialized randomly.</li></ul><p><strong>XXT </strong>would lead to n * d * n operations, where as dot product compression XXTY would take O(n * d * k) operations (k is very less than n).</p><p>Y is a learnable parameter and is initialized randomly. Y can be learnt, alongside other parts of the model. The projection through Y significantly reduces the number of neurons passing to the next layer while still preserving the information of original dot product matrix by exploiting the low rank property of the dot product matrix.</p><p>One of the drawback of this approach is that learned matrix Y becomes independent of the input. It would have same values for all inputs. To resolve this issue, we can use attention aware compression (please refer to <a href="https://www.tdcommons.org/cgi/viewcontent.cgi?article=3891&amp;context=dpubs_series">Dot Product Matrix Compression for Machine Learning</a> for more details).</p><h3>Method 5 — Attention Fusion</h3><p>In this approach we follow the <a href="https://proceedings.neurips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf">self attention</a> logic to fuse different embeddings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iP1BZgoOjQXF7r2Q" /></figure><h3>Method 6 — Tree based Fusion</h3><p>In this technique we concatenate the feature embeddings and provide them as a single input to a Tree Ensemble Model e.g. <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html">Boosted Trees or GBT</a>. This model will be separately trained from the main neural network. In this phase we would take output of leaves of each tree in the ensemble. In the image below these are depicted as h1, h2 etc. The fused (transformed) embedding will be concatenation of the output of leaves (h1 + h2 + ..). This will be provided as input to the main neural network. On a high level this acts as a non linear transform of input features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*WkYQ3KAAa7qEU3KZ" /></figure><h3>Dense (Float) Features Fusion</h3><p>The special case for feature fusion is for float value features. Unlike embedding based feature fusion, here we have just one vector of float features (e.g product price, click through rate, add to cart rate etc.). For handling dense features we would pass them through a fully connected layer with non linearity. This will lead to a transformed representation that would either concatenated or interacted with sparse fused features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/0*dT06rhxvAmlXQ_oV" /></figure><h3>Baseline Model</h3><p>An example architecture for a baseline model is described below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*cYX8Yg7Dhqnd11eM" /></figure><p>In this architecture we are first performing fusion of dense features. Separately sparse features (or embedding features) will have dot product fusion in a separate layer. As next step we are concatenating the fused vector of dense and sparse vectors in the interaction arch. In the next part of the network we are performing transformations over the concatenated feature vector.</p><h3>Dense Sparse Feature Fusion</h3><p>The last piece of the puzzle is how to interact the dense features and sparse features. Till now we have seen embedding based feature fusion (let’s say via dot product fusion) and dense (float value features) fusion. In this section we would explore how to interact (fuse) them together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*V0oA1kJ9K9oQKcdt" /></figure><p>For dense-sparse interactions we would first generate an intermediate representation of the dense features via performing a non linear transform. Then we would perform following two steps</p><ul><li>Concatenating transformed dense feature representation to interaction layer</li><li>Stacking the transformed dense feature representation with embedding inputs</li></ul><p>In this way the dense transformed representation (output of FC + Relu layer) would take part in dot product fusion, hence it will interact with the individual embeddings of the input layer. Since dense features contain bias information (e.g. CTR or number of clicks provide bias about product performance), we would want to preserve this information. Hence in a residual connection kind of way we concatenate the transformed dense representation with the output of dot product fusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c5938db28b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search Query Understanding]]></title>
            <link>https://siddharth-1729-65206.medium.com/search-query-understanding-8e8baec040c5?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e8baec040c5</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[information-retrieval]]></category>
            <category><![CDATA[query-understanding]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[search-engines]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 05:29:30 GMT</pubDate>
            <atom:updated>2021-04-06T16:28:19.054Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>The journey of a search query through e-commerce engineering stack can be broadly divided into following phases, search query text processing phase, retrieval phase where relevant products are fetched from indexer and the last but not the least, product re-ranking phase where a machine learning ranking engine re sorts the products primarily based on combination of KPIs like click through rate, add to cart rate, checkout rate etc. The focus of this post would be primarily on the first phase i.e. query text processing via a Query Understanding Service (QUS). I would be discussing the applications and working of QUS in e-commerce search. QUS is one of the most critical service needed to resolve user query and find the key search intent. Among the plethora of machine learning(ML) services working across the engineering stack in any e-commerce company, QUS is usually the first to hold the fort and acts as the backbone ML service in pre retrieval phase.</p><p>When a user enters a query in the search box, the first step is to ingest that raw text and generate some structured data from it. The objective here is to find as much relevant information from the query as possible and retrieve the most relevant results for the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/0*hzCrebfXQgIGF3m6" /></figure><p>The search query in e-commerce can contain many clues that can guide us in finding results pertinent to user’s intent. A query like “<em>levi black jeans for men</em>” consist of a un-normalized brand name “levi”, gender “men”, product type “jeans”, color “black” and top level taxonomy category of the query can be Clothing &amp; Accessories. The aim of QUS is to find these attributes, normalize them (levi =&gt; Levi Strauss &amp; Co, mens =&gt; Men etc.) and send this information to retrieval endpoint to fetch relevant results. QUS would comprises of an ensemble of sub services like query category classification service, query tagging service, attribute normalization service etc. In the case of long tail queries(queries that are not too common and results in either very limited products or null results) the output of QUS can be further used to relax by rewriting it, this process is known as <strong>query relaxation</strong>. Furthermore we can also expand the query (<strong>query expansion</strong>) where we can show user results which are near similar to search query e.g. if user search for “light blue tee”, we can expand the results set where color can be either light blue, blue or violet. Also in case of brand sensitive queries, the result can be expanded to near similar brands to provide user exposure to available alternatives in your inventory.</p><h3>Common Issues</h3><p>QUS will help move search beyond raw keyword match. In a <strong>world without QUS </strong>following <strong>issues</strong> can occur if we depend on pure SOLR retrieval</p><ol><li><strong>Wrong product categorization </strong>: queries like “hershey cocoa powder” that belong to Grocery category can retrieve fashion products since it has the word “powder” in it.</li><li><strong>Retrieval</strong> <strong>Sensitivity</strong> :</li></ol><p>Queries like “office desk wooden” vs “office desk wood”, “halloween costumes for girls” vs “halloween costumes girls” can result in different results although they have the same search intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ozy5iINCJh-Cl0Yd" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RJKNNHRjhQPX067R" /></figure><p>Solr Provides equal weightage to all the tokens. This may result in a situation like the following where the tokens “range” is getting equal weight as “eggs”. Hence the result set includes “range free chicken”.</p><p>3. No <strong>query relaxation</strong>: too narrow queries are mostly unresolved e.g. “fleece queen size sheets” can return blankets — query should be relaxed to “queen size sheets”</p><p>4. <strong>Price Agnostic</strong> Search: Another feature of QUS is be to extract price information from the query, this either can be done by using either a set of regular expressions or using tagger + normalizer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YQilSf_47kpY6S3p" /></figure><p>5. <strong>Unresolved Brand Variants</strong>: For queries like “coke six pack” vs “coca-cola six pack” results can be different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kny23ioIJmTvR-Lz" /></figure><h3>Search Phases</h3><p>We can divide the e-commerce search process in two phases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*laVpIM4BzfIcBV9x" /></figure><h3>Post Retrieval :</h3><p>This phase is concerned with the retrieved relevant results corresponding to the query. It is here where we rank the results, add recommendation, add sponsored products to the final list of results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QoqVcSZSgGGLhByA" /></figure><h3>Pre Retrieval :</h3><p>This is the phase where we haven’t yet retrieved results from backend indexing engine yet. The only information we got to deal with is the raw user query. Usually this phase comprises of following components (can be separate microservices)</p><p><strong>Spell corrector</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PS4gkBAuuoi9K0x_" /></figure><p><strong>Intent Detection</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pMGQFIZ-VIo-O1_R" /></figure><h3>Query Classifiers</h3><p><strong>Category Classifier</strong>: This service would classify the query into leaf level categories corresponding to the catalog structure/taxonomy. The output of this service would be a set of leaf level categories. Solr can either filter the results on the basis of predicted set of categories or boost the results for products belonging to predicted category set.</p><p><strong>Product Type(PT) Classifier</strong>: Usually taxonomies are hierarchical in nature e.g. Under top level Clothing &amp; Accessories category you would have Shirts at level 2 and Men/Women/Children at level 3, formal/casual at level 4 etc. Due to noise in catalog content and semantic issues in catalog structure (near similar leaf categories under different L1s e.g. tea can be in Grocery as well as Office &gt; Pantry items) it is usually better to classify the query into flat hierarchy Product Types e.g. in the context of last query PT would be just Shirts, if query is iphone 9 charger, PT would be “Phone Chargers”</p><h3>Query Tagger</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BjBFz1Zd7ngtwJb1" /></figure><p>Just like query category classifier and query product type classifier query tagger is another component of QUS but unlike them it works on tagging individual tokens in a query rather than categorizing the whole string.</p><p>The aim here to successfully detect customers intent and improve retrieval by finding tokens in the query that contribute to key <strong>product</strong> being searched by customer<strong>, brand, gender, color, size, price range</strong> etc. This would help us in</p><ol><li>refining the retrieval in a faceted manner</li><li>resolving long tail queries</li><li>query rewriting and query relaxation</li><li>product promotion / recommendation</li></ol><pre>Architecture: <a href="https://arxiv.org/abs/1508.01991"><strong>Bidirectional LSTM-CRF Models for Sequence Tagging</strong></a><br><strong>Tutorial</strong> : <a href="https://guillaumegenthial.github.io/sequence-tagging-with-tensorflow.html">https://guillaumegenthial.github.io/sequence-tagging-with-tensorflow.html</a></pre><p><strong>Tagger Attributes</strong></p><p>Broadly speaking there are two types of attributes, namely global and local. <strong>Local attributes</strong> are highly specific to particular leaf categories e.g. attributes for <strong>Home&gt;Furniture&gt;Table</strong> would have attribute key/values like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDCZkR1qhACLmneU046ibQ.png" /></figure><p>Since each leaf level category can have specific attributes that are not applicable to other categories, we can end up with a large number of local attribute key/value pairs. That’s why it is better to not to use Tagger to detect these attributes since we would face performance issues in scaling the tagger to these many attributes.</p><p>On the contrary there are other set of <strong>attributes that are global</strong> in nature i.e. they are not focused on any particular category e.g. size can be found in clothing, in furniture, appliances etc. Although the values of these attributes can be category specific e.g. size in clothing can take values like XS, S, M, L etc. while size in home appliances &gt;Microwave category could have valid size values as Compact, Mid-Sized, Family Size etc. They are present across categories or at least in bunch of categories. It is better to use a tagger to detect these attributes. The table below comprises of what we call as global attributes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QcuI-drUZazD8sMBvZTehQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGuw4gfebhrGjtCp3-Cn0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*TvZETHzNkGGN83pDaYtoZg.png" /><figcaption>Global Attributes</figcaption></figure><h3>Attribute Normalization</h3><p>Once the tagger detects a mention in query and tags individual tokens the next step involves normalizing these tokens. For attributes types like color, normalization is pretty straight forward e.g. {red, light red, pink, .. etc} can be mapped to one color family with normalized name RED, similarly for price too we can create a standardized denomination using a set of regular expressions. With normalization we are aiming to standardized the attribute key/value pair w.r.t the values in catalog. Here the prior requirement is that products in catalog would have canonicalized values for attributes e.g. all men shirts would have size attribute mapped to only a predefined values {XS, S, M, L, Xl, XXL ..}. Now once we detect size attribute in a query like “mens small checked shirt”, the next step is to normalize the size token “small” to normalized attribute value in catalog “S”. This would help us in either making a faceted query to SOLR or boost products in retrieval where size attribute is “S”, thereby enhancing the retrieval quality.</p><p><strong>Numerical attributes</strong> like price, quantity (e.g. 1 gallon milk), Age (toys for 8–12 years old) can be handled with regular expression driven approach. Once we detect category and product type of a query, we can apply set of regular expressions applicable for only those categories and PTs to extract numerical attributes e.g. for query like “2 gallon whole milk”, the category can be “Grocery&gt;Milk&gt;Whole Milk” and PT can be Milk, once we know these values we can apply a set of regular expression created exclusively to handle the grocery/milk quantity/amount normalization. The following set of queries have price attribute values as 20 that can be easily extracted using a couple of regular expressions.</p><p>a. “tees under 20”</p><p>b. “tees under $20”</p><p>c. “tees under 20 dollars”</p><p>d. “tees under 20 usd”</p><p>Overall<strong> attribute normalization can be achieved using following approaches</strong></p><ol><li><strong>Regular Expressions</strong> based methods</li><li><strong>Rule based methods</strong></li></ol><p><em>a. This is a simple yet very effective approach. Before jumping to nlp based methods a good way to get some quick wins and draw a performance baseline is to manually create rules for normalization.</em></p><p><em>b. A sql like table can be created with each unnormalized attribute mapped to its normalized variant</em></p><p><em>c. A simple lookup in the table can generate normalized attribute values.</em></p><p><strong>3. Classification Based Approach</strong>:</p><p><em>a. The key drawback of the</em><strong><em> rule based approach</em></strong><em> is that it is</em><strong><em> not scalable</em></strong><em>. It would too much manual effort to analyze the queries and find varied patterns in them and create explicit rules to map them to normalized values.</em></p><p><em>b. But the last approach would provide us a labeled data set to work with i.e. attribute values mapped to their canonicalized versions.</em></p><p><em>c. The above data set can be used to create an attribute classifier. The difference between this and category classifier that I mentioned earlier is that here we would be classifier the tagged mention (e.g. Product Line) and in the earlier we were classifying the whole query string.</em></p><p><strong>d. Entity Linking</strong> based approach</p><p><em>i. Entity linking is wholesome topic that I plan to write about in a separate post. But to provide gist of the idea Entity Linking is a process to detect mention strings in a text that may correspond to names entities (like tagging finds mentions and tags them to attribute keys like Brand, Size etc.) and then tries to map them to the entities in knowledge base. This method can be useful while trying to detect brands in query as well as in product title and description.</em></p><p><em>ii. Although there are neural architectures that can detect the mention string and then link the mention to the best candidate entity, in the next section we would discuss a much similar model based approach.</em></p><h3>Entity Linking Based Brand Normalization</h3><p>Let’s say we have a mention string tagged as Brand in the search query. The entity linking task can be broken into two steps: candidate generation and candidate ranking. <strong>Candidate generation</strong> means fetching normalized brand candidates that are syntactically or semantically similar to the mention string, e.g for search query “paw-patrol fire truck”, the tagger would generate mention for Brand as “paw-patrol” and the candidate generation phase can find a set of syntactically similar brands from catalog for category Toys. Traditionally an information retrieval based approach for candidate generation has been used like BM25, a variant of TF-IDF to measure similarity between mention string and candidate brands and their description. Once we have a set of candidates we can rank them in the <strong>Candidate ranking</strong> phase.</p><p>A context aware ranking can be done by using the left span of mention, mention string, right span of mention as separate inputs to a model. We can create a model to score the contextual similar of a mention string to description of a brand. For getting description of brands(and hence their <a href="https://arxiv.org/abs/1206.5538">representations</a> we can either create a custom dataset or get brand pages from wikipedia and learn a representation for them using the title, introduction of the brand).</p><p>In <a href="https://arxiv.org/pdf/1909.10506.pdf">Learning Dense Representations for Entity Retrieval</a> authors uses model architecture similar to sentence similarities architecture to put the entity description and mention description representations near each other in the same domain. Furthermore this kind of approach is highly preferable since the brand representations can be pre computed and since in this architecture there is no direct interaction between the encoders on each side, we can just compute the contextually aware representation of the mention string and take a dot product between it and pre computed brand representations. This enables efficient retrieval, but constrains the set of allowable network structures. The image is from the mentioned publication depicting how the components from the query string and entity description can be used to find similarity between the two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MTnwIIF7MEUgl1q9" /></figure><h3>Brand Resolution In A Noisy Catalog</h3><p>It may happen that brand names are not normalized in the catalog. In this case some brand e.g. Coca-Cola can be referred by different products in catalog using different variants e.g. coke, coca cola, coca-cola, coca + cola etc. Here we can’t normalize brand in query since brand names in catalog aren’t normalized. So instead of canonicalizing the brand in query we should aim to fetch products that refer to any variant of the searched brand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PRQ8JneCeWHbTXsr" /></figure><p>A simple yet handy way to canonicalize brand names in queries would involve following steps</p><ol><li>Parse the catalog to create a mapping of product type : list of available brand</li></ol><p><em>a. E.g. coffee maker : [black decker, black &amp; decker, black and decker, black + decker, Mr. Coffee, Keurig, …..]</em></p><p>2. Use Product Type classifier to get the query PT</p><p>3. Use query tagger to get the token/tokens tagged as B-BR and I-BR</p><p>4. Now match the tagged tokens with list of brands corresponding to the predicted product type and use <strong>string similarity approaches</strong> to select candidate brands</p><blockquote><em>a. Trigram-Jaccard</em></blockquote><blockquote><em>b. Levenshtein Edit Distance</em></blockquote><blockquote><em>c. JaroWinkler</em></blockquote><blockquote><em>d. FuzzyWuzzy</em></blockquote><p>Example:</p><p>For a query like “<strong><em>coffee maker black n decker</em></strong>” the predicted Product Type can be “Coffee Maker” and mention string tagged as brand can be “black n decker”. A lookup in PT to brand list map can return list of valid brand variants in catalog for PT “Coffee Maker” as [black decker, black &amp; decker, black and decker, black + decker, Mr. Coffee, Keurig, …]. Now by using edit distance of either 1 or 2 to we can find candidate brands from brand list mapped to product type coffee maker as [black decker, black &amp; decker, black and decker, black + decker]. Later on Solr can boost all these brands while retrieving the results for this query. In this approach we don’t even needs brands to be normalized in the catalog since we can boost all variants in one go.</p><h3>Connecting the Dots</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uzv_RNQTD2w6KPbU" /></figure><p>Once QUS fetches all the key insights from the query, the results are forwarded to SOLR. The prerequisite is that catalog is indexed with separate dimensions for Category, Brand, product type etc. For retrieval we can use a weight based scheme where higher weight based boost is provided to predicted categories, product types, brands etc. For attributes like category and PT we can even make a faceted search call while adding boosts for predicted brand, product line, size etc. Furthermore we can also add a relaxed secondary query to the main query so that the recall can be high. This will help in resolving long tail queries and null result queries. The product ranker layer can take care ordering the relaxed query supplemental results w.r.t to products returned from main query. More advanced techniques like creating a separate optimization service to predicts weights for attributes to be boosted based on user query can further enhance the relevance of returned results e.g. for clothing query the SOLR weight prediction algorithm can provide more weights to brand and price rather then style/pattern.</p><p>Follow me on smashinggradient.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e8baec040c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Of Bandits And Bidding]]></title>
            <link>https://siddharth-1729-65206.medium.com/of-bandits-and-bidding-26b6109d5d9d?source=rss-38f9b73a928c------2</link>
            <guid isPermaLink="false">https://medium.com/p/26b6109d5d9d</guid>
            <category><![CDATA[real-time-bidding]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[advertising]]></category>
            <dc:creator><![CDATA[Siddharth Sharma]]></dc:creator>
            <pubDate>Mon, 09 May 2016 21:59:56 GMT</pubDate>
            <atom:updated>2016-05-09T21:59:58.959Z</atom:updated>
            <content:encoded><![CDATA[<p>Real-time bidding(RTB) refers to the buying and selling of online ad impressions through real-time auctions that occur in the time it takes a webpage to load. Those auctions are often facilitated by ad exchanges or supply side platforms(SSPs). A RTB agent has a set of active ad campaigns each with its own targeting criteria. So when an ad request is broadcasted by an ad ex or SSP, each RTB agent has to take two important decisions, first is given the segment (a segment is just the unique set of features of the incoming request e.g. geo location, content category, ad slot size, ad slot position etc) which campaign to serve from list of active campaigns and the second one is, how much to bid at.</p><p>The first problem is dealt by <strong>smooth pacing</strong> algorithms. They involve allocating/spreading out the daily budget of a campaign throughout (if possible uniformly) the 24 hours time line. The main aim of pacing algorithm is to allocate the budget of a campaign to different time periods in such a way that the campaign is able to exhaust the daily budget as well as impressions delivery is not skewed or biased. In this article I will not be discussing the details of pacing algorithm, rather I will dig into the intricacies of bidding algorithm, in particular how Bayesian Bandits can be used to determine optimal bidding price in real time.</p><h3>Under The Analytical Hood</h3><p>We are starting with the assumption that given a segment S (impression request), N RTBs are actively bidding on it. We are unaware of the number N and this number is a dynamic parameter. It may happen that the campaign running on one of the competitor RTB targeting the concerned segment ends, and we are left with N-1 bidder, on the other hand new bidders can join the bidding process thereby increasing the number of active bidders.</p><p>Furthermore an impression has relative significance for each RTB agent. Let’s say some RTB has an active campaign that is only targeting impressions belonging to one particular segment and this campaign has high CPM and huge daily budget. Now this RTB will bid higher compared to rest of the bidders when an impression belonging to that particular segment is received.</p><p>Another interesting aspect that makes this problem more challenging is that if an RTB lost the bid, it will never get to know the auction winning price.</p><ul><li>The number of players in the game are dynamically changing</li><li>The bid process response is either 1 (you won the bid) or 0 (you lost the bid)</li><li>At some particular bid price for a segment we have an associated win rate distribution.</li><li>The payoffs matrix is unknown i.e. we don’t know how important that segment is to the competing RTB.</li></ul><p>We are further making an assumption that given an impression request a Pacing Algorithm has already selected a campaign and the win rate to achieve. There will be a specific win rate associated for each campaign and segment pair. Since each segment has different available inventory we can distribute our budget accordingly. So even though in next thirty minutes we are expected to receive 10000 impressions belonging to a particular customer segment we needn’t win them all. Based on all active campaigns targeting them, their respective budgets and availability of all other segments that can be targeted too our pacing algorithm outputs a win rate value. Now we will try to analytically formulate a model for the bid price prediction problem. I will try to be as much comprehensive as possible for the benefit of the uninitiated reader.</p><p><strong>Symbols used and assumptions made :</strong></p><ul><li>We denote the parameters of the ith competing bidder for segment s by <strong>Bidder(i,s)</strong>.</li><li><em>Each </em><strong><em>Bidder(i,s)</em></strong><em> is assumed to draw it’s bid price at some time ‘t’ from a Gaussian Distribution</em> with <strong>mean=μ(i,s)t </strong>and some constant <strong>standard deviation = σ</strong></li><li>We assume the standard deviation, σ is very small, but over time a bidder can change mean parameter of bid price.</li><li>From Game Theoretic standpoint this is a <strong>Game of incomplete information</strong> i.e. each bidder will only get to know the optimal win price only if he wins the bid and will never know what other bidders are bidding. Every player will have different set of information regarding the payoffs.</li><li><em>The Payoffs are continuously changing</em> i.e. the winning rate of bids on a constant bid amount (a fixed strategy) is changing.</li><li>Each <em>bidder i, bids on a proportion of incoming request</em> from SSP for a particular segment s, therefore even if some bidder is bidding way less he/she will win some times since it may happen that other RTBs who usually bid higher for segment s haven’t bid on some particular requests. Lets denote the normalized bidding rate of a player i on segment s as <strong>p^i,s (Medium lacks superscript) </strong>. So we can also say that <strong>p^i,s represents the probability of bidding for an RTB i on segment s</strong>.</li></ul><p>Since a bidder can increase or decrease its pacing rate depending time of day and remaining budget of the campaign <strong>p^<em>i,s </em>is a dynamic parameter.</strong></p><h3>Win Price Distribution</h3><p>The<strong> Win Price distribution at time t will be a Gaussian Mixture Model</strong> with<strong>probability density function(pdf)</strong> as</p><p>pdf(x) = <strong>p^1,s * N(x|mean=μ(1,s)^t , sd= σ) + p^2,s * N(x|mean=μ(2,s)^t , sd= σ) + …………………….+ p^n,s * N(x|mean=μ(n,s)^t , sd= σ)</strong></p><p>here n refers to total number of bidder and x is the bid price.<em>The above distribution will give us the probability density of the bid price.</em></p><p><strong>So given a bid price x the above pdf will give us probability density of winning the bid.</strong></p><p>To solve the above problem i.e. to derive the estimated values of all the distribution parameters pi,s and mean=μ(i,s)t , sd= σ we need to generate a sample (points) from the distribution and then calculate the parameters using Expectation Maximization. In the figure below the distribution is sum of two Gaussian Distribution. We can imagine that there are two bidders, each with bid price derived from one Gaussian distribution and each bids only on the proportion of requests. So the one with higher bid price always win on the bids made by it while the other won only winds a proportion of bids i.e. when the earlier bidder doesn’t bid. So the overall distribution of winning price will look like as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*V-mndCgOGRIsfoVoaqhDlA.png" /></figure><p>RTB1 = Green</p><p>RTB2 = Red</p><p>RTB1 has higher mean bidding price, around $18 CPM but has lower variance, whereas RTB2 has lower mean bidding price of approximately $11 CPM but has higher variance. Now given a bid price we can get an estimate of winning rate over a long run.</p><ul><li><strong>So sometimes RTB2 wins since it bids more than RTB1 while other times it wins because RTB1 didn’t bid on those requests.</strong></li></ul><p>Issues:</p><p>Now to calculate all the known parameters and draw this distribution we will need to get a sample of data points from this distribution, in our case these are the winning bid price over a significant interval of time.</p><ul><li>In our case we never get to know the winning bid price if we lose the bid. Even if we win the bid many exchanges doesn’t reveal the second highest winning price since they don’t use Vickery auctions.</li><li>To use EM (Expectation Maximization) we should know how many RTBs are taking part in the auction, but we have on way of knowing the number ’n’ used in the pdf.</li><li>Another important issue is the temporal aspect of the distribution. It may happen that RTB1 or RTB2 stops bidding on the segment (may be their respective campaign targeting the segment finishes) or they increase the bidding rate, resulting a major change in the shape of the distribution. This kind of behavior is much expected in RTB environment.</li><li>So basically we can’t use the approach of analytically solving the Gaussian Mixture Model using Expectation Maximization.</li></ul><h3>Reinforcement Learning : Explore And Exploit</h3><p>To solve the above defined mixture model we will be using a variant of a technique known as <a href="http://en.wikipedia.org/wiki/Reinforcement_learning">reinforcement learning</a> that works via allocating some fixed amount of resources to exploration of the optimal solution and spends the rest of the resources on the best option. After spending due time on various explore and exploit techniques like <a href="http://en.wikipedia.org/wiki/Multi-armed_bandit">Multi Arm Bandit</a>,<a href="https://www.chrisstucchio.com/blog/2013/bayesian_bandit.html">Bayesian Bandits </a>etc I settled on using <a href="http://artint.info/html/ArtInt_266.html">Boltzmann Exploration</a> / <a href="http://en.wikipedia.org/wiki/Simulated_annealing">Simulated Annealing</a> technique.</p><h3>Bidding Algorithm : Bayesian Bandits</h3><p>We will be using Bayesian Bandit based approach using Thompson sampling for selecting optimal bandit [5]. Though bayesian bandits are mostly used in A/B testing and ad selection based on CTR, according to our research their usage suits the requirements and dynamics of RTB environment. In [6] the authors compares the performance of Bayesian Bandit techniques with other bandit algorithms like UCB, epsilon greedy etc with the aim of selecting best ad to deliver to maximize CTR. All the referred researches show that Bayesian Bandit based method outperforms other bandit techniques w.r.t. total regret, proportion of best armed played, and convergence time and readily converges to best choice/action in the explore-exploit dilemma.</p><p>Please go through the references 3, 5 and 6 for getting comprehensive look into bandit based techniques. Henceforth I will be explaining the application of Bayesian Bandit method to RTB bidding skipping the underlining theoretical details.</p><p>As described in earlier section (titled win price distribution) that the distribution of win rate and bidding price can be a mixture distribution with latent parameters. Since we will never know the winning price of a lost bid we can’t solve this optimization problem in more of an closed form analytical way. Therefore we will try to discover the optimal bid price to get the desired win rate by exploring the bid price space.</p><p>Let’s say a campaign has <em>cpm of $5</em>.<strong><em> We will divide the bid price space into different bins</em> </strong>as follows <em>[$1, $1.5, $2, $2.5, $3, $3.5, $4, $4.5]</em>. Now we will explore over these bins to discover the corresponding win rate.</p><p><strong>Experiment Scenario :</strong></p><p><strong>Scenario 1:</strong></p><p><strong>RTBS: </strong>We have 3 hypothetical RTBS bidding on a particular segment, each generating bid price via a Normal Distribution with the following bid parameters</p><p>RTB1: mean bid price = $3, standard deviation = $0.1, proportion of bids placed on incoming requests = 70% i.e. on an average this rtb bids on 70% of all requests sent by the exchange</p><p>RTB2: mean bid price = $4, standard deviation = $0.1, proportion of bids placed on incoming requests = 50%</p><p>RTB3: mean bid price = $5, standard deviation = $0.1, proportion of bids placed on incoming requests = 30%</p><p>Target Win Rate required by our test campaign = 40%</p><p>CPM = $5</p><p>Given a list of bid price choices from <em>[$1, $1.5, $2, $2.5, $3, $3.5, $4, $4.5] bins </em>the aim of the algorithm is to find the bin where the win rate is closest to 40%.</p><p><strong>Examples :</strong></p><ul><li>Now if we bid at $3.5 cpm then the probability of winning will be = (probability that RTB3 doesn’t bid on that request) * (probability that RTB2 doesn’t bid at that request)<br>= (1–0.3) *(1–0.5) = 0.35<br>i.e. if we bid $3.5 we will win 35% of the time.</li><li>On the other hand if we bid $4 cpm then out probability of winning is = (probability that RTB3 doesn’t bid on that request) * (probability that RTB2 bid less than $4 at that request) + (probability that RTB3 doesn’t bid on that request) * (probability that RTB2 doesn’t bid at that request)<br>= (1–0.3) * 0.5 * 0.5 + (1–0.3) *(1–0.5)<br>= 0.175 + 0.35<br>=0.525<br>i.e. If we bid at $4 we will be winning 52.5% of the time.</li></ul><p>Since the required win rate is 40% and bid price of $3.5 is giving us the win rate closest to the target win rate the algorithm should win most of the bids at $3.5</p><p><strong>Experiment Results:</strong></p><p>I did a simulation of the above defined scenario for 400 trials. At each request the algorithm selects a bid bin/bucket based on its assessment of win rate of that bin. Closer the win rate of the bin is to target win rate more bids will be made at that price. After each bid the algorithm will update the winning probability. After some trials the algorithm will get more and more confident about its assessment of the win rate of each bid price and will finally select the best bid price for all further bids.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*0bdvPF8dPE5vKEtmvlQkNA.png" /><figcaption>Figure 1.1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*rZz6jrvSaHQTqgIqcc6Ggw.png" /><figcaption>Figure 1.2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*rwhYcGCg8uTnM7GT8QqZKA.png" /><figcaption>Figure 1.3</figcaption></figure><p>Figure 1.1 shows that for some initial runs (around 100 bids) the algorithm had enough information to make intelligent guesses about winning rate of each bid price. Once the exploration phase is over the algorithm was selecting $3.5 cpm as the bid price over and over. Figure 1.3 depicts that out of 400 bids around 225 bids were made at $3.5. The interesting aspect of the Bayesian bandit is that once the algorithm has enough confidence about the estimates of winning probability for each bid price, it was selecting $3.5 over and over (after bid #150, bid $3.5 was selected almost every time).</p><p><strong>Issues with the Algorithm:</strong></p><p>At each bid the algorithms updates the <a href="http://en.wikipedia.org/wiki/Beta-binomial_distribution">Posterior Distribution </a>of the win probability of the corresponding bid price. As more and more bids take place and the algorithm’s Beta Posterior estimates converges, the variance of the posterior will be low and accurate predictions of the win rate will be made. Since the bidding environment is dynamic i.e. a new rtb can enter or an old rtb can leave the bidding process thereby changing the winning probability at some particular bid price, our algorithm will not be able to adopt to this change. The reason being that our posterior variance is too low and we have grown pretty much confident in our estimates.</p><p><strong>Scenario 2:</strong> A new RTB enters the bidding process after 300 trials. By this time our algorithm had drawn win estimate for each bid price and has grown pretty confident about them but this new RTB will change the real win rate at $3.5 cpm bid. Now this bid will not be optimal choice for us.</p><p>RTB4: mean bid price = $3.5, standard deviation = $0.01, proportion of bids placed on incoming requests = 90%</p><p>Now if we bid at $3.5 our win probability will be = (1–0.3) * (1–0.5) (1- 0.9) = 0.034, i.e. 3.4%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*ZurQTO8R5sXnmVKoNo92Iw.png" /><figcaption>Figure 2.1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*FuKSkoDJ_7PtmFI1anYzNg.png" /><figcaption>Figure 2.2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*JcbjOodlVC7CRKwFfhFb_Q.png" /><figcaption>Figure 2.3</figcaption></figure><p>Figure 2.3 shows that as soon as RTB 4 enters the bidding process we stopped winning at $3.5 price. But since the algorithm will try to keep on believing that win rate is optimal for this bid price (think of it in terms of inertia or momentum) it will keep on bidding at $3.5. But with time it will lose the inertia and started selecting $4 cpm (after iteration 400). But overall this algorithm takes too much time to adapt to the new scenario.</p><h3>Restless Bandit And Variance Inflation</h3><p>To tackle the issue of dynamic environment described in the last section, I experimented with a technique called variance inflation. As we saw in last experiment that the Bayesian Bandit technique was able to continuously pick the best bid price for an ad request just after around 100 overall bids. As we select the optimal bid price more often the variance of posterior beta will decrease. This means that our algorithm is learning continuously and becoming more and more confident about its choice. But as soon as the environment changed e.g. a new RTB bidding more than our optimal bidding price entered the bidding environment we will start losing all the bids. But it took us around 200 lost bids to learn that the current bid price is stale and that we should select some other bid price. In a way after losing hundreds of bid our algorithm lost confidence (the distribution changed) in the bid price it thought was optimal.</p><p>To tackle this problem I started increasing the variance of win rate distribution associated with each bid price by 10% as soon as we have made 50 bids on that price. This means that as soon as our algorithm starts selecting one particular bid price more often for an segment we will decrease its confidence by 10 % and ask it to explore other bid price. If the environment doesn’t change then the exploration will result in wastage of resources since we will bid either higher price or lower price then the optimal price, but if the environment changes i.e. lets say some new rtb enters or leave the bidding environment or some existing rtb starts bidding higher or lower, our algorithm will grasp this change.</p><p><strong>Simulation Scenario:</strong></p><p>I made the appropriate implementation changes and created similar scenario as defined in last section. We have 3 RTBs bidding for a segment with following configuration</p><p>RTB1: mean bid price = $3, standard deviation = $0.1, proportion of bids placed on incoming requests = 70% i.e. on an average this rtb bids on 70% of all requests sent by the exchange</p><p>RTB2: mean bid price = $4, standard deviation = $0.1, proportion of bids placed on incoming requests = 50%</p><p>RTB3: mean bid price = $5, standard deviation = $0.1, proportion of bids placed on incoming requests = 30%</p><p>Target Win Rate required by our test campaign = 40%</p><p>CPM = $5</p><p>Given a list of bid price choices from <em>[$1, $1.5, $2, $2.5, $3, $3.5, $4, $4.5] bins </em>the aim of the algorithm is to find the bin where the win rate is closest to 40%.</p><p><strong>Objective : </strong>The bidding algorithm will find the optimal bid price i.e. $3.5 after some trials. From this point onwards our algorithm will bid on most of the requests at $3.5. But after 300 bids a new RTB, RTB 4 will enter the bidding domain. It will start bidding little more i.e. $3.6 than us. Now we will see compared to results posted in last section how fast will our new algorithm will adapt to this change and relearn the optimal bidding price.</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*2E2b1YWmfGLwWM2qvttSUg.png" /><figcaption>Figure 3.1</figcaption></figure><p>Figure 3.1 shows the over all bids made on X axis and #bids made for each bid price on Y axis. We can see that before bid #300 the optimal bid price was $3.5 and it was being used most of the time. At trial #300 a new RTB enters the bidding environment. From the above plot we can see that it took the algorithm only 20–30 trials to find that optimal bid price has changed from $3.5 to $4. Henceforth $4 bid price was selected most often.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*VkEdtvl4AnlD7RlU_S9d_A.png" /><figcaption>Figure 3.2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*HUQdJADSQ-Y7wIPHwEZv1g.png" /><figcaption>Figure 3.3</figcaption></figure><p>Figure 3.3 shows that the win rate for bid price $3.5 becomes nearly zero after trial #300 since RTB 4 was bidding at a higher price.</p><p>IPython Notebook:</p><p><a href="https://github.com/euclid1729/RTB_DYNAMIC_BID_PRICE">euclid1729/RTB_DYNAMIC_BID_PRICE</a></p><p><strong>References:</strong></p><ol><li><a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;cad=rja&amp;uact=8&amp;ved=0CDcQFjAB&amp;url=http%3A%2F%2Flabs.yahoo.com%2Ffiles%2Find0788-cui.pdf&amp;ei=bpgRVYHzG8SqgwTs4oG4BA&amp;usg=AFQjCNE111oxP2qkkKFlc0d_jhVRva2rrA&amp;sig2=O8QLZwDs5LAmfypguiRGNQ&amp;bvm=bv.89184060,d.eXY">Bid Landscape Forecasting in Online Ad Exchange Marketplace</a></li><li><a href="http://arxiv.org/pdf/1305.3011.pdf">Real Time Bid Optimization with Smooth Budget Delivery in Online Advertising</a></li><li><a href="http://nbviewer.ipython.org/github/msdels/Presentations/blob/master/Multi-Armed%20Bandit%20Presentation.ipynb">http://nbviewer.ipython.org/github/msdels/Presentations/blob/master/Multi-Armed%20Bandit%20Presentation.ipynb</a></li><li><a href="http://www.robots.ox.ac.uk/~parg/pubs/theses/MinLee_thesis.pdf">http://www.robots.ox.ac.uk/~parg/pubs/theses/MinLee_thesis.pdf</a></li><li><a href="https://www.escholar.manchester.ac.uk/api/datastream?publicationPid=uk-ac-man-scw:227658&amp;datastreamId=FULL-TEXT.PDF">DECISION MAKING USING THOMPSON SAMPLING</a></li><li><a href="http://drum.lib.umd.edu/bitstream/1903/12540/1/Gupta_umd_0117E_12914.pdf">Learning Techniques In Multi Armed Bandits</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26b6109d5d9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>