<?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 Shubham Krishna on Medium]]></title>
        <description><![CDATA[Stories by Shubham Krishna on Medium]]></description>
        <link>https://medium.com/@shubhamkrishna.ism?source=rss-3b774f062b84------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*N9vGTJ6ooqUzy5Ey</url>
            <title>Stories by Shubham Krishna on Medium</title>
            <link>https://medium.com/@shubhamkrishna.ism?source=rss-3b774f062b84------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:55:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhamkrishna.ism/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[Get Started with Machine Learning Faster Using Amazon SageMaker JumpStart]]></title>
            <link>https://medium.com/ml6team/get-started-with-machine-learning-faster-using-amazon-sagemaker-jumpstart-3386e01ff16a?source=rss-3b774f062b84------2</link>
            <guid isPermaLink="false">https://medium.com/p/3386e01ff16a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Shubham Krishna]]></dc:creator>
            <pubDate>Tue, 22 Aug 2023 09:28:41 GMT</pubDate>
            <atom:updated>2023-08-22T09:28:41.557Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_AlhCw8zmt47Mwful8nEw.png" /></figure><p>Machine learning is a powerful technology with the potential to transform businesses and industries. However, for newcomers, it can be a daunting and time-consuming endeavor. The process of learning the fundamentals, setting up the infrastructure, and understanding the intricacies of ML frameworks can be overwhelming.</p><p>To address these challenges and make machine learning more accessible and efficient for newcomers, Amazon Web Services (AWS) offers a service called <strong>Amazon SageMaker JumpStart</strong>. This offering is a part of the broader <strong>Amazon SageMaker</strong> ecosystem. It offers a range of additional tools and features. There are resources to help with tasks like data access, labeling, and processing. If you’re a data scientist or developer, then there are IDEs that assist in creating, training, fine-tuning, and deploying models. On top of that, there’s a variety of MLOps services and more to explore.</p><p>SageMaker JumpStart is designed to cater to individuals who lean towards <strong>minimal coding (low code)</strong> and those who aim to steer clear of coding altogether (<strong>no code</strong>). It also benefits seasoned machine learning practitioners and individuals aiming to rapidly develop proof of concepts. It provides a curated collection of resources and tools, including solution templates, built-in algorithms and pre-trained models, foundation models, and others<strong>. </strong>SageMaker Jumpstart provides two ways to interact with its features:</p><ul><li><strong>SageMaker Jumpstart User Interface</strong>: A graphical interface for a user-friendly experience.</li><li><strong>SageMaker Python SDK</strong>: For more control and customization through code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*k-rrqVINi8yGZllt.jpg" /></figure><h4>Solution Templates</h4><p>With SageMaker JumpStart, you have access to pre-built solutions designed for common machine learning tasks. The solutions cover various tasks like demand forecasting, credit rating prediction, fraud detection, document analysis, predictive maintenance and others. The solution templates are seamlessly integrated with a range of AWS services, enabling effortless deployment through a single click. They use AWS CloudFormation templates for quick deployment, allowing complete customization of infrastructure resources like VPCs, subnets, gateways, EC2 instances, and others.</p><h4>Pre-trained models and Built-in algorithms</h4><ul><li><strong>Deploy pre-trained models for common ML tasks: </strong>SageMaker JumpStart simplifies solving common machine learning tasks without any development effort. It offers easy deployment of over 350 pre-trained models from the machine learning research community, spanning 15 popular tasks like object detection, text classification, and text generation. These models, sourced from TensorFlow, PyTorch, Hugging Face, and MXNet Hub, allow users to leverage the latest advancements in machine learning for their projects effortlessly.</li><li><strong>Finetune pre-trained models or use built-in algorithms : </strong>SageMaker<strong> </strong>JumpStart also provides easy fine-tuning of models on your datasets without writing your own training algorithm. You’ll save on training costs compared to starting from scratch. With SageMaker Jumpstart, built-in algorithms such as LightGBM, CatBoost, XGBoost, and Scikit-learn, also require no coding to start running experiments. SageMaker Jumpstart provides you notebooks that already contain instructions on how to use the algorithms or finetune pre-trained models on your data. The only inputs you need to provide are the data, hyperparameters, and compute resources. This allows you to run experiments more quickly, with less overhead for tracking results and code changes.</li></ul><h4>Foundation Models</h4><p>SageMaker JumpStart now also offers a wide range of<strong> state-of-the-art foundation models </strong>such as Llama-2, Falcon, Stable Diffusion and others catering to diverse use cases like content writing, code generation, question answering, copywriting, summarization, classification, and information retrieval. It offers access to both publicly available and proprietary<strong> </strong>foundation models. One can either deploy them directly out of the box or finetune on custom data and then deploy it.</p><p>Note: <strong>AWS Bedrock</strong> presents an additional option to access foundation models, including those developed by Amazon, a feature not found in SageMaker Jumpstart. Furthermore, Bedrock relieves you from deployment worries, whereas SageMaker Jumpstart requires you to handle deployment. For Bedrock, this means users don’t have control over data encryption and privacy, security concerns and others. So, you should verify whether the Bedrock’s data handling practices and encryption mechanisms meet your stringent security demands. As of writing this blog post, Bedrock is still in its preview phase. A detailed comparsion between Bedrock and SageMaker can be found in the blogpost: <a href="https://dev.to/aws-builders/amazon-bedrock-vs-amazon-sagemaker-understanding-the-difference-between-awss-aiml-ecosystem-5364">Amazon Bedrock vs Amazon SageMaker: Understanding the difference between AWS’s AI/ML ecosystem</a>.</p><h4>Example of Finetuning with SageMaker Jumpstart</h4><p>To illustrate the practical usage of SageMaker Jumpstart, let’s explore a concrete example. We will walk through an example where we finetune the distill-bert-base-uncased language model on SST-2dataset for <strong>Text Classification</strong>.</p><p><strong>Note</strong>: To begin with, it is important to verify that the dataset conforms to SageMaker Jumpstart’s expected format based on the task you have chosen. Regarding <strong>Text Classification</strong>, the input should be a directory containing a <strong>data.csv</strong> file inside a <strong>AWS S3 bucket.</strong> This <strong>data.csv </strong>file should comprise two columns:</p><ol><li>The first column must contain integer class labels ranging from 0 to the total number of classes.</li><li>The second column should contain the corresponding text data.</li><li>The file should not have any header.</li></ol><p>So, in the end your “data.csv” should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvjmTRII2DJiRFSdCrUXRg.png" /><figcaption>Fig. 1. Example of how custom dataset should look like</figcaption></figure><p><strong>Using Sagemaker Jumpstart UI for Finetuning</strong></p><p>If you’d rather steer clear of complicated coding, no problem at all! Say hello to a new level of convenience: the Sagemaker Jumpstart UI. It’s your shortcut to fine-tuning models, all with some simple clicks of your mouse. The first step is to look up the specific model you want to work with. You’ll find a handy search bar right there, where you can simply type in the name of the model you’re interested in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s2OMILFU70tk9LMjhHJx8A.png" /><figcaption>Fig. 2. Searching Model in SageMaker Jumpstart UI</figcaption></figure><p>Once you have selected the model, all that is left to do is fill in some parameters:</p><ul><li><strong>Data Source</strong>: Location of your training dataset.</li><li><strong>Hyperparameters:</strong> Epochs, batch-size, learning rate and others.</li><li><strong>Deployment Configuration</strong>: Machine type for training the model (e.g. ml.g4dn.xlarge), Model name and others.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*RD4_Iutfmvw5eBjtlL8lxA.png" /><figcaption>Fig. 3. Finetuning Model using Jumpstart UI</figcaption></figure><p>After providing the configuration, all you have to do is click on the <strong>Train</strong> button and model will be finetuned. The Sagemaker Jumpstart UI doesn’t specify the precise costs involved in model fine-tuning, and it also doesn’t offer specific time estimates for the fine-tuning process. However, you’ll come across a message in the UI that informs you about the ongoing training job progress.</p><p><strong>Utilizing SageMaker Python SDK</strong> <strong>for Finetuning</strong></p><p>SageMaker Jumpstart also provides a SageMaker notebook where one can finetune the model programmatically with the SageMaker API on the managed SageMaker service. All the code for finetuning is already present there and one just needs to change the values for the <strong>Data Source</strong>, <strong>Hyperparameters, Deployment Configuration </strong>and others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYCUbOLpPe2u02OrdQjbmw.png" /><figcaption>Fig. 4. Snapshot of setting parameters</figcaption></figure><p>The SageMaker notebook is well-documented and easy to follow, so you can get started with minimal learning curve. However, do bear in mind that certain factors such as batch size, learning rate, and evaluation metrics might potentially necessitate a certain level of familiarity with machine learning concepts. Once you are done, all you have to do is execute the cell containing the training job which looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38Dp7Jh82U1tduWMLBukGg.png" /><figcaption>Fig. 5. Snapshot of Jupyter Notebook containing the training job</figcaption></figure><p>In Fig. 5, observe how the training code is wrapped within the Estimator Class. You need to provide parameters like model_uri and hyperparameters and others — a convenient approach, for those seeking a hassle-free training experience without the need for in-depth expertise. Nevertheless, this convenience comes with a trade-off: certain finer details such as custom loss function, criteria for early stopping, and others have been abstracted, limiting your ability to make extensive modifications within the training process.</p><p>An interesting feature of SageMaker Jumpstart is its capability to log various metrics, such as training loss, validation loss, and more. Moreover, it automatically generates plots for these metrics, relieving you of any concerns about visualizing the fine-tuning progress. This seamless visualization makes SageMaker Jumpstart a truly user-friendly tool for model development and evaluation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hQp6bjFeT_ixVOaKquoj8w.png" /><figcaption>Fig. 6. Snapshot of Plots for metrics from SageMaker Jumpstart</figcaption></figure><p>After the fine-tuning process is finished, SageMaker JumpStart offers valuable information about the model, including details such as the parent model, training job name, training time, and output path. The output path is where you can find your new model in an Amazon S3 bucket. The folder structure uses the model name that you provided and the model file is in an /output subfolder and it&#39;s always named model.tar.gz . JumpStart utilises SageMaker services for deploying the model and establishing an endpoint that facilitates inference. You can select the deployment configuration such as machine type, security settings (e.g. VPC, Encryption keys) for hosting your model.</p><h4>Conclusion</h4><p>SageMaker Jumpstart provides a user-friendly interface that caters to individuals with minimal coding experience (low code), those without any coding background (no code) and for individuals looking for quick prototyping or developing proof of concepts. So, whether you prefer deploying existing pre-trained models or fine-tuning pre-existing models without delving deep into training process, SageMaker Jumpstart is a right tool for running those experiments. This saves time and costs compared to starting from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*r0ORVP-yy_w16FmU.jpg" /></figure><p>Although, SageMaker Jumpstart’s built-in algorithms, pre-trained models and solution templates provide convenience, they may not suffice for highly specialized or unique use cases that demand significant customization. Although it provides a notable selection of pre-trained models, it offers only specific NLP models sourced from HuggingFace and a limited set of Computer Vision models. Also, due to its low-code, no-code nature, certain complexities have been abstracted away, which means that while it offers convenience, you might not have complete control over all aspects of the process.</p><p>In essence, if you’re interested in getting started with machine learning, Amazon SageMaker JumpStart is a great place to start. To learn more, please visit the SageMaker JumpStart website: <a href="https://aws.amazon.com/sagemaker/jumpstart/">https://aws.amazon.com/sagemaker/jumpstart/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3386e01ff16a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/get-started-with-machine-learning-faster-using-amazon-sagemaker-jumpstart-3386e01ff16a">Get Started with Machine Learning Faster Using Amazon SageMaker JumpStart</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Whisper Deployment Decisions: Part I — Evaluating Latency, Costs, and Performance Metrics]]></title>
            <link>https://medium.com/ml6team/whisper-deployment-decisions-part-i-evaluating-latency-costs-and-performance-metrics-d07f6edc9ec0?source=rss-3b774f062b84------2</link>
            <guid isPermaLink="false">https://medium.com/p/d07f6edc9ec0</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[whisper]]></category>
            <dc:creator><![CDATA[Shubham Krishna]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 18:43:15 GMT</pubDate>
            <atom:updated>2023-07-21T18:43:15.911Z</atom:updated>
            <content:encoded><![CDATA[<h3>Whisper Deployment Decisions: Part I — Evaluating Latency, Costs, and Performance Metrics</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*AelLcRqiJ2iYe-oK.jpg" /></figure><h3>Introduction to Whisper</h3><p>In September 2022, OpenAI introduced Whisper, a robust speech recognition model trained on diverse audio data. Its multitasking capabilities support tasks like multilingual speech recognition, speech translation, and language identification. With 10 models of varying sizes and capabilities, Whisper offers a versatile and effective solution for speech recognition requirements.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c09f32052bbb842167b6985ab4e2b03/href">https://medium.com/media/8c09f32052bbb842167b6985ab4e2b03/href</a></iframe><p>While numerous articles cover training, fine-tuning, and explaining the paper behind Whisper, there is a scarcity of resources focusing on running Whisper in a production environment.</p><p>Deploying into production requires a thorough consideration of three major factors:</p><p>💪 Performance metrics</p><p>⏱️ Latency</p><p>💰 Deployment cost</p><blockquote><strong>Embarking on a two-part blog series</strong>, we delve into the practicalities of implementing Whisper in a production environment. <strong>In the first part</strong>, we navigate the <strong>tradeoffs between model sizes and GPUs</strong>, shedding light on optimal choices. The <strong>sequel</strong> takes a closer look at the transformative effects of tools and techniques like <strong>JAX, ONNX, and KernlAI </strong>on these metrics.</blockquote><h4>Benchmarking Performance Metrics of Whisper Models</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F43.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F43%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf93252633d2bcce2fbf9740d8485fa6/href">https://medium.com/media/cf93252633d2bcce2fbf9740d8485fa6/href</a></iframe><blockquote>According to Fig. 1, it is evident that <strong>larger models exhibit superior performance</strong>, as indicated by their <strong>lower word error rate</strong>. Therefore, if your primary objective is to attain <strong>optimal performance</strong> without concerns about latency and cost, opting for the <strong>largest model</strong> would be the <strong>ideal choice</strong>.</blockquote><p>While larger models typically offer better performance, their impact on latency and cost must be taken into account. Finding the right balance is crucial for an informed decision.</p><h4>Benchmarking Inference Speed of Whisper Models</h4><p>Using HuggingFace’s 🤗 Whisper implementation, we benchmarked multilingual models across different batch sizes (1,2,4,8,and 16) on CPUs and GPUs (T4,V100,and A100) to evaluate inference speed. All the benchmarks were done on the test split of the HuggingFace 🤗 dataset: librispeech_asr.</p><blockquote><strong>Note</strong>: Missing bars/points means that we were not able to run the inference because of Out-of-Memory issue.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F23.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F23%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0d5e6ecd499872ca44f6068b7004f20/href">https://medium.com/media/a0d5e6ecd499872ca44f6068b7004f20/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F51.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F51%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/69fc8b66655b4f1b9be2693463481c05/href">https://medium.com/media/69fc8b66655b4f1b9be2693463481c05/href</a></iframe><p>The following observations can be easily derived from Fig. 2 and Fig. 3:</p><ul><li>As the size of the model increases, the inference time becomes slower since larger models have more parameters.</li><li>Running Whisper on CPUs is noticeably slower compared to using GPUs.</li><li>Irrespective of the model size, the inference time is the quickest on A100.</li><li>For a batch size of 1, Whisper models are faster on T4 than P100. However, for batch sizes &gt; 1, only tiny and small models are faster on T4.</li><li>Batching data for inference results in faster processing compared to a batch size of 1, where no batching is involved.</li></ul><h4>Benchmarking Cost of Running Whisper Models</h4><p>We benchmarked the cost of transcribing 5 hours of audio using different Whisper models on different GPUs which is presented below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F29.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F29%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a7f49e1350f35e6f50a7cbbc603a9e1/href">https://medium.com/media/2a7f49e1350f35e6f50a7cbbc603a9e1/href</a></iframe><p>Fig. 4 highlights a <strong>positive correlation between faster GPUs </strong>and<strong> </strong>increased<strong> cost</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F48.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F48%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce688996f3dbbaca85b00b695ee198b5/href">https://medium.com/media/ce688996f3dbbaca85b00b695ee198b5/href</a></iframe><p>Similar trends were observed in the cost of batching vs. non-batching inference, regardless of the GPU used. To gain insights into cost and inference speed, Fig. 6 illustrates the tradeoff between the average inference time for a 30-second audio sample and the cost of running it on a virtual machine in Google Cloud.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F27.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F27%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/af6b9098772efb89c551122795f54a27/href">https://medium.com/media/af6b9098772efb89c551122795f54a27/href</a></iframe><p>Fig. 6. shows that the Tesla T4 GPU has the lowest cost per hour, while its inference speed is only slightly slower than the Tesla P100 GPU. The Tesla A100 GPU is the fastest, but its price is significantly higher than the other two GPUs.</p><h4>Conclusion</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1jpN1cI8Hix5_i41YzzvNg.png" /><figcaption>Fig. 7. Best choice of GPU/CPU based on Latency and Deployment Cost for online setting.</figcaption></figure><p>To sum it up: The <strong>T4 GPU emerges as the optimal choice</strong> for supporting <strong>any Whisper model </strong>(except Whisper large-v2)<strong> </strong>in <strong>online</strong> (Batch-size = 1) and <strong>batch</strong> settings. It offers a <strong>cost-effective solution</strong> compared to the <strong>P100</strong> and <strong>A100</strong> GPUs. Despite the P100’s superior speed in batch settings compared to the T4, the tradeoff of higher costs makes it a less economical choice.</p><p><strong>What’s next?</strong> Stay tuned for the highly anticipated second part of this blog post series, where we will delve deep into <strong>different optimizations</strong>. Discover how these optimizations can significantly impact crucial aspects such as latency, deployment costs, and overall performance metrics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d07f6edc9ec0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/whisper-deployment-decisions-part-i-evaluating-latency-costs-and-performance-metrics-d07f6edc9ec0">Whisper Deployment Decisions: Part I — Evaluating Latency, Costs, and Performance Metrics</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenVINO vs ONNX for Transformers in production]]></title>
            <link>https://medium.com/ml6team/openvino-vs-onnx-for-transformers-in-production-3e10c01520c8?source=rss-3b774f062b84------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e10c01520c8</guid>
            <category><![CDATA[onnx]]></category>
            <category><![CDATA[openvino]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Shubham Krishna]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 07:20:52 GMT</pubDate>
            <atom:updated>2022-10-17T07:20:52.050Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*wFLpQ8cEEzvOOFiE.jpg" /></figure><p>Transformers has revolutionized NLP, making it the first choice for applications like machine translation, semantic search engines, and more. Considering that transformers contain millions of parameters, efficiently serving them can be challenging. Deploying into production requires a thorough consideration of the three factors listed below:</p><p>⏱️ Latency</p><p>💰 Deployment cost</p><p>💽 Memory</p><p>With the help of GPUs (Graphics Processing Unit), which were originally designed to accelerate graphics processing, deep learning computations can be sped up dramatically. But GPUs are quite expensive 💸, so if you have a budget constraint, you will have difficulty finding an efficient deployment that is still fast enough ⏱️ for production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*vA-n2RlgOwalMdQa.gif" /></figure><blockquote>Our team at ML6 is always looking for solutions that will facilitate the efficient deployment of large models like transformers.</blockquote><p>The CPU is ubiquitous and can be a more cost-effective option for running AI-based solutions than a GPU. Therefore, we’ll look at different approaches to optimize transformer models for CPU inference.</p><h4>What is Quantization ? How does it help?</h4><p>Quantization refers to techniques for computing and storing tensors with lower bitwidths than floating point precision. To put it simply, quantization refers to the mapping of input values from a large set to output values in a smaller set. A neural network consists of activation nodes, connections between nodes, and weight parameters associated with each connection. It is these weight parameters and activation node computations that can be quantized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*IoSTBtnaD6q6j9bt.gif" /></figure><p>👉 In a neural network, using lower bits parameters, and quantized intermediate calculations produces large performance gains.</p><p>👉 Another benefit of quantization is that it can lead to lower network latency and better power efficiency. As a result of using lower-bit quantized data, there is less data movement to and from the chip, which reduces memory bandwidth and saves significant energy, thus making it more environmentally friendly.</p><p>👉 Although quantization brings benefits, it also has a downside that neural networks can lose accuracy since they don’t represent information precisely.</p><blockquote>TLDR; It has been shown that quantization can often result in a very minimal loss of accuracy, especially when weighed against the improvements in latency, memory usage, and power.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*S9QlOOgQrap9EALH.gif" /><figcaption>Fig. 1 How Quantization helps [1]</figcaption></figure><h4><strong>Different Types of Quantization</strong></h4><p>There are mainly two types of quantization:</p><ul><li><strong>Post-training quantization</strong>: The term Post-training quantization refers to the process of quantizing a model that’s already trained. The quantized model is what ultimately gets deployed and used to perform inference.</li><li><strong>Quantization-aware training</strong>:<strong> </strong>Quantization-aware training relies on the idea that the errors associated with quantization will accumulate in the total loss of the model during training, and the optimization algorithm will adjust parameters accordingly and reduce the overall error.</li></ul><blockquote><strong>Note</strong>: Within this blogpost, we will only look into accelerating transformers using Post-training quantization, with a special focus on using OpenVINO to accomplish this.</blockquote><h4>Quantization and hardware integration</h4><p>In practice, quantization is tightly coupled with hardware as different hardware platforms have varying levels of support for quantization. For example, Intel CPUs with x86 architecture prefer the input data types of the quantized conv2d to be UINT8×INT8 due to the Intel Vector Neural Network Instructions (VNNI) requirement [2].</p><p>Similarly, CPUs in ARMv8 architecture have special instructions to accelerate the INT16 multiply-accumulate, while ARMv8.2 CPUs introduce DOT instruction to directly speed up INT8 multiply-accumulate [3].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*A1dQj-UjX7NKhW5a.gif" /></figure><p>Taking a model from development to production requires a change of software framework to achieve the best results in order deploy on the most suitable target hardware. Popular machine learning frameworks like PyTorch or TensorFlow do support Post-training quantization, but there are more suitable options to deploy on CPUs for real-time applications.</p><p>We will look into two highly optimized frameworks that provide Post-training quantization that aim to accelerate transformers drastically:</p><ol><li><strong>ONNX Runtime</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/0*JrTAMeSCSuGL4yql" /></figure><p>ONNX Runtime is a cross-platform machine-learning model accelerator, with a flexible interface to integrate hardware-specific libraries. We have covered quantization and acceleration using ONNX Runtime in another blogpost:<strong> </strong><a href="https://blog.ml6.eu/bert-is-eating-your-cash-quantization-and-onnxruntime-to-save-ea6dc84dcd88"><strong>BERT is eating your cash: quantization and ONNXRuntime to save💰</strong></a>[4].</p><p>2. <strong>OpenVINO</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/0*u07OV52f8T7o8q-y.png" /></figure><p>The OpenVINO toolkit (Open Visual Inference and Neural network Optimization) is an open-source toolkit facilitating the optimization of a deep learning model from a framework and deployment using an inference engine onto <strong>Intel hardware like CPUs</strong>. It has also been developed with a similar mindset to ONNX and ONNXRuntime — allowing a bridge from development to production and enable representation in a framework agnostically.</p><h4><strong>Model optimization using OpenVINO</strong></h4><p>Model optimization involves improving final model performance by applying optimization methods such as quantization, pruning, preprocessing optimization, etc.</p><p>OpenVINO provides several tools to optimize models at different steps of the model development lifecycle:</p><ul><li>The <strong>Model Optimizer</strong> provides a number of optimizations to a model, most of which are added by default, but you can configure mean/scale values, batch size, RGB vs BGR input channels, and others to speed up preprocessing (<a href="https://docs.openvino.ai/latest/openvino_docs_MO_DG_Additional_Optimization_Use_Cases.html#doxid-openvino-docs-m-o-d-g-additional-optimization-use-cases">Embedding Preprocessing Computation</a>).</li><li>Using the <strong>Post-training Optimization Tool</strong> (<a href="https://docs.openvino.ai/latest/pot_introduction.html">POT</a>) one can optimize inference from deep learning models without the need to retrain the models or fine-tune them, for example by applying post-training 8-bit quantization methods.</li><li><strong>Neural Network Compression Framework</strong> <a href="https://docs.openvino.ai/latest/docs_nncf_introduction.html#doxid-docs-nncf-introduction">(NNCF)</a> provides a suite of advanced methods for training-time model optimization within the DL framework, such as PyTorch and TensorFlow. It supports methods, like Quantization-aware Training and Filter Pruning. NNCF-optimized models can be inferred with OpenVINO using all the available workflows.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8-0o7QmpcHLZVkHlRf3Gw.png" /></figure><p>The typical process for quantizing and accelerating a model using OpenVINO consists of following steps:</p><ol><li>Convert TensorFlow/PyTorch* Model to OpenVINO using Model Optimizer.</li><li>Quantize to INT8 using Post-training Optimization tool.</li></ol><blockquote>* <em>For PyTorch Model, you need to first convert to ONNX and then to OpenVINO</em>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BCK7-bGU2KchmLdL" /></figure><p>If you want to know more about the runtime inference optimization options provided by OpenVINO, please refer to the <a href="https://docs.openvino.ai/latest/openvino_docs_deployment_optimization_guide_dldt_optimization_guide.html">documentation</a>.</p><p>For converting an ONNX model to OpenVINO, execute the following command using command line interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21db44afe7222c2c69f663706f55e928/href">https://medium.com/media/21db44afe7222c2c69f663706f55e928/href</a></iframe><p>We couldn’t find any Python function for converting an ONNX model to OpenVINO.</p><p>In order to quantize toINT8 using OpenVINO, one first needs to have the model converted into OpenVINO format. Afterwards, we need to define a dataloader which takes in a dataset and a model that you want to quantize. The dataloader code can be found below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fad5a379089129510356ca052ee62920/href">https://medium.com/media/fad5a379089129510356ca052ee62920/href</a></iframe><p>After defining the dataloader, we need to code some extra steps that are required for quantizing the model. The code is attached below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05795f11739aa1116f17888babec13e1/href">https://medium.com/media/05795f11739aa1116f17888babec13e1/href</a></iframe><p>After executing main.pywe will get our INT8 quantized model.</p><h4>Benchmarking ONNX and OpenVINO on CPU</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*JJ0n2UjW0csr4xiP.gif" /></figure><p>To find out which framework is better for deploying models in production on CPU, we used the distilbert-base-uncased-finetuned-sst-2-englishmodel from HuggingFace 🤗. All the benchmarks were done on Intel Ice Lake Architectures with Intel(R) Xeon(R) CPU @ 2.80GHz(4 cores)processors having AVX-512 instruction set. We benchmarked both ONNX and OpenVINO quantized models for different sequence lengths and batch sizes.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F10.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F10%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7a2af0c5827196e328ed3116874de75/href">https://medium.com/media/d7a2af0c5827196e328ed3116874de75/href</a></iframe><ul><li>We can clearly see that ONNX and OpenVINO are equally good for different sequence lengths and batch-sizes.</li><li>We couldn’t observe any major difference between OpenVINO and ONNX Runtime benchmarks. Triton Inference Server has support for both OpenVINO and ONNX Runtime, which allows you to easily use and benchmark different backends for your models.</li></ul><h4>Long Story Short</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*TSr7MI_6vmLNVrYH.gif" /></figure><p>👉 ONNX and OpenVINO are highly optimized frameworks for deploying models on CPUs, making deployment budget friendly 💰.</p><p>👉 The performance of ONNX and OpenVINO are comparable. So no matter which framework you use, you are in good hands.</p><p>👉 Quantizing models using ONNX is bit easier compared to OpenVINO. Using HuggingFace 🤗 , one needs to write only few lines of code for quantization.</p><p>👉 Quantization works like a charm and definitely is one of the best techniques out there to speed up inference ⏱, and reduce model size 💽.</p><h4>References</h4><p>[1] <a href="https://www.qualcomm.com/news/onq/2019/03/12/heres-why-quantization-matters-ai">https://www.qualcomm.com/news/onq/2019/03/12/heres-why-quantization-matters-ai</a></p><p>[2]<a href="https://www.intel.com/content/www/us/en/developer/overview.html#gs.1305tu">https://www.intel.com/content/www/us/en/developer/overview.html#gs.1305tu</a></p><p>[3] <a href="https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/exploring-the-arm-dot-product-instructions">https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/exploring-the-arm-dot-product-instructions</a></p><p>[4] <a href="https://blog.ml6.eu/bert-is-eating-your-cash-quantization-and-onnxruntime-to-save-ea6dc84dcd88">https://blog.ml6.eu/bert-is-eating-your-cash-quantization-and-onnxruntime-to-save-ea6dc84dcd88</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e10c01520c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/openvino-vs-onnx-for-transformers-in-production-3e10c01520c8">OpenVINO vs ONNX for Transformers in production</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Triton Ensemble Model for deploying Transformers into production]]></title>
            <link>https://medium.com/ml6team/triton-ensemble-model-for-deploying-transformers-into-production-c0f727c012e3?source=rss-3b774f062b84------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0f727c012e3</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ml-in-production]]></category>
            <category><![CDATA[triton]]></category>
            <dc:creator><![CDATA[Shubham Krishna]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 08:33:26 GMT</pubDate>
            <atom:updated>2023-03-13T20:58:25.534Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ftf_Idtz3mDrPhdt-vcNPQ.png" /></figure><p>We all have witnessed the magic of Transformer-based models for a variety of NLP tasks including Name Entity Recognition (NER), Text Classification, etc.</p><p>However, the job isn’t over when we train a machine learning model that performs well on different datasets. In real life, a machine learning model can only add value to an organization when its insights are routinely made available to the users for whom it was designed.</p><p>The process of taking a trained ML model and making its predictions available to users or other systems is known as <strong>deployment.</strong></p><h3>What changes when we move from training to deploying models?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*oQAuLE9yCSqdT7z7.gif" /></figure><p>During the model development process, we train different iterations of our model multiple times, optimizing for metrics like <strong>loss</strong>, <strong>accuracy, precision, recall</strong>, etc.</p><p>But, when we move into <strong>deployment</strong> we have to think about additional aspects such as:</p><p>🙏 <strong>Client usability</strong></p><p>📦 <strong>Artifact version management</strong></p><p>✂️ <strong>Separation of concerns</strong></p><p>👨‍💻 <strong>Ease of deployment</strong></p><p>⏱ <strong>Latency</strong></p><p>💰 <strong>Usage Costs</strong></p><p>Aside from these topics, we need to think about how to host the model, what kind of infrastructure will be required, and others. We have to think about tools and frameworks that are better suited for deployment.</p><p>As for deploying a Transformer model, the complexity increases since besides the model one also needs to consider how to deploy the tokenizer. The questions that need to be answered are:</p><p>❓ Is it best to deploy the tokenizer on the server or to have the end users handle it?</p><p>❓What is the best way to deploy the tokenizer along with the model on the server so that inference latency and costs are minimized?</p><h3>So, How can we deploy Transformers?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*cwqcOy5AZYZvGiqW.png" /></figure><p>An open-source inference serving software called <a href="https://developer.nvidia.com/nvidia-triton-inference-server"><strong>Triton</strong></a>, developed by NVIDIA, can help us to standardize model deployment in a fast and scalable manner.</p><p>It provides ML Engineers, and Data Scientists the freedom to choose the right framework for their projects without impacting production deployment. It also helps developers deliver high-performance inference across cloud, on-premise, and edge devices.</p><blockquote>TL; DR<br>In other words, <em>Triton</em> checks off most of the additional metrics listed above.</blockquote><p>The process of deploying an optimized model on a Triton server can be broken down into two steps:</p><p>1. Convert the PyTorch/TensorFlow model to a serialized representation of model by using tools like tf2onnx, Torchscript or onnx. During this, one can further optimize the serialized representation by quantizing to FLOAT16.</p><p>2. Deploy the serialized representation onto a Triton server.</p><h3>Why one more blogpost about deploying models?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*4xP6ILT4DyuAF-P8.gif" /></figure><p>In this blogpost, we will introduce two alternatives to deploy Transformer models and tokenizers in production leveraging Nvidia Triton.</p><p>There are many articles on how to deploy a Computer Vision model to production, but the same is not true for NLP models. Through this blog post, we would like to contribute to the <strong>NLP in production</strong> community. This blog post is inspired by <a href="https://towardsdatascience.com/hugging-face-transformer-inference-under-1-millisecond-latency-e1be0057a51c">Hugging Face Transformer Inference Under 1 Millisecond Latency</a> , which goes into greater detail on the first step.</p><h3>Let’s talk about deploying NLP models</h3><p>Any Transformer model comprises two main artifacts:</p><ul><li><strong>Tokenizer</strong></li><li><strong>Model</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQldaC78weaIZ4YdZ_suag.png" /><figcaption><strong>Figure 1</strong>. Logical flow of getting prediction from a NLP Model</figcaption></figure><p>During inference, the tokenizer first needs to tokenize the text, after which the tokenized output is forwarded to the model for prediction.</p><p>This two-step process for getting predictions actually already hints two ways in which we can deploy a model onto a Triton server. The two ways are:</p><p>1) <strong>Client-side tokenization</strong>: in this approach, only the model is deployed on the server. The tokenization needs to be handled by the client on its own.</p><p>2) <strong>Server-side tokenization using</strong> <strong>Ensemble Model</strong>: in this approach, both the tokenizer and the model are packaged into one container and deployed on the server. An <a href="https://github.com/triton-inference-server/server/blob/main/docs/architecture.md#ensemble-models">ensemble model</a> represents a pipeline of one or more models and how the input and output tensors are connected between those models.</p><p>Ensemble models traditionally refer to combining multiple machine learning models for prediction. However, with the concept of ensembles one can cleverly treat pre-processing or/and post-processing logic as independent models on Triton as well. It all sounds wonderful but one can hardly find an example on how to exactly use this. While the <a href="https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md">documentation</a> describes how the config.pbtxt file should look like, an example of a working end-to-end ensemble model seems to be rare.</p><p>Figure 2 visualizes the difference between deployment of a NLP model via Client-side tokenization and Server-side tokenization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a5RoVLUly785rYka4NO-OA.png" /><figcaption><strong>Figure 2</strong>. Deployment difference: Client-side vs Server-side tokenization</figcaption></figure><h3>Ensemble Models in Action</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dv9PJfxwsqJ-bo7G.jpg" /></figure><p>Let’s use an NLP model called <a href="https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english"><strong>distilbert-base-uncased-finetuned-sst-2-english </strong></a>from ​HuggingFace 🤗​. This model is based on distillbert-base-uncased, fine-tuned on SST-2 and is used for Sentiment Analysis.</p><p>We carry out the first step of deploying the model onto a Triton Server by converting it to the onnx format and then optionally quantizing it toFLOAT16. For the final step, we need to configure the model repository and the config.pbtxt files. In the end, the structure should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/930025ff6ef6c3a11c0182ab541b033a/href">https://medium.com/media/930025ff6ef6c3a11c0182ab541b033a/href</a></iframe><p>From the structure above, we can see that the folder model_repository contains three different folders:</p><p>📁 ensemble_model: this subfolder contains an empty folder 1 indicating the version of the model and a config.pbtxt . The config.pbtxt contains the flow/logic of how an inference request is first passed to the tokenizer and then the tokenized output is passed to the model in order to get the final output. The config.pbtxt contains:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc77a13129e3892bcd29bfdfb7f85948/href">https://medium.com/media/bc77a13129e3892bcd29bfdfb7f85948/href</a></iframe><blockquote>If you want to learn in depth more about different arguments that can be used in config.pbtxt , read it on the <a href="https://github.com/triton-inference-server/server/blob/main/docs/model_configuration.md">official GitHub repository</a>.</blockquote><p>📁 model: this subfolder contains one folder 1 which contains the serialized representation of the model: distilbert-base-uncased-finetuned-sst-2-english.onnx. The config.pbtxt for this folder is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/344daacd9bfe3bb90e54584734ec2ea0/href">https://medium.com/media/344daacd9bfe3bb90e54584734ec2ea0/href</a></iframe><p>📁 tokenizer: this subfolder contains one folder 1 which has different files:</p><ul><li>📋 *.json and *.txt files are generated when one saves the tokenizer by using Autotokenizer.from_pretrained() from HuggingFace🤗.</li><li>📋model.py : contains the logic for invoking the tokenization of the text. For our case, it looks like this:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4de85d54c15b88333709a864eab2a28/href">https://medium.com/media/f4de85d54c15b88333709a864eab2a28/href</a></iframe><p>and the config.pbtxt for this folder is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0ad76deb556c4bc1a3c04b470bd7c0f/href">https://medium.com/media/b0ad76deb556c4bc1a3c04b470bd7c0f/href</a></iframe><h3>🚧 Client-side vs. 🏠 Server-side tokenization</h3><p>Both ways of deployment have their own set of pros and cons:</p><p>🙏 <strong>Client usability</strong>: with Server-side tokenization, you just need to send the text as a request, whereas for Client-side tokenization, you have to tokenize the text and then send the tokenized output as a request for inference.</p><p>📦 <strong>Artifact version management</strong>: Server-side tokenization enables better artifact version management capabilities compared to Client-side tokenization. The process of developing ML models is iterative, and at the end of a training run, two artifacts will be produced: a tokenizer (a bunch of files) and a model (a single file). If these artifacts are scattered across different places, it can become messy and error prone to link the correct tokenizer version to the correct model version.</p><p>✂️ <strong>Separation of concerns</strong>: with Server-side tokenization, the backend service, which interacts with model serving framework, takes care of the request and the business logic. It can be agnostic of the ML aspects. This doesn’t hold true for models deployed via Client-side tokenization.</p><p>👨‍💻 <strong>Ease of deployment</strong>: combining the tokenizer with the model in a single container makes the deployment of Server-side tokenization challenging. It becomes challenging because one has to define multiple config.pbtxt files and also properly structure the Triton model repository for a successful deployment. The lack of examples on the internet also makes it a bit difficult.</p><p>⏱ ️<strong>Latency</strong>: we benchmarked the inference time for both models deployed using Client-side tokenization and Server-side tokenization on a Tesla T4 GPU for different sequence lengths. We found the inference time for models deployed using Client-side tokenization to be faster than those for Server-side tokenization. We think that ensemble scheduling introduces an overhead which makes the inference slower for Server-side tokenization. However, we also think that if both methods were tested on a relatively large pool of text, each algorithm’s inference time would probably be comparable.</p><p>A detailed comparison of inference time can be found in figures 3 and 4.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F1.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F1%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0654beb2ee21f2314fe9dc352342e1f/href">https://medium.com/media/f0654beb2ee21f2314fe9dc352342e1f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eshubhamkrishna%2F3.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eshubhamkrishna%2F3%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/319916d8f8d7260a3e35d6f1282e256e/href">https://medium.com/media/319916d8f8d7260a3e35d6f1282e256e/href</a></iframe><p>💰 <strong>Usage Costs</strong>: It will be cheaper to deploy models with Server-side tokenization as one needs to send only one request per inference, whereas with Client-side tokenization, one needs to send two requests per inference. First, one needs to send the request to a tokenizer which is being served at a different endpoint. Second, the output from the tokenizer is sent as an additional request to the model in order to get final predictions.</p><h3>Long Story Short</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*E4ARCWt-3B7aWJSj.gif" /></figure><p>👉 Although deployments with Client-side tokenization are slightly faster, Server-side tokenization is a neater way to host NLP models. Deployment with Server-side tokenization gives a lot of freedom in serving the model end-to-end. Ensemble models can also incorporate custom pre-processing and post-processing logic.</p><p>👉 You need to be more vigilant in creating the model repository and the config files for deployments with Server-side tokenization. The flow of inputs and outputs of different models needs to be carefully designed.</p><p>👉 With Server-side tokenization, the client just needs to send the text for which the prediction is needed. However, with Client-side tokenization, the client must ensure that the tokenizer they implement is compatible with the model being served.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0f727c012e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/triton-ensemble-model-for-deploying-transformers-into-production-c0f727c012e3">Triton Ensemble Model for deploying Transformers into production</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>