<?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[Predibase - Medium]]></title>
        <description><![CDATA[A magazine collating articles about Predibase and Ludwig, the declarative machine learning framework. - Medium]]></description>
        <link>https://medium.com/predibase?source=rss----6792b5a79e9d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Predibase - Medium</title>
            <link>https://medium.com/predibase?source=rss----6792b5a79e9d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:49:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/predibase" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Predicting Customer Reviews with Multi-Modal Machine Learning]]></title>
            <link>https://medium.com/predibase/predicting-customer-reviews-with-multi-modal-machine-learning-25ffd40695ab?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/25ffd40695ab</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Abhay Malik]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 17:36:15 GMT</pubDate>
            <atom:updated>2023-03-13T17:36:14.958Z</atom:updated>
            <content:encoded><![CDATA[<h3>Predicting Customer Review Ratings on Multi-Modal Data with Predibase and Ludwig</h3><p><em>Watch our recent webinar to see this use case in action: </em><a href="https://go.predibase.com/hands-on-with-multi-modal-machine-learning-lp"><em>https://go.predibase.com/hands-on-with-multi-modal-machine-learning-lp</em></a><em>.</em></p><p>In this blog post, we will show how you can easily train, iterate, and deploy a highly-performant ML model on a multi-modal dataset using Predibase, the low-code declarative ML platform, and open-source Ludwig.</p><p>If you want to see this use case in action, make sure to watch the <a href="https://go.predibase.com/hands-on-with-multi-modal-machine-learning-lp">on-demand webinar</a> or request a <a href="https://predibase.com/request-early-access">demo</a> to learn more about the platform. If you’d like to follow along, you can use our OSS project Ludwig with a Jupyter Notebook <a href="https://colab.research.google.com/drive/1Tf1wjSzJWzGXH60Rgv7p_rkyuaPmD0h1?usp=sharing">here</a> and if you are new to Ludwig, feel free to check out our <a href="https://ludwig.ai/latest/getting_started/">quick tutorial.</a></p><h3>Predicting Customer Reviews with ML</h3><p>For today’s use case, we’ll take a look at the <a href="https://www.kaggle.com/datasets/nicapotato/womens-ecommerce-clothing-reviews?datasetId=11827">Women’s E-commerce Clothing Reviews dataset</a>. With a surge in e-commerce shopping in recent years, customer reviews have become an important factor in both understanding customer satisfaction as well as influencing customer demand. We’ll be using the e-commerce dataset to predict customer ratings from detailed reviews. With this information, organizations can proactively reach out to dissatisfied customers or improve products before negative reviews start to amass. This use case can also be easily modified into a product recommendation or product sentiment use case directly within the Predibase platform depending on what you’re interested in predicting.</p><p>The dataset itself contains over 20k rows of real, anonymized reviews for women’s clothing in the e-commerce industry. In addition, this multimodal dataset includes a wide variety of feature types including categorical, numerical, and text features. These features include the age of the reviewer, product department, text description of the reviews, and the number of other users who found this review helpful. This set of wide-ranging features makes this use case a great fit for a platform like Predibase, which allows you to leverage all your structured and unstructured data to train cutting-edge ML models.</p><p>The ML task we’ll investigate will be to predict the number of stars (from 1 through 5, where 5 indicates the best score) of a given review. Since we will treat this rating score as a numerical value, this is a regression task and we’ll choose a corresponding performance metric of R2.</p><p>So without further ado, let’s dive in!</p><h3>Connecting to Structured and Unstructured Data</h3><p>Predibase allows you to instantly connect to your cloud data sources, pulling in all your data — including tabular, text, images, audio, and more — wherever it may live. For today’s example, the Women’s Clothing Review dataset is included in the out-of-the-box Ludwig datasets which makes it just a few clicks to pull it into Predibase.</p><p>If you’re following along with Ludwig, follow the instructions in the <a href="https://colab.research.google.com/drive/1Tf1wjSzJWzGXH60Rgv7p_rkyuaPmD0h1?usp=sharing">notebook</a> to download the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xa6qXi2nlQdO1dBz" /></figure><p>Predibase makes it easy to try out a variety of datasets out of the box.</p><h3>Getting our first ML models trained</h3><p><strong>Phase 1 — Train Model Baselines</strong></p><p>Now that we have our data in Predibase, let’s continue to the exciting part of training models!</p><p>One of the benefits of a tool like Predibase is the ability to quickly establish baselines for a given dataset and task. When you are first analyzing a dataset, you may not immediately know if an ML-based approach could be useful, let alone what initial results you can expect to see. Built on top of Ludwig’s data-centric configuration approach, Predibase makes it easy to train your first baseline models. Let’s see this in action by training Neural Networks and Tree-based models.</p><p><strong>Default Neural Network Model</strong></p><p>Configuration</p><pre>input_features:<br>  - name: Clothing ID<br>    type: number<br>  - name: Age<br>    type: number<br>  - name: Recommended IND<br>    type: binary<br>  - name: Positive Feedback Count<br>    type: number<br>  - name: Division Name<br>    type: category<br>  - name: Department Name<br>    type: category<br>  - name: Class Name<br>    type: category<br>output_features:<br>  - name: Rating<br>    type: number<br>model_type: ecd</pre><p><strong>Default Neural Network Configuration</strong></p><ul><li>Training R2: 0.4921</li><li>Test R2: 0.4896</li></ul><p><strong>Default Gradient-boosted Tree Model</strong></p><p>Configuration</p><pre>input_features:<br>  - name: Clothing ID<br>    type: number<br>  - name: Age<br>    type: number<br>  - name: Recommended IND<br>    type: binary<br>  - name: Positive Feedback Count<br>    type: number<br>  - name: Division Name<br>    type: category<br>  - name: Department Name<br>    type: category<br>  - name: Class Name<br>    type: category<br>output_features:<br>  - name: Rating<br>    type: number<br>model_type: gbm</pre><p><strong>Default Gradient-boosted Tree Model Configuration</strong></p><ul><li>Training R2: 0.6619</li><li>Test R2: 0.6141</li></ul><p>Before moving on, let’s highlight a few key points.</p><p>To get started with Ludwig, all you have to do is specify your input and output features in a configuration-driven manner–in this case, YAML–to start to train your baselines. Predibase simplifies thmodeling process even further, reducing the process to arrive at a trained model, with just a few clicks.</p><p>In addition, one of the unique advantages you get is the ability to train both deep learning and tree-based models at the same time. This provides you with more confidence in the results of your baselines and serves as a starting options for future iteration. Below, we see the two models have varying performance which suggests there may be some room for improvement.</p><p>Default Neural Network. R2: 0.4896</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UNsj-bPRa9YOgW8u" /></figure><p>Default GBM Model. R2: 0.6141</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p5vxAGtHRJUyefvu" /></figure><h3>Iterating Models to Success</h3><p>With real-world machine learning, it’s rarely the case that the first model we train will be our final model. There are typically many iterations of exploration before converging on a model that meets our performance criteria while ensuring the model performs well on different slices of our data. So now that we have a few good baselines, what if we want to improve the model further?</p><p>In our experience, this question comes up all too often and other options on the market don’t quite work. If you look at other tools, you’ll likely find two broad types of options:</p><ul><li>Fallback to the DIY approach of building models from scratch requiring lots of code, or</li><li>Try AutoML solutions hoping they can improve performance, but at the cost of flexibility</li></ul><p>We’ve seen companies try both approaches, but in our opinion neither provides a truly efficient way for users of all skill levels to iterate on ML models. With Predibase and declarative ML, you get the best of both worlds through a unique combination of <em>simplicity</em> and <em>flexibility, </em>specifically:</p><ul><li>The <em>simplicity</em> of simply declaring what you want to change and Predibase automatically making the necessary modifications and training the end-to-end pipeline for you</li><li>The<em> flexibility</em> to customize nearly *any* aspect of the model pipeline from how text is preprocessed to the learning rate used during training</li></ul><p>This approach of declarative machine learning has been tried and tested by companies like <a href="https://research.facebook.com/publications/looper-an-end-to-end-ml-platform-for-product-decisions/">Meta</a>, <a href="https://machinelearning.apple.com/research/overton">Apple</a>, and <a href="https://www.uber.com/blog/introducing-ludwig/">Uber</a> (where Ludwig itself was created). Let’s discover how easy this declarative approach makes it to experiment and iterate!</p><p><strong>Phase 2 — Adding Unstructured Text Data</strong></p><p>How then should we begin thinking about iterating on our models? There are a variety of different approaches we can try including (but not limited to):</p><ul><li>Using additional preprocessing on the dataset</li><li>Choosing different model types for encoders / combiners / decoders</li><li>Tuning specific hyperparameters related to the training process like batch size and learning rate</li></ul><p>In our case, we can try something even simpler to start. You may have noticed that although we used a neural network for one of our baseline models, we actually didn’t use the text features at all!</p><p>Given both the signal that could lie within customer review text and the ease of Predibase to handle unstructured data, let’s go ahead and add those text features and retrain our model. For Predibase, it’s a matter of a few toggles enabling those features, and in Ludwig, it’s only a few lines of code as shown below.</p><p><strong>Neural Network using Text features</strong></p><pre>input_features:<br>  - name: Clothing ID<br>    type: number<br>  - name: Age<br>    type: number<br>  - name: Title<br>    type: text<br>  - name: Review Text<br>    type: text<br>  - name: Recommended IND<br>    type: binary<br>  - name: Positive Feedback Count<br>    type: number<br>  - name: Division Name<br>    type: category<br>  - name: Department Name<br>    type: category<br>  - name: Class Name<br>    type: category<br>output_features:<br>  - name: Rating<br>    type: number<br>combiner:<br>  type: tabnet</pre><p><strong>Neural Network using Text Features Config</strong></p><p>Once we train this new neural network model with the updated text features, we can see the performance metrics and compare how it performed to the previous iteration. Before we do that, however, it’s worth noting one of the many benefits of having models expressed as configuration files: Model Version Diff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*DxixnXPlHXujmCYY" /></figure><p>Comparing model parameters in Predibase is as easy as looking at a few lines of code in a config file.</p><p>With an entire model pipeline expressed as a single configuration file, we can visually inspect the differences between these two models and verify that we did indeed add the unstructured text fields in the new model versions. Neat!</p><p><strong>Performance of Neural Network using Text Features</strong></p><ul><li>Training R2: 0.7543</li><li>Test R2: 0.5671</li></ul><p>Great, it looks like adding text features helped the model achieve a better R2 score. Now you may be wondering if this should be our final model or if we should continue iterating. Predibase offers a variety of visualizations to understand the nuances of how our model performed and help answer that question including ROC curves, Confusion Matrices, and Feature Importances.</p><p>In particular, let’s take a look at the feature importance plots (powered by Integrated Gradients) to see if we can build stronger intuition for how much these text features aided model performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S6o3YySSZAu3xGYd" /></figure><p>Feature Importance for Neural Network with Text Features.</p><p>The chart above shows the relative importance values for each of the input features in the model. It looks like those text features (Review Text and Title) were critically important for the model to learn after all! The contrast becomes even starker when comparing relative to the original neural network’s feature importance chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*c2vsGb4mjy_MDYd7" /></figure><p>Feature Importance for Neural Network without Text Features.</p><p><strong>Phase 3 — Fine-tuning BERT</strong></p><p>Now that we’re using all the features, let’s try something a bit more advanced! Predibase (and Ludwig) have integrations with <a href="https://huggingface.co/">Hugging Face</a>, providing us with state-of-the-art models at our fingertips. Together with the fact that Ludwig leverages a <a href="https://ludwig.ai/latest/user_guide/how_ludwig_works/#ecd-architecture">compositional model architecture</a>, we can use Hugging Face models as encoders at the individual input feature type level.</p><p>In our case, let’s try two things:</p><ol><li>Use a heavyweight encoder like BERT to encode our text features. We’ll use the pre-trained version model and choose to fine-tune the model on our dataset.</li><li>We’ll also do a bit of feature selection and will only choose these two features as they were the most influential overall in our previous iteration.</li></ol><p><strong>Neural Network with fine-tuning BERT</strong></p><pre>input_features:<br>  - name: Title<br>    type: text<br>  - name: Review Text<br>    type: text<br>output_features:<br>  - name: Rating<br>    type: number<br>trainer:<br>  optimizer:<br>    type: adamw<br>  batch_size: auto<br>  learning_rate: 0.00002<br>  learning_rate_warmup_epochs: 0<br>defaults:<br>  text:<br>    encoder:<br>      type: bert<br>      trainable: true</pre><p><strong>Neural Network with Fine-Tuning BERT Config</strong></p><ul><li>Training R2: 0.9186</li><li>Test R2: 0.6429</li></ul><h3>The Ease of Model Iteration with Predibase</h3><p>Let’s summarize our findings from this iteration journey!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ieuLsWaYS7tejcGj" /></figure><p>Summary of R2 scores for our customer rating prediction models.</p><p>You can see that training a multi-modal model that fine-tuned BERT for our text features along with defaults for our structured features resulted in the best performance with a Test R2 of 0.6636.</p><p>And while training baselines were simple to get started, Predibase also allowed us to easily experiment by adding features and modifying cutting-edge encoders to reach a high-performing model. Today, we experimented with some high-level parameters but in a future post, we’ll take a look at how we can tweak more advanced parameters as well. With Predibase, this iteration journey can also continue in a more automated fashion by leveraging distributed hyperparameter optimization.</p><h3>Ready to Deploy Models into Production</h3><p>Perfect, that final model is the best performing model we’ve trained so far! Now that we have a model we’re satisfied with, how exactly should we go about operationalizing it? Building a custom, in-house deployment process would be quite time-consuming and complex. Without Predibase, we’d likely have to pass the model over to the ML Engineering team who would have to figure out the best way to deploy the model. Given the use-cases and performance requirements for inference vary significantly per model, we’ve seen many organizations fall into the trap of creating insurmountable tech debt while building out a model deployment pipeline.</p><p>Recognizing these challenges, Predibase offers performant, hassle-free deployments natively within the platform for both batch and real-time serving through the use of <a href="https://predibase.com/blog/how-to-run-inference-on-ludwig-models-using-torchscript">Torchscript</a> and other cutting-edge technologies.</p><p>In the case of batch inference, we can use Predibase’s PQL (Predictive Query Language) to get predictions instantly and examine how the <em>Rating_predictions</em> compare to the ground truth <em>Rating</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*2dwTgFXzAmpKJRDT" /></figure><p>You can quickly explore rating predictions inline using Predibase’s predictive query language (PQL) and editor</p><p>If instead, we want to deploy this to a REST endpoint for real-time inference, we can deploy to a high-throughput, low-latency endpoint that is live in just a few clicks!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1yJwUehWVMU38Sce" /></figure><p>You can deploy to a REST endpoint in just one click using Predibase.</p><h3>Trying Multimodal Datasets on Predibase</h3><p>In this example, we showed you how to build a review ratings prediction engine in less than 10 minutes using state-of-the-art deep learning techniques and multi-modal data on Predibase. This was possible due to the underlying compositional Encoder-Combiner-Decoder (ECD) model architecture that makes unstructured data as easy to use as structured data. This is powerful for any e-commerce or retail companies looking to better understand customer sentiment and apply ML to their business.</p><p>This was also just a quick preview of what’s possible with Predibase, the first platform to take a low-code declarative approach to machine learning. Predibase democratizes the approach of declarative ML used at big tech companies, allowing you to train and deploy deep learning models on multi-modal datasets with ease.</p><p>If you’re interested in finding out how declarative ML can be used at your company:</p><ul><li>Request a personalized <a href="https://predibase.com/request-early-access">demo</a> of Predibase</li><li>Check out the OSS project <a href="https://ludwig.ai/latest/">Ludwig</a> and download the ratings prediction <a href="https://colab.research.google.com/drive/1Tf1wjSzJWzGXH60Rgv7p_rkyuaPmD0h1?usp=sharing">notebook</a></li><li>Explore more deep learning and machine learning use cases in our <a href="https://predibase.com/blog">blog</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25ffd40695ab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/predicting-customer-reviews-with-multi-modal-machine-learning-25ffd40695ab">Predicting Customer Reviews with Multi-Modal Machine Learning</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 AI Predictions that Will Shape 2023 and Beyond]]></title>
            <link>https://medium.com/predibase/10-ai-predictions-that-will-shape-2023-and-beyond-42dc62a88f81?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/42dc62a88f81</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Michael Ortega]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 15:53:59 GMT</pubDate>
            <atom:updated>2023-01-30T15:53:35.263Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lqYRChmyIbejWDXFMTGjPw.png" /></figure><p>2022 was an exciting year for machine learning. The industry saw remarkable innovations from the release of powerful generative AI tools like ChatGPT and DALL-E to major advancements in AI for drug discovery (see: <a href="https://www.newscientist.com/article/2330866-deepminds-protein-folding-ai-cracks-biologys-biggest-problem/">Google’s Deep Mind cracks the code on protein structures</a>). Machine learning is quickly moving from theoretical research to real-world applications, and every organization is looking to tap into its potential.</p><p>So what exciting ML trends will emerge in 2023 and beyond? To help answer that question, we gathered predictions from our team at Predibase — many of which represent leading minds in AI. Their backgrounds span AI research at Google to creating popular open-source projects like Ludwig and Horovod. Whether you’re a seasoned AI expert or just starting to learn about the field, we hope you find our musings on the future thought-provoking and insightful and we’d love to hear your predictions as well.</p><h3>1. ML becomes indispensable for scientific research</h3><p>The application of ML techniques for scientific discovery has been hindered by the specificity of the skills needed for both conceptualizing valuable uses (mostly machine learning and AI knowledge) and applying them fruitfully at scale (mostly computer science and software engineering knowledge). A new breed of ML models and technologies has lowered the barrier for use and demonstrated the disproportionate impact ML can have on scientific research. With the democratization of ML, the time is right for the widespread adoption of ML in chemistry, material science, biology, pharmacology, agronomy, and many other areas.</p><p><strong>Piero Molino</strong></p><p>CEO &amp; Cofounder of Predibase, creator of Ludwig and previously founder of the AI Lab at Uber</p><h3>2. Multi-modal model architectures see mass adoption</h3><p>As enterprises attempt to harness the potential of large foundation models, multi-modal model architectures that combine unstructured data with structured data will start to become the norm in industry. The primary driver for this will be the need to tailor these pretrained models for supervised learning tasks using structured metadata about the users, products, etc. associated with the unstructured data.</p><p><strong>Travis Addair</strong></p><p>CTO &amp; Cofounder of Predibase, creator of Horovod and previously Deep Learning Engineering Lead at Uber</p><h3>3. A large language model provider will be the new AWS</h3><p>Large language models (LLMs) like ChatGPT are rapidly growing in popularity, but are limited by the publicly available information that they are trained on. To get the most value out of a LLM, enterprises will need to train LLMs on their own documentation. For example, doctors and therapists might need to tune a LLM based on their own scripts. The company that is able to provide LLM-as-a-Service will become the new utility provider of the internet.</p><p><strong>Daliana Liu</strong></p><p>Sr. Data Scientist at Predibase and host of the “The Data Scientist Show” with 200k+ followers on LinkedIn and previously Sr. Data Scientist at AWS</p><h3>4. Deep learning goes mainstream for the citizen data scientist</h3><p>Outside the ivory tower of academia and inside the gritty world of practical data science, there’s long been a belief that “XGBoost is all you need”. And generally they’ve been right — gradient boosted machines dominated machine learning competitions, which tended to be tabular datasets, and ease and speed of linear and tree models (vs neural networks) made them the preferred approach for the large majority of data scientists.</p><p>However, there are going to be two factors that will drive the uptake of deep learning now: 1) the practical impact demonstrated by transformer architectures and foundation models that have put unstructured data modalities like text and images more front-and-center for data scientists — structured data is “boring” now, unstructured is where the envelope is being pushed. Coupled with 2) the rising popularity of higher level abstractions that practically make deep learning much easier to use, like fast ai, pytorch lightning, <a href="http://www.ludwig.ai/">Ludwig, </a>and others.</p><p><strong>Devvret Rishi</strong></p><p>CPO &amp; Cofounder of Predibase and previously PM Lead at Kaggle and Google Assistant</p><h3>5. Standardization will enable deployment of ML models at scale</h3><p>Industry standards for data management and ML development will take hold in 2023. For example, we’ll see broad adoption of second generation data lake formats <a href="https://iceberg.apache.org/">Apache Iceberg</a> and <a href="https://delta.io/">Delta Lake</a> for performant reading and writing of versioning data.</p><p>The ecosystem around <a href="https://arrow.apache.org/">Apache Arrow</a>, the language-independent columnar memory format for efficient data transfer, will continue to grow as projects like the Arrow Database Connection specification (<a href="https://arrow.apache.org/docs/dev/format/ADBC.html">ADBC</a> is an API standard for database drivers) and <a href="https://substrait.io/">Substrait</a> (a cross-language specification for data compute) continue to mature.</p><p>Additionally, we will start to see standards evolve at the intersection of <a href="https://dataproducts.substack.com/p/the-rise-of-data-contracts">data contracts</a> and <a href="https://huggingface.co/docs/hub/model-card-landscape-analysis">model cards</a>, providing a consistent protocol for defining input, output, and configuration required for model training.</p><p>On the model inference side, <a href="https://github.com/kserve/kserve/tree/master/docs/predict-api/v2">KFServing v2</a> which defines both REST and gRPC protocols will continue to see broad adoption from both open-source solutions like Seldon Core as well as cloud ML vendors.</p><p>These standards provide consistent interfaces to load data and consume predictions, enabling a customer to start with open-source tooling, and migrate to a managed machine learning platforms like <a href="https://www.predibase.com/">Predibase</a> without breaking any downstream applications.</p><p><strong>Julian Bright</strong></p><p>Platform Engineering Manager at Predibase and previously Principal Solutions Architect at AWS</p><h3>6. MLOps expands to support differentiated pre-trained models</h3><p>As pre-trained models continue to proliferate the machine learning landscape, there will be a race to apply pre-trained models to proprietary data sources in the pursuit of specialized and differentiated ML.</p><p>MLOps companies will move to offer services in support of renewed interest in pre-trained models such as: fine-tuning as a service, enterprise model hubs, model distillation, and synthetic data. A one billion parameter model will be created that has performance on par with GPT-3, as practitioners seek cost-efficient ML.</p><p><strong>Justin Zhao</strong></p><p>ML Engineering Lead at Predibase and previously Sr. Engineer and NLP researcher at Google</p><h3>7. AI reaches every corner of the corporate office</h3><p>Every enterprise is investing in ML and the advent of low-code ML tools like <a href="https://www.predibase.com/">Predibase</a> are making it even easier for data practitioners to build ML applications. That being said, the average knowledge worker probably doesn’t interact with ML that often or at all. That will rapidly change in 2023.</p><p>Generative AI tools like ChatGPT and DALL-E — which may seem like a novelty — are making it easier for a new breed of business personas to experiment with AI and unlock new use cases like <a href="https://www.thecontentflywheel.com/post/eight-intriguing-chatgpt-use-cases-for-copy-and-content-writers">marketing content development</a> and product design (see: <a href="https://news.microsoft.com/source/features/ai/from-hot-wheels-to-handling-content-how-brands-are-using-microsoft-ai-to-be-more-productive-and-imaginative/">Hot Wheels</a> and <a href="https://techcrunch.com/2022/08/09/businesses-including-stitch-fix-are-already-experimenting-with-dall-e-2/">Stitch Fix</a>). These tools still need refinement, and there are open questions around legality, but we’re only scratching the surface of what’s possible. As more of these tools make it into the mainstream, business teams from HR to Finance will begin experimenting.</p><p><strong>Michael Ortega</strong></p><p>Head of Marketing at Predibase and previously Marketing Director at Databricks</p><h3>8. Open-source foundation models will make their way into the mainstream</h3><p>Big Tech companies currently hold a disproportionately large amount of influence on how Foundation Models are ultimately trained and deployed; however, the data with which they are training these models is largely in the public domain. This means that, with sufficient hardware resources, time, and talent, there is no hard barrier to training an equivalently powerful Foundation Model.</p><p>A concerted effort from the OSS community (such as that spearheaded by the <a href="https://www.together.xyz/">Together Project</a>) to develop its own Foundation Models could accelerate innovation outside of Big Tech research labs and ultimately give enterprises access to powerful generative models that can be fine-tuned and deployed in any environment.</p><p><strong>Geoffrey Angus</strong></p><p>ML Engineer at Predibase and previously ML Researcher at Google and Stanford</p><h3>9. Decreased corporate spending will put pressure on ML tools to provide demonstrable ROI</h3><p>Generative AI models — like GPT-3 and Dall-E — have drawn many people into the true power of ML. While new and increasingly powerful generative models will continue to be released, businesses will be focused on how they can leverage many forms of ML including generative modeling and supervised ML to provide concrete business value. Success stories will likely be found across multiple departments in an organization, ranging from Marketing to Customer Success. In terms of tooling, horizontal platforms that can demonstrate quick time-to-value and widespread adoption will be well-positioned to take advantage of this opportunity.</p><p><strong>Abhay Malik</strong></p><p>Product Manager at Predibase and previously Cofounder and CTO at BlitzIQ</p><h3>10. Machine learning becomes ubiquitous</h3><p>In the 1990s, most programs didn’t have a network stack. Today, it’s hard to find an app without one. Consumers expect every product to communicate over networks and retrieve or store data in the cloud.</p><p>In a similar way, every software product in the near future will interact with ML. Features like personalization, natural language interfaces, and considerate systems will be expected in every product.</p><p>Like networking, most of us don’t need to be machine learning experts, but we will all become familiar with its capabilities and learn how to interact with it.</p><p><strong>Daniel Treiman</strong></p><p>ML Engineering Lead at Predibase and previously Engineering Lead at Google and cofounder of multiple startups including GameSalad</p><h3>Get started with one of the biggest ML trends of 2023</h3><p>Machine learning is finding its way into all areas of the enterprise, but data teams still struggle to build and deploy ML models at scale. Predibase is on a mission to change that. As the first low-code declarative ML platform, Predibase makes it easy for everyone — from developer to experienced data scientist — to train, optimize and deploy state-of-the-art models in minutes.</p><p>Join our <a href="https://pbase.ai/3XKz09c">upcoming webinar</a> on building a multi-modal deep learning model with Predibase to learn more or <a href="https://pbase.ai/GetStarted">request a demo</a> to get started building models today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42dc62a88f81" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/10-ai-predictions-that-will-shape-2023-and-beyond-42dc62a88f81">10 AI Predictions that Will Shape 2023 and Beyond</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost Tabular Data Predictions with Tree Models in Ludwig 0.6]]></title>
            <link>https://medium.com/predibase/boost-tabular-data-predictions-with-tree-models-in-ludwig-0-6-6b03429b5c90?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/6b03429b5c90</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Joppe Geluykens]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 19:00:36 GMT</pubDate>
            <atom:updated>2023-01-04T19:00:36.594Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2qbtzXb-BTRZ2oCPyCuSA.png" /><figcaption><em>Cover by</em> <a href="https://medium.com/u/75396a8f3cf2">Jackie Ho</a></figcaption></figure><p>Authors: <a href="https://medium.com/u/f497ec7e15bd">Joppe Geluykens</a>, <a href="https://medium.com/u/1dad367afd91">Daliana Liu</a>. Editors: <a href="https://medium.com/u/9b9b6ae518c0">Arnav Garg</a>, <a href="https://medium.com/u/eddb48e54738">Piero Molino</a>.</p><p><a href="https://ludwig-ai.github.io/ludwig-docs/">Ludwig</a> is an open-source declarative machine learning framework that enables you to train and deploy state-of-the-art models for a variety of tasks including tabular, natural language processing, and computer vision by just writing a configuration. If you are new to Ludwig, check out our <a href="https://ludwig.ai/latest/examples/text_classification/">quick tutorial</a>.</p><p>Until now, Ludwig only supported neural network (NN) models, but with the release of Ludwig 0.6, we are excited to add gradient boosted tree (GBM) models as a new model type for tabular data.</p><p>One of the key advantages of gradient boosted trees is their speed of training compared to neural network models. They also tend to perform competitively on tabular data and to be more robust against class imbalance compared to neural networks, making them a reliable and widely-used tool among practitioners. By adding gradient boosted trees to Ludwig, we hope to provide you with a unified interface for exploring different model types and obtain improved performance in particular on small tabular data tasks.</p><p>We created an interactive tutorial that you can <a href="https://ludwig.ai/latest/examples/gbm_fraud/">explore here</a>.</p><h3>Why add GBMs to Ludwig?</h3><p>Ludwig provides a simple and flexible declarative interface for building and serving the best quality models on a wide variety of tasks.</p><p>Ludwig uses a compositional architecture with neural networks as the default for modeling. This is because neural networks are able to handle a wide <a href="https://ludwig.ai/latest/configuration/features/supported_data_types/">range of data types</a> and support <a href="https://ludwig.ai/latest/examples/multi_task/">multi-task learning</a>, making them a versatile choice for many applications.</p><p>While neural networks work well with many types of data, they are relatively slow to train and they may not always be the best choice for tabular data, particularly when the dataset is small or when there is class imbalance. Additionally, using multiple frameworks to try different model types can be time-consuming and cumbersome.</p><h3>How to use GBMs in Ludwig?</h3><p>If you have a dataset to predict income from census data, this is a Ludwig configuration that gets you started:</p><pre>input_features:<br>  - name: age<br>    type: number<br>  - name: workclass<br>    type: category<br>  - name: fnlwgt<br>    type: number<br>output_features:<br>  - name: income<br>    type: category</pre><p>This will train a neural network with default architecture and training parameters. If you want to train a GBM model instead, you can specify the model_type in the Ludwig configuration:</p><pre>model_type: gbm</pre><p>This tells Ludwig to train a GBM model, instead of the default NN.</p><p>Under the hood, Ludwig uses LightGBM to train a gradient boosted tree model. <a href="https://lightgbm.readthedocs.io/en/v3.3.2/">LightGBM</a> is a gradient boosting framework that uses tree based learning algorithms and is designed to be scalable and performant.</p><p>Like other parameters in Ludwig, LightGBM-specific hyperparameters come with a default value, which you can override if desired. For example, you might include the following in the trainer section of the configuration file:</p><pre>trainer:<br>  learning_rate: 0.1 <br>  num_boost_round: 50 <br>  num_leaves: 255 <br>  feature_fraction: 0.9 <br>  bagging_fraction: 0.8 <br>  bagging_freq: 5 <br>  min_data_in_leaf: 1 <br>  min_sum_hessian_in_leaf: 100</pre><p>This sets the learning rate, number of boosting rounds, and other hyperparameters for the GBM model. For more information about the available hyperparameters, default values and how to override them, you can refer to the <a href="https://ludwig.ai/latest/configuration/trainer/">Ludwig documentation</a>.</p><p>Here is a comparison of the configurations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XTnB-i3u-HpMnIKTAccfA.png" /><figcaption>(left) Default Ludwig config, (right) <em>Ludwig config for training GBM</em></figcaption></figure><h4>Hyperparameter tuning</h4><p>Hyperparameters heavily influence the performance you get out of any model, including GBMs. In Ludwig there is a simple way to run hyperopt by just adding a section in the configuration.</p><p>For example, you can do a hyperopt sweep over some specific values for learning_rate and max_depth by adding these to the hyperopt parameters section of the Ludwig config:</p><pre>hyperopt:<br> parameters:<br>   trainer.learning_rate:<br>     space: grid_search<br>     values:<br>       - 0.001<br>       - 0.01<br>       - 0.1<br>   trainer.max_depth:<br>     space: grid_search<br>     values:<br>       - 5<br>       - 10<br>       - 30</pre><p>Adding this section to the config will run a grid search on the outer product of those parameters (9 runs in total). Ludwig also supports random search, bayesian optimization and other advanced techniques, check out the <a href="https://ludwig.ai/latest/configuration/hyperparameter_optimization/">documentation</a> for more details.</p><h4>Model quality</h4><p>In order to test out the new GBM capability in Ludwig we ran some benchmarks to compare GBMs with the default neural network architecture. We looked at small tabular datasets representing various tasks and characteristics (see Table 1). By using a diverse set of datasets, we were able to evaluate the model’s ability to handle different types of data and tasks, as well as its robustness to imbalanced datasets.</p><p>On 8 out of 12 datasets, GBMs outperformed NNs in terms of predictive power (see Figure 1). In particular GBM models perform on par or better for 7 out of the 8 classification datasets and 3 out of 4 regression datasets. For the datasets where NNs perform better than GBMs, the performance difference is within 2% of ROC AUC (binary classification) and 1% of <em>R</em>2 (regression).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T924Kt7X_lOMtRr-0j1Nbw.png" /><figcaption><strong>Table 1</strong> Out of the 12 datasets, 5 are binary classification, 3 are multi-class classification, and 4 are regression datasets. Of the 8 classification datasets, 2 are balanced, 2 are imbalanced with a minimum to majority ratio of less than 0.9, and 4 are highly imbalanced with a minimum to majority ratio of less than 0.25. The size of the smallest dataset (naval) is 1.73MB, while the largest (Allstate claims severity) is 1,233.46MB. The number of features in the datasets ranges from 15 (No-show appointments) to 379 (Mercedes-Benz greener).</figcaption></figure><p>On the balanced datasets <em>numerai28pt6</em> and <em>mushroom edibility</em>, NNs perform on par or better than GBMs, whereas GBMs outperform NNs on most imbalanced datasets. This provides some evidence for the hypothesis that GBMs are more robust to class imbalance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zP9B3fsA22NvoojL" /><figcaption><strong>Figure 1</strong> We report accuracy for multi-class classification datasets, ROC AUC for binary classification datasets and R-squared for regression datasets.</figcaption></figure><p>Note that the results presented here are based on small tabular datasets and may not represent the performance of GBMs and NNs on larger or more complex data. To better understand the relative strengths and weaknesses of both models, we plan to conduct a larger-scale comparison on a wider range of datasets which will include a more indepth hyperopt.</p><h4>Faster training</h4><p>On 7 out of 12 datasets, GBMs outperformed NNs in terms of training speed. The time it took to train a NN on all datasets was 2.5 times longer than the time it took to train a GBM on the same datasets. In particular, the NN took 10 times as long to train on the BNP claims management dataset and over 5 times as long on the Allstate claims severity dataset. Both model types were trained on a single Ray cluster with 1 head node and 1 worker node, both running m5.2xlarge instances on AWS.</p><h3>Benefits and limitations</h3><p>The introduction of GBMs in Ludwig makes it a one-stop shop to declaratively train multiple types of models.</p><p>A major <strong>benefit</strong> is that you can take advantage of all of the additional functionalities that Ludwig offers for NNs also for GBMs: preprocessing, hyperparameter optimization using Ray Tune, interoperability with different data sources (pandas, dask, modin), which are all declared in the same familiar and concise Ludwig config, and Ludwig’s out of the box visualization and serving capabilities.</p><p>Moreover, the fact that running different experiments with different model types only requires modifying a couple strings of a configuration makes it very easy to perform a fair comparison of models and experiment with different preprocessing, training schedules and find the best hyperparameters.</p><p>Choosing GBM as the model type in Ludwig imposes some <strong>limitations</strong> on the available data types and the number of output targets.</p><p>GBMs can only be used for binary, categorical, or regression tasks, and the data types for input and output features are limited to binary, categorical, or numerical data. If your task includes other types of data, such as images, audio, or text, you can use the default Ludwig model type, which is neural networks. Ludwig contains many state of the art NN architectures out of the box.</p><p>Additionally, GBM models currently only support a single output feature. If you want to do multi-task learning, where the model makes predictions for multiple output targets, you will need to use neural networks instead.</p><h3>Stay in the loop</h3><p>We hope you are as excited as we are about how easy it is to use GBM models in Ludwig 0.6 and that you take it for a spin! We are also working on benchmarking this capability on a wider range of datasets, so stay tuned. In the meantime, you can download <a href="https://ludwig.ai/latest/">Ludwig</a> and join our<a href="https://join.slack.com/t/ludwig-ai/shared_invite/zt-mrxo87w6-DlX5~73T2B4v_g6jj0pJcQ"> Slack</a> community to connect with Ludwig builders. Happy modeling!</p><p>If you are interested in adopting Ludwig in the enterprise, check out<a href="http://predibase.com/"> Predibase</a>, the declarative ML platform that connects with your data, manages the training, iteration and deployment of your models, and makes them available for querying, reducing time to value of machine learning projects. In Predibase, you can switch between a NN and a GBM with the click of a button.</p><p>Don’t want to miss future updates? Join <a href="https://docs.google.com/forms/d/1w2lY1YbIcpChAAMzyUipCOeivwia7u53rBUAWIroC34/edit">this</a> email list (you can unsubscribe anytime).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b03429b5c90" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/boost-tabular-data-predictions-with-tree-models-in-ludwig-0-6-6b03429b5c90">Boost Tabular Data Predictions with Tree Models in Ludwig 0.6</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Run Inference on Ludwig Models Using TorchScript]]></title>
            <link>https://medium.com/predibase/how-to-run-inference-on-ludwig-models-using-torchscript-b53e83dc31f?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/b53e83dc31f</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Geoffrey]]></dc:creator>
            <pubDate>Tue, 20 Dec 2022 20:13:44 GMT</pubDate>
            <atom:updated>2022-12-20T20:13:44.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In <a href="https://ludwig.ai/latest/">Ludwig</a> 0.6, we have introduced the ability to export Ludwig models into <a href="https://pytorch.org/docs/stable/jit.html">TorchScript</a>, making it easier than ever to deploy models for highly performant model inference. In this blog post, we will describe the benefits of serving models using TorchScript and demonstrate how to train, export, and use the exported models on an example dataset.</p><h4>How are models served today?</h4><p>A common way to serve machine learning models is wrapping them in REST APIs and exposing their endpoints. In fact, you can do this today in Ludwig using the serve command:</p><pre>ludwig serve --model_path=&lt;MODEL_PATH&gt;</pre><p>This works great if you do not have particularly strict SLA requirements or if backwards compatibility is not a concern. However, if you need to serve a model in a production environment, you will likely need to use a more robust solution. Such a solution typically involves one or both of (1) some inference framework, such as <a href="https://pytorch.org/serve/">TorchServe</a> or <a href="https://developer.nvidia.com/nvidia-triton-inference-server">NVIDIA Triton</a>, and (2) a method of serializing models into inference-optimized formats such as TorchScript or <a href="https://onnx.ai/">ONNX</a>. As of Ludwig 0.6, we now support the export of Ludwig models into TorchScript.</p><h4>What is TorchScript?</h4><p>TorchScript is a format that allows you to serialize a model and its weights in a way that can be loaded and executed in a production environment.</p><p>Serving TorchScript models has numerous advantages over serving vanilla <a href="https://pytorch.org/">PyTorch</a> models:</p><ul><li>TorchScript models are fully serialized and can be loaded without the original Python code. This means that you can load TorchScript models in a lightweight environment with minimal dependencies (see the <strong>Try it Yourself </strong>section below).</li><li>TorchScript models are often more performant than their vanilla PyTorch counterparts. This is because the underlying PyTorch computation graph is extracted and optimized for inference.</li><li>Finally, TorchScript models can be loaded and executed in a variety of environments, including C++. This means that you can use TorchScript models in a variety of production environments, including mobile devices.</li></ul><h4>What is new in Ludwig?</h4><p>Vanilla Ludwig models are composed of three stages, (1) preprocessing, (2) prediction, and (3) postprocessing. While prediction is always done in PyTorch, preprocessing and postprocessing happens using DataFrame engines such as either <a href="https://pandas.pydata.org/">Pandas</a> or <a href="https://www.dask.org/">Dask</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DKtb2SqXFgZvjhiR" /></figure><p>In Ludwig 0.6, we introduced the export_torchscript CLI command, which takes a trained vanilla Ludwig model and exports it to the TorchScript format. In order to support this, we needed to ensure that everything from preprocessing to postprocessing was TorchScript-compatible in order to give Ludwig users the end-to-end inference experience they expect from a trained Ludwig model. This meant writing preprocessors and postprocessors for each feature type as torch.nn.Module subclasses, and introducing a new InferenceModule class able to execute the entire graph. Behind the scenes, the InferenceModule is composed of three separate TorchScript modules: the preprocessor, the predictor, and the postprocessor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3f_s1R000L4WHWP-" /></figure><p>The three-stage pipeline design gives us several benefits:</p><ul><li>Having separate TorchScript modules makes it possible to split these stages between devices– for example, placing the preprocessor and postprocessor on CPU, while placing the predictor on GPU. A single monolithic TorchScript module would make doing this much more difficult.</li><li>If the staged pipeline is paired with a model serving tool like NVIDIA Triton, it becomes possible to independently scale the stages to ensure maximum efficiency. If interested in using NVIDIA Triton in this way, check out the export_triton CLI command.</li></ul><p>With this change, Ludwig users can now export trained models and deploy them seamlessly* in a variety of production environments. Next, we’ll take a look at exactly how to do so!</p><p>*For the most part– see the <strong>Limitations</strong> section below.</p><h3>Try It Yourself</h3><p>For this blog post, we are going to be working with the <a href="https://botometer.osome.iu.edu/bot-repository/datasets.html">Twitter Bots dataset</a>– a popular public dataset where the task is identifying bots based on account metadata. The next section will demonstrate how to</p><ol><li>Train a multimodal (tabular+text) neural network pipeline with Ludwig</li><li>Export the entire neural network pipeline into TorchScript</li><li>Run inference on the exported TorchScript model</li></ol><h4>Training a Ludwig Model</h4><p>Ludwig is a <a href="https://arxiv.org/abs/2107.08148">Declarative ML</a> framework that enables training multimodal, multi-task Deep Learning models with simple YAML configuration files. It also comes with a couple of example datasets to help new users get started.</p><p>To get started, download the Twitter Bots dataset via the Ludwig CLI with the following command:</p><pre>ludwig datasets download --output_dir=&lt;DATA_DIRECTORY&gt; twitter_bots</pre><p>Once the dataset is downloaded, all we have to do to train a model is specify a new YAML configuration file that looks like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9f8fd803c6eb867fdc2bc89ce810234/href">https://medium.com/media/b9f8fd803c6eb867fdc2bc89ce810234/href</a></iframe><p>The above configuration file specifies a multimodal neural network that takes in 9 input features (8 tabular and 1 text) and outputs a single binary output feature. Each of the features in this case are columns from the downloaded Twitter Bots Parquet file. The model type is set to ecd, which is the <a href="https://ludwig.ai/0.5/user_guide/how_ludwig_works/#ecd-architecture">ECD architecture</a> that Ludwig uses to train multimodal neural networks.</p><p>Finally, we set the epoch count to 1 for the sake of expediency in this blog post. If you are interested in training a performant model, feel free to set this value higher!</p><p>We can finally train a Ludwig model using the above configuration with the following command:</p><pre>ludwig train --config=&lt;CONFIG_FILEPATH&gt; \<br>  --dataset=&lt;DATA_DIRECTORY&gt;/twitter_bots.parquet \<br>  --output_directory=&lt;EXPERIMENT_DIRECTORY&gt;</pre><p>After a few minutes, you should have a trained Ludwig model.</p><h4>Exporting a Ludwig Model to TorchScript</h4><p>We can now export our trained Ludwig model into TorchScript. We can do this by running the following command:</p><pre>ludwig export_torchscript --model_path=&lt;EXPERIMENT_DIRECTORY&gt;/model \<br> --output_path=&lt;EXPERIMENT_DIRECTORY&gt;/torchscript</pre><p>If model training was done on a CPU device, doing so produces three new TorchScript artifacts and copies over a couple of others for convenience. In the specified output directory, we should now have the following files:</p><pre>torchscript/<br>  inference_preprocessor.pt<br>  inference_predictor_cpu.pt<br>  inference_postprocessor.pt<br>  training_set_metadata.json # copied over from - model_path<br>  model_hyperparameters.json # copied over from - model_path</pre><p>These artifacts fully represent a single Ludwig model. The three TorchScript files represent our inference pipeline. The inference_preprocessor.pt file is a TorchScript version of the preprocessing steps done during training. The inference_predictor_cpu.pt file is a TorchScript version of the trained model. The inference_postprocessor.pt file is a TorchScript version of the postprocessing steps associated with the output.</p><h4>Running Inference on a TorchScript Model</h4><p>The pipelined nature of the exported Ludwig model gives the user a lot of flexibility in how they want to run inference. Below are a couple of examples to do so.</p><h4>Method 1: Using the InferenceModule class</h4><p>The most straightforward way to start using the model is by leveraging the InferenceModule class, a convenience class that allows users to load all three modules from a given directory. It additionally provides a predict method whose interface mimics LudwigModel.predict and enables inference on a <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html">Pandas DataFrame</a>.</p><p>Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec4c299493818867f074b41f0ae4ec2c/href">https://medium.com/media/ec4c299493818867f074b41f0ae4ec2c/href</a></iframe><p>Output:</p><pre>{&#39;account_type&#39;: {&#39;predictions&#39;: [&#39;human&#39;, &#39;human&#39;],<br>                  &#39;probabilities&#39;: tensor([[1.0000e+00, 2.1253e-07],<br>    [1.0000e+00, 7.5131e-11]])}}</pre><p>The primary limitation of this method is that it requires a Python backend to run. The subsequent methods use pure TorchScript and thus do not have this limitation.</p><h4>Method 2: Convert InferenceModule Into a Single TorchScript Module</h4><p>It is also possible to convert the entire pipeline into a single TorchScript module. This can be done by running torch.jit.script on the InferenceModule class from Method 1. You can then save the resulting module to file and use it in any TorchScript-compatible backend.</p><p>The resulting model is pure TorchScript, so input DataFrames must be converted to dictionary objects before the forward pass. You can use the convenience function ludwig.utils.inference_utils.to_inference_module_input_from_dataframe to do this for you.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67048f74bfb5f7d240f668872986df04/href">https://medium.com/media/67048f74bfb5f7d240f668872986df04/href</a></iframe><p>Output:</p><pre>{&#39;account_type&#39;: {&#39;predictions&#39;: [&#39;human&#39;, &#39;human&#39;],<br>                  &#39;probabilities&#39;: tensor([[1.0000e+00, 2.1253e-07],<br>    [1.0000e+00, 7.5131e-11]])}}</pre><h4>Method 3: Running Inference on Each Module Separately</h4><p>The final way to use this model is by loading the modules individually and forward passing on each one sequentially. One might do this if using an inference framework that can assign resources to each pipeline stage accordingly, such as <a href="https://developer.nvidia.com/nvidia-triton-inference-server">NVIDIA Triton</a>.</p><p>As in Method 2, inputs must be fed in as dictionary objects. Also note that, because these modules are individually optimized for inference frameworks like NVIDIA Triton, the output of the postprocessor is a flattened dictionary (as opposed to the nested dictionary outputs from Methods 1 and 2).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d90f5fad5edf0df42bdf548a6457d6f/href">https://medium.com/media/7d90f5fad5edf0df42bdf548a6457d6f/href</a></iframe><p>Output:</p><pre>{&#39;account_type::predictions&#39;: [&#39;human&#39;, &#39;human&#39;],<br> &#39;account_type::probabilities&#39;: tensor([[1.0000e+00, 2.1253e-07],<br>    [1.0000e+00, 7.5131e-11]])}</pre><h3>Limitations</h3><p>The TorchScript export code path introduces significant improvements in Ludwig’s model serving capabilities, there are still a few limitations when it comes to exporting models to TorchScript.</p><p>As of Ludwig 0.6.4, we are just beginning to provide limited support for <a href="https://huggingface.co/">HuggingFace</a> encoders; this means that HuggingFace encoders will likely need to be fine-tuned using one of our TorchScript-compatible encoders before use. We have implemented TorchScript-compatible GPT-2, CLIP, and BERT tokenizers for such use cases.</p><p>The second is that there are a small number of features that must be featurized before being fed into the inference module. These features are Image, Audio, and Date. Image and Audio features– which can often be trained in Ludwig using file paths alone– must be loaded in as Tensors before use with the inference module. Date features– which can be trained in Ludwig using the raw string format– must be preprocessed since the built-in datetime module is not TorchScript-able. For more info, please take a look at <a href="https://ludwig.ai/latest/user_guide/model_export/#current-limitations">the docs</a>. All other feature types supported by Ludwig have been made compatible with the new TorchScript implementation.</p><h3>Wrap-up</h3><p>The new TorchScript export feature makes it possible to decouple preprocessing, prediction, and postprocessing in order to serve highly performant models. With this new feature, Ludwig users can deploy their models into production in a way that is backend-independent and highly backwards compatible.</p><p>We’d love to hear your feedback on this new feature. Please let us know if you have any questions or suggestions by posting in the <a href="https://join.slack.com/t/ludwig-ai/shared_invite/zt-mrxo87w6-DlX5~73T2B4v_g6jj0pJcQ">Ludwig Slack channel</a> or by opening an <a href="https://github.com/ludwig-ai/ludwig/issues">issue on GitHub</a>.</p><p>If you are interested in going even further, <a href="https://predibase.com/">Predibase</a> is an end-to-end Declarative ML platform to train and deploy production-grade machine learning models in just a few lines of code. It is built with Ludwig at its core and supports all of the features described in this post and more, including high-performance serving in NVIDIA Triton at the click of a button. If you are interested in trying it out, feel free to <a href="https://predibase.com/request-early-access">get in touch</a>.</p><p>Happy serving!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b53e83dc31f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/how-to-run-inference-on-ludwig-models-using-torchscript-b53e83dc31f">How to Run Inference on Ludwig Models Using TorchScript</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Declarative Machine Learning and the Future of Data Science]]></title>
            <link>https://medium.com/predibase/declarative-machine-learning-and-the-future-of-data-science-2de3c1c7de2b?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/2de3c1c7de2b</guid>
            <dc:creator><![CDATA[Abhay Malik]]></dc:creator>
            <pubDate>Wed, 16 Nov 2022 23:39:02 GMT</pubDate>
            <atom:updated>2023-01-13T22:58:55.214Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>ABSTRACT: Declarative ML has the potential to reduce the time, effort, and skills required to bring ML into production in a wide range of enterprise environments.</em></strong></p><p>This is a guest post co-authored with <a href="https://medium.com/u/4968d2f593a8">Kevin Petrie</a>, VP of Research at the Eckerson Group. The blog was originally posted on the <a href="https://www.eckerson.com/articles/declarative-machine-learning-and-the-future-of-data-science">Eckerson blog</a>.</p><p>Authors: <a href="https://medium.com/u/4968d2f593a8">Kevin Petrie</a>, <a href="https://medium.com/u/1dad367afd91">Daliana Liu</a>, and <a href="https://medium.com/u/220a3b57bca8">Abhay Malik</a>.</p><p>The irony of machine learning (ML) models is that, while they automate business decisions and processes, building them takes a lot of manual effort. Data science teams struggle to handle all the complex programming required to implement ML models in production. Skilled, <a href="https://www.python.org/">Python</a>-savvy data scientists and ML engineers might spend months training, tuning, and finally deploying ML models. But if they use AutoML solutions to simplify the model building process, they risk losing visibility and control.</p><p>No surprise, then, that three quarters of enterprise respondents to a recent KDNuggets <a href="https://www.kdnuggets.com/2022/01/models-rarely-deployed-industrywide-failure-machine-learning-leadership.html">survey</a> said that most of their ML models never make it into production. This is just one of many research findings that indicate a sobering lack of ROI on AI/ML initiatives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLftrwJBT5z7WJN4Fsqg3w.png" /></figure><p>But there is cause for hope. A new approach called Declarative ML, inspired by Declarative programming, might help data science teams bring ML models to fruition with less time and effort.</p><h4>The Value of Declarative Machine Learning (ML)</h4><p>Declarative ML has data science teams define <strong>what</strong> they want to predict, classify, or recommend, then let the software figure out <strong>how</strong> to do it. They enter intuitive commands without needing to specify the code, rules, or other elements that execute on those commands. If this sounds familiar, it should, because popular languages such as hypertext markup language (<a href="https://en.wikipedia.org/wiki/HTML">html</a>) and structured query language (<a href="https://www.techtarget.com/searchdatamanagement/definition/SQL">SQL</a>) take the same approach. These languages achieved mainstream adoption by enabling less skilled users to define what they want without worrying about how it will get done. More advanced users can still inspect what happens under the covers if they want.</p><p>A Declarative ML system trains the ML model(s) on historical data, applying various default features, parameters, and algorithms. Using just a simple configuration file that defines the model and data, Declarative ML allows data scientists and engineers alike to train models without low-level knowledge of frameworks such as <a href="https://pytorch.org/">PyTorch</a> or <a href="https://www.tensorflow.org/">TensorFlow</a>. They can accept the default selections or adjust them to meet custom, dynamic requirements, then implement and monitor the models.</p><p>This flexible approach supports ML projects that range from the simple to the sophisticated, depending on the use case and the skills of the user. In fact, that user might be a SQL-savvy analyst rather than a python-savvy data scientist. Since it’s declarative, they can inspect and modify the parameters at their preferred level of detail.</p><p><strong><em>Declarative machine learning enables users to specify what they want,</em></strong></p><p><strong><em>and let the software figure out how to do it</em></strong></p><p>Declarative ML is similar to AutoML tools that also make default selections and automate part or all of the ML lifecycle. But AutoML might hide certain elements within automated workflows for the sake of simplicity, reducing the ability of data scientists to customize or explain what is happening. Declarative ML maintains full visibility and control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/0*YJaFPt9RmhoqqiXw" /></figure><p><strong>Benefits.</strong> Designed and implemented well, Declarative ML has the potential to democratize implementation of complex algorithms. It can empower data analysts and engineers to tackle basic ML projects — or even complex projects such as natural language processing or computer vision — without waiting on more ML-savvy colleagues such as data scientists and ML engineers. With Declarative ML, they can improve team productivity by spending less time on minutiae and more time on innovation. They can improve agility by assembling and reusing pre-built, modular features and models. Finally, they can maintain oversight of details to ensure explainability and governance.</p><p><strong>SQL Precedent.</strong> The history of structured query language (SQL) demonstrates the power of declarative approaches to programming. SQL helped drive adoption of relational databases in the 1980s, 90s, and onward by simplifying data manipulation and retrieval. For example, analysts define which records they want to query, but don’t need to specify how to reach it — e.g., whether to use an index. Decades on, SQL remains analysts’ lingua franca for managing business intelligence projects.</p><p>Recently data science teams within several large technology companies have applied a declarative approach to their ML model development. Their projects include the Overton project at Apple, Looper at Meta, and Ludwig at Uber.</p><p><a href="https://venturebeat.com/2019/09/13/apple-details-overton-ai-development-tool-whose-models-have-processed-billions-of-queries/"><strong>Overton</strong></a>. Apple developed this project to enable its data scientists and developers to build and operationalize ML or deep learning without writing code. They provide a schema that includes the data inputs, model tasks, and data flow that supports those tasks. Overton then compiles the schema for frameworks such as TensorFlow or Apple’s CoreML, and finds the right architecture and hyper parameters to support that schema. Overton-based applications have processed billions of queries and trillions of records.</p><p><a href="https://ai.facebook.com/blog/looper-meta-ai-optimization-platform-for-engineers/"><strong>Looper</strong></a>. Meta developed the Looper project for similar reasons as Apple. Looper helps build and operationalize ML models to support real-time use cases such as prediction and classification. Based on high level specifications from the user, Looper recommends configurations of models, parameters, features, etc. based on prepared blueprints. As of April 2022 Looper hosted 700 AI models and generated 4 million AI outputs per second.</p><p><a href="https://ludwig-ai.github.io/ludwig-docs/0.5/"><strong>Ludwig</strong></a>. Uber’s Ludwig project recommends features and model outputs based on simple user commands, while also enabling users to enter additional specifications for feature processing, model training, etc. They can adapt and scale by adding models, metrics, and functions to a unified configuration system. The startup <a href="https://predibase.com/">Predibase</a> offers a Declarative ML system based on Ludwig.</p><p>Another innovation in this space is predictive query language (PQL), offered via Predibase, which provides SQL-like commands for managing the ML lifecycle. PQL helps data scientists or data analysts use a familiar declarative interface as they connect with data, then train, deploy, and monitor ML models.</p><h4>Declarative ML in Practice</h4><p>To understand what this looks like in practice, let’s examine how Declarative ML compares with traditional approaches to the three stages of the ML lifecycle: data and feature engineering, model development, and model production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/0*UxqfnTtj8uB8N-Do" /></figure><h4>Data and feature engineering</h4><p><strong>Traditional approach. </strong>In this stage, the data scientist and data engineer ingest and transform data inputs from various sources. They apply common labels to historical outcomes, perform exploratory data analysis, and derive the most telling data inputs — called features — that they think will best predict outcomes.</p><p><strong>Declarative ML approach</strong>. A Declarative ML system<strong> </strong>will select and assemble features based on a simple specification by the data scientist or even data analyst. For example, to detect fraud using features such as purchase description and transaction type, the user just needs to specify the data types of the features. In this case, the data type for purchase description is “text,” and for transaction type it’s “category.” The Declarative ML system then presents a suggested set of features and model framework based on the data types.</p><h4>Model development</h4><p><strong>Traditional approach. </strong>In this stage, the data scientist experiments with various ML techniques. These can range from simple linear regressions that define the relationship between features and outputs, to deep learning neural networks that use multiple models for use cases such as image classification or natural language processing. The data scientist spends time training, tuning, and re-tuning parameters to make accurate predictions. They also might need to synchronize elements such as the layered algorithms that feed one another in an artificial neural network for deep learning.</p><p><strong>Declarative ML approach. </strong>A Declarative ML system automates this stage in a big way. Based on a few basic commands from the user, the system creates individual models that perform the tasks listed above. The data scientist or analyst reviews each model and how it relates to the others, approves or adjusts each, and kicks off the automated training process. The system inspects the outputs and adjusts features, parameters, and models to make them more accurate. Users can oversee, approve, or override steps along the way.</p><p>Similar to AutoML, users can train models without worrying about the minutiae. But Declarative ML does enable users to improve their models by iterating in a transparent and flexible way. They can inspect and make specific changes to features, parameters, and models based on their skills.</p><h4>Model production</h4><p><strong>Traditional approach</strong>. Once the ML model meets the requirements, the ML engineer takes the trained model from the data scientist and implements it in production applications or workflows. The ML engineer monitors model operations, including its performance, accuracy, cost, and potential bias. They also collaborate with data stewards to govern the model by cataloging key metrics and intervening when necessary to replace or re-train models.<strong> </strong>This process can become complex given the varying infrastructure, maintenance, and alerting requirements of different models and use cases.</p><p><strong>Declarative ML approach</strong>. A well-designed Declarative ML system<strong> </strong>can assist this stage by abstracting away complex ML infrastructure while providing metrics for model monitoring. It helps identify drifting data inputs or model outputs; inspect features, parameters, and models — and recommends actions to optimize these elements or fix issues. For instance, Predibase provides “blue-green” updates that allow users to quickly deploy models to a high-throughput, low-latency endpoint.</p><h4>Conclusion</h4><p>In summary, Declarative ML:</p><ul><li>Has been adopted by Uber (Ludwig), Apple (Overton), and Meta (Looper).</li><li>Offers a higher abstraction layer that provides flexibility, automation, ease-of-use.</li><li>Can improve efficiency across the entire ML life-cycles of feature engineering, model development, and production.</li></ul><p>While we’re early in the adoption curve, Declarative ML has the potential to reduce the time, effort, and skills required to bring ML into production in a wide range of enterprise environments. If you’d like to see what Declarative ML looks like in practice, I’d recommend requesting a demo from <a href="https://predibase.com/">Predibase</a> to learn more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2de3c1c7de2b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/declarative-machine-learning-and-the-future-of-data-science-2de3c1c7de2b">Declarative Machine Learning and the Future of Data Science</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit Testing Machine Learning Code in Ludwig and PyTorch: Tests for Gradient Updates]]></title>
            <link>https://medium.com/predibase/unit-testing-machine-learning-code-in-ludwig-and-pytorch-tests-for-gradient-updates-f1dc17b1461c?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/f1dc17b1461c</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[pytorch]]></category>
            <dc:creator><![CDATA[Jim Thompson]]></dc:creator>
            <pubDate>Thu, 27 Oct 2022 18:01:29 GMT</pubDate>
            <atom:updated>2022-10-27T18:02:31.476Z</atom:updated>
            <content:encoded><![CDATA[<p>Editors: <a href="https://medium.com/u/1c3f839d01cd">Justin Zhao</a>, <a href="https://medium.com/u/9714e35acce9">Daniel Treiman</a>, <a href="https://medium.com/u/eddb48e54738">Piero Molino</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*EDCmUALuYwJRK5sW" /></figure><p>A significant step was taken in <a href="https://medium.com/predibase/ludwig-v0-6-gradient-boosted-models-schema-validation-and-pipelined-torchscript-2e84bd342769">Ludwig 0.6</a> to improve the code quality of Ludwig components, e.g., encoders, combiners and decoders. All of these components may be implemented as deep neural networks, and may have trainable or fixed parameters. Deep neural networks have many layers composed of a large number of parameters that must be updated to converge to a solution. Depending on the particular algorithm, the code for updating parameters during training can be quite complex. As a result it is near impossible for a developer to reason through an analysis that confirms model parameters are updated.</p><p>In this article we’ll show how we introduced a mechanism for testing the updates of the weights to Ludwig, how it improved code quality and how it can be used by the PyTorch community</p><h3>How Neural Networks Are Trained</h3><p>At a high-level Figure 1 shows the typical training cycle for a neural network. Input features from the training data are fed into the neural network where training data are combined with network parameters to produce predictions. These predictions are compared to the target output features to compute loss values. Lower the loss, the better the model’s predictions match the training data. The backward pass computes the gradient of each parameter with respect to the total loss for each batch of training examples. These gradients are used by the optimizer to update the network parameters to minimize the total loss. This process is repeated many, many times until the model “converges” to a solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*vGxORMC3CaYc5QSO" /><figcaption><strong>Figure 1: Neural Network Training Cycle</strong></figcaption></figure><h3>Detecting Errors in Neural Architectures</h3><p>Computations performed in the forward pass range from very simple, sequential processing to a complex set of computations that depend on various factors, such as type of training data and pseudo random number values. If these complex computations are not handled correctly, this may produce miscalculations of the gradient and inconsistent updating of network parameters during the optimization step.</p><p>Errors in neural network architectures may be harder to detect since unlike regular code, no hard errors are generated. Subtle architecture issues may surface only during model training, manifesting as slightly reduced performance or slower convergence time.</p><h3>Introducing the check_module_parametes_updated utility</h3><p>To address this difficulty, a reusable utility called check_module_parametes_updated() was developed by the Ludwig team to perform a quick sanity check on Ludwig encoders, combiners and decoders to ensure parameters, such as weights and biases, are updated during one cycle. This work was inspired by these earlier blog postings: <a href="https://thenerdstation.medium.com/how-to-unit-test-machine-learning-code-57cf6fd81765"><em>How to unit test machine learning code</em></a> and <a href="https://towardsdatascience.com/testing-your-pytorch-models-with-torcheck-cb689ecbc08c">Testing Your PyTorch Models with </a><a href="https://towardsdatascience.com/testing-your-pytorch-models-with-torcheck-cb689ecbc08c">Torcheck</a>.</p><p>Before continuing, a note on terminology. For the remainder of the post, the term “parameter” will mean Torch’s <a href="https://pytorch.org/docs/stable/generated/torch.nn.parameter.Parameter.html#torch.nn.parameter.Parameter">Parameter object</a>. This should not be confused with the other use of the term “parameter” referring to the underlying Torch.tensor objects.</p><p>This code fragment illustrates this difference. For a fully connected layer (the FCLayer module in Ludwig) named fc_layer defined below, <strong>check_module_parameters_updated()</strong> returns 2 trainable Parameter objects, which represent weights and bias for that fc_layer. For the same object<strong> </strong>torchinfo.summary()<strong> </strong>reports there are 4,352 parameters. These are the individual tensors that make up fc_layer weights (16 X 256 = 4,096) and bias (256) that add up to 4,352.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lFj0vzOvsklJhT8F" /></figure><h3>How does check_module_parameters_updated() work?</h3><p>In a nutshell, the utility performs a minimal version of the core learning procedure in Figure 1 using synthetic data. As described in the function’s docstring, there are three required positional parameters:</p><ul><li>module: this is the instantiated Ludwig object to be tested, i.e., encoder, combiner, or decoder</li><li>module_input_args<strong>: </strong>tuple of synthetic tensor data that is passed to the forward() method of the module being tested.</li><li>module_target: target values used to compute losses.</li></ul><p>The other function parameters are optional with the specified default values, which can be modified if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gr3-90k-wD9dyS6C3NK-LQ.png" /></figure><p>Let’s now look at how the functionality is implemented. Before executing the steps shown in Figure 1, the function sets up some key objects, such as the loss function to use and the optimizer. As noted earlier there is some ability to customize these key objects with the optional function arguments.</p><p>The next bit of setup involves initializing data structures to capture results of the Figure 1 process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5IU33JOtFO9-Aq7G" /></figure><p>These are the key code fragments of the function:</p><p>This makes a forward pass with the synthetic input data through the Ludwig module under test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ik1N49nnSgo0ZknM" /></figure><p>After taking the forward pass through the module, the function computes the loss from the predicted value and target, after which it performs the backward pass to compute gradients and updates the Parameter objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*miHHbqRmVoxdHjLf" /></figure><p>The function checks each Parameter. If a Parameter object contains a non-zero gradient tensor it means it was updated. If it is updated, the Parameter is recorded in a list to keep track of what Parameters were updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*37kviu8BkTEePPiD" /></figure><p>As noted earlier this work was inspired by two other blog posts. These posts describe taking a copy of the parameters before the backward pass and optimizer step and compare the before values against the values after the optimizer step to see changes. In our approach, which depends on the gradient value only, we eliminate the need to duplicate and update the model’s parameters. Depending on the model could involve a large amount of memory.</p><p>After capturing all updated parameters, the utility now captures any parameter not updated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QyJSpJHEeZ9u-PSa" /></figure><p>Finally the function returns results of the above checks, which are:</p><ul><li>frozen_parameters : count of frozen parameters</li><li>trainable_parameters : count of trainable parameters</li><li>parameters_updated : count of updated parameters</li><li>parameters_not_updated : the list of parameters that are not updated, if any.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lDVuHg9_uiEnyB0X" /></figure><h3>How is check_module_parameters_updated() used in unit tests?</h3><p>First a developer will need a good understanding of PyTorch classes used to build neural networks. <a href="https://pytorch.org/docs/stable/nn.html">This knowledge is needed</a> to understand how Parameter objects are used in the classes.</p><p>With this understanding, the developer will need to understand the number and types of Parameters that are contained in the Ludwig module to be tested. One method is by printing the module. Using the fc_layer object from the earlier example, we see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1u2OUl4QHL8j-is3" /></figure><p>This shows fc_layer is made up of torch.nn.Linear and torch.nn.ReLU classes. From the perspective of Parameter, fc_layer contains 2 Parameters (weights and bias in torch.nn.Linear). The torch.nn.ReLU is an activation function and does not contain a Parameter.</p><p>We ‘ll now show two examples of unit tests using the check function. The Ludwig Developer Guide contains a <a href="https://ludwig.ai/latest/developer_guide/unit_test_design_guidelines/#test-for-parameter-updates">section </a>that describes how to incorporate parameter update checking into the unit tests in more detail.</p><h3>Simple Parameter update check</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*clgu4A69SkD37WJO" /></figure><p>This unit test is composed of these steps:</p><ul><li>Set the random seed to ensure repeatability</li><li>Create synthetic input tensor and instantiate the ResNetEncoder to test</li><li>Confirm the output contains the expected content and is the correct shape</li><li>Create synthetic target tensor and use it to check for parameter updates</li></ul><p>In this simple case, the number of updated parameters (upc) should equal the number of trainable parameters (tpc). If this is not the case, raise an AssertionError because some of the parameters that should have been updated were not.</p><p>The situation where upc == tpc is, for the most part, the expected case and is the approach described in the two blog posts mentioned earlier. However, there are times when this is not the case and is not an error. The next example illustrates this situation.</p><h3>Complex Parameter update check</h3><p>This covers one of the unit tests for the TabTransformerCombiner. To understand circumstances when upc != tpc one needs to understand how <a href="https://arxiv.org/abs/2012.06678">TabTransformer works</a>. Figure 2, which comes from the paper, shows the TabTransformer architecture. From this we see there are two processing paths through the network. One path involves categorical features and the other involves numerical (aka continuous) features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*3Oz2hGpmS65ULf6eCtVooA.png" /></figure><p><strong>Figure 2: TabTransformer Architecture</strong></p><p>For the situation where it is not possible to know ahead of time if categorical features will be in the input, then Parameters associated with the Transformer stack may not be used at all. While the count of trainable parameters will include all Parameters in the model, the Transformer only parameters will not be reflected in the count of updated parameters. For this situation, adjustments need to be made to reflect this operation. This is shown in the final Assert check where the number of parameters in the Transformer stack is subtracted from the count of trainable parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*U-QtmoJ8dUk-uFxV" /></figure><h3>Summary</h3><p>As neural network architectures become more sophisticated, their processing complexity increases. This makes it almost impossible to verify their correct operation through static analyses, such as code reviews. The check_module_parameters_updated() function was developed to assist Ludwig developers in confirming correct operation of Ludwig components. An advanced user who is developing custom components can also use this capability in their work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1dc17b1461c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/unit-testing-machine-learning-code-in-ludwig-and-pytorch-tests-for-gradient-updates-f1dc17b1461c">Unit Testing Machine Learning Code in Ludwig and PyTorch: Tests for Gradient Updates</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ludwig v0.6 — Gradient Boosted Models, Schema Validation, and Pipelined TorchScript]]></title>
            <link>https://medium.com/predibase/ludwig-v0-6-gradient-boosted-models-schema-validation-and-pipelined-torchscript-2e84bd342769?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/2e84bd342769</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Justin Zhao]]></dc:creator>
            <pubDate>Wed, 05 Oct 2022 17:41:11 GMT</pubDate>
            <atom:updated>2022-10-05T21:51:02.800Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ludwig 0.6: Gradient Boosted Models, Config Validation, and Pipelined TorchScript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ym-3p6j1uRcGiNhU2_QPlQ.png" /></figure><p><strong>Authors:</strong> <a href="https://github.com/jppgks">Joppe Geluykens</a>, <a href="https://medium.com/u/9714e35acce9">Daniel Treiman</a>, <a href="https://medium.com/u/d7f1cf49523f">Connor McCormick</a>, <a href="https://medium.com/u/9b9b6ae518c0">Arnav Garg</a>, <a href="https://medium.com/u/2ef1c9f34ecd">Travis Addair</a>, <a href="https://medium.com/u/92fe48c67854">Geoffrey Angus</a>, <a href="https://medium.com/u/465015f53a93">Julian Bright</a>, <a href="https://medium.com/u/a9c8fc013a29">Jim Thompson</a>.</p><p><strong>Editors:</strong> <a href="https://medium.com/u/1c3f839d01cd">Justin Zhao</a>, <a href="https://medium.com/u/1dad367afd91">Daliana Liu</a>, <a href="https://medium.com/u/eddb48e54738">Piero Molino</a>.</p><h3>Overview</h3><p><a href="http://ludwig.ai/">Ludwig</a> is an open-source <strong>declarative machine learning framework</strong> that enables you to train and deploy state-of-the-art tabular, natural language processing, and computer vision models by just writing a configuration.</p><p><a href="https://medium.com/predibase/ludwig-0-5-declarative-machine-learning-now-on-pytorch-1268a6432646">Earlier this year</a>, we migrated our entire backend from TensorFlow to PyTorch. In this <a href="https://github.com/ludwig-ai/ludwig/releases/tag/v0.6">latest release</a>, we’ve capitalized on the benefits of being on a fully PyTorch backend — adding <strong>Gradient Boosted Models (GBMs)</strong>, expanding options for <strong>deployment</strong> with <strong>Pipelined TorchScript</strong> and <strong>NVIDIA Triton</strong>, all while continuing to improve <strong>testing and stability</strong> with <strong>parameter update tests</strong> and <strong>config validation</strong>.</p><p>All of this, in addition to support for <a href="https://docs.ray.io/en/latest/index.html">Ray 2.0</a>, makes <a href="https://pypi.org/project/ludwig/">Ludwig 0.6</a> a great platform for machine learning, supporting a variety of state-of-the-art ML models combined with MLOps best practices packaged in the form of a simple configuration interface.</p><p>Ludwig 0.6 feature highlights:</p><ul><li><strong>Gradient boosted models: </strong>Historically, Ludwig has been built around a single, flexible neural network architecture called ECD (for Encoder-Combiner-Decoder). With the release of 0.6 we are adding support an additional model architecture: <a href="https://lightgbm.readthedocs.io/en/v3.3.2/">gradient-boosted tree models</a> (GBMs).</li><li><strong>Configuration type checking and schema validation</strong>: We’ve defined a formalized Ludwig configuration schema that validates configurations at initialization time, which can help you avoid mistakes like typos and syntax errors.</li><li><strong>Calibrating probabilities for category and binary output features: </strong>With deep neural networks, probabilities given by models often don’t match the true likelihood of the data. Ludwig now supports temperature scaling calibration (<a href="https://arxiv.org/abs/1706.04599">On Calibration of Modern Neural Networks</a>), which brings class probabilities closer to their true likelihoods in the validation set.</li><li><strong>Pipelined TorchScript: </strong>We improved the TorchScript model export functionality, making it easier than ever to train and deploy models for high performance inference.</li><li><strong>Model parameter update unit tests</strong>: The code to update parameters of deep neural networks is complex for developers to make sure the model parameters are updated. To address this difficulty and improve the robustness of our models, we implemented a reusable utility to ensure parameters are updated during one cycle of a forward-pass / backward-pass / optimizer step.</li></ul><p>Additional improvements include a new <strong>global configuration section</strong>, <strong>time-based dataset splitting</strong> and more <strong>flexible hyperparameter optimization configurations</strong>. Read more about specific features below!</p><p>If you are learning about Ludwig for the first time, or if these new features are relevant and exciting to your research or application, we’d love to hear from you. <a href="https://join.slack.com/t/ludwig-ai/shared_invite/zt-mrxo87w6-DlX5~73T2B4v_g6jj0pJcQ">Join our Ludwig Slack Community</a>.</p><h3>Gradient Boosted Models</h3><p>Historically, Ludwig has been built around a single, flexible neural network architecture called ECD (for Encoder-Combiner-Decoder). With the release of 0.6 we are, adding support an additional model architecture: gradient-boosted tree models (GBM).</p><p>This is motivated by the fact that tree models <a href="https://arxiv.org/abs/2106.11189">still outperform</a> neural networks on some tabular datasets, and the fact that tree models are generally less compute-intensive, making them a better choice for some applications. In Ludwig, you can now experiment with both neural and tree-based architectures within the same framework, taking advantage of all of the additional functionalities and conveniences that Ludwig offers like: preprocessing, hyperparameter optimization, integration with different backends (local, ray, horovod), and interoperability with different data sources (pandas, dask, modin).</p><p><strong>How to use GBMs?</strong></p><p>Install the tree extra package with pip install ludwig[tree]. After the installation, you can use the new gbm model type in the configuration. Ludwig will default to using the ECD architecture, which can be overridden as follows to use GBM:</p><pre>model_type: gbm</pre><p>In some initial benchmarking we found that GBMs are particularly performant on smaller tabular datasets and can sometimes deal better with class imbalance compared to neural networks. Like the ECD neural networks, GBMs can be sensitive to hyperparameter values, and hyperparameter tuning is important to get a well-performing model.</p><p>Under the hood, Ludwig uses <a href="https://lightgbm.readthedocs.io/en/v3.3.2/">LightGBM</a> for training gradient-boosted tree models, and the LightGBM trainer parameters can be configured in the trainer section of the configuration. For serving, the LightGBM model is converted to a PyTorch graph using <a href="https://www.microsoft.com/en-us/research/group/gray-systems-lab/articles/announcing-hummingbird-a-library-for-accelerating-inference-with-traditional-machine-learning-models/">Hummingbird</a> for efficient evaluation and inference.</p><p><strong>Limitations</strong></p><p>Ludwig’s initial support for GBM is limited to tabular data (binary, categorical and numeric features) with a single output feature target.</p><h3>Calibrating probabilities for category and binary output features</h3><p>Suppose your model outputs a class probability of 90%. Is there a 90% chance that the model prediction is correct? Do the probabilities given by your model match the true likelihood of the data? With deep neural networks, they often don’t.</p><p>Drawing on the methods described in <a href="https://arxiv.org/abs/1706.04599">On Calibration of Modern Neural Networks</a> (Chuan Guo, Geoff Pleiss, Yu Sun, Kilian Q. Weinberger), Ludwig now supports temperature scaling for binary and category output features. Temperature scaling brings a model’s output probabilities closer to the true likelihood while preserving the same accuracy and top k predictions.</p><p><strong>How to use Calibration</strong></p><p>To enable calibration, add calibration: true to any binary or category output feature configuration:</p><pre>output_features:<br>  - name: Cover_Type<br>    type: category<br>    calibration: true</pre><p>With calibration enabled, Ludwig will find a scale factor (temperature) which will bring the class probabilities closer to their true likelihoods in the validation set. The calibration scale factor is determined in a short phase after training is complete. If no validation split is provided, the training set is used instead.</p><p>To visualize the effects of calibration in Ludwig, you can use <a href="https://ludwig-ai.github.io/ludwig-docs/0.5/user_guide/visualizations/#calibration-plot">Calibration Plots</a>, which bin the data based on model probability and plot the model probability (X) versus observed (Y) for each bin (see <a href="https://github.com/ludwig-ai/ludwig/tree/master/examples/calibration">code examples</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*sTsZCROgbx-pPQWc" /><figcaption>Example of a probability calibration plot.</figcaption></figure><p>In a perfectly calibrated model, the observed probability equals the predicted probability, and all predictions will land on the dotted line y=x. In <a href="https://github.com/ludwig-ai/ludwig/tree/master/examples/calibration/train_forest_cover_calibrated.py">this example using the forest cover dataset</a>, the uncalibrated model in blue gives over-confident predictions near the left and right edges close to probability values of 0 or 1. Temperature scaling learns a scale factor of 0.51 which improves the calibration curve in orange, moving it closer to y=x.</p><p><strong>Limitations</strong></p><p>Calibration is currently limited to models with binary and category output features.</p><h3>Config type checking and schema validation</h3><p>Ludwig configurations are flexible by design, as they internally map to Python function signatures. This allows for expressive configurations, but we have found that users would too easily have typos in their configs like incorrect value types or other syntactical inconsistencies.</p><p>We have now formalized the Ludwig config with a strongly typed <strong>schema</strong>, which also serves as a centralized source of truth for <strong>parameter documentation</strong> and <strong>config validation</strong>. Ludwig configurations are now rigorously checked for valid types and values, flagging issues early at model initialization time.</p><h3>Nested encoder and decoder parameters</h3><p>We have also restructured the way that encoders and decoders are configured to now use a <strong>nested structure</strong>, consistent with other modules in Ludwig such as combiners and loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhgUkGEm53xgWggHM4l3hQ.png" /><figcaption>Encoder and decoder parameters are now nested.</figcaption></figure><p>As these changes impact what constitutes a valid Ludwig config, we introduced a registration mechanism to ensure backward compatibility with older versions of Ludwig. Older configs are invisibly and automatically upgraded to the latest config structure.</p><p>We hope that with the new Ludwig schema and the improved encoder/decoder nesting structure, you find using Ludwig to be a much more robust and user-friendly experience!</p><h3>New Defaults Ludwig Section</h3><p>In older versions of Ludwig, you can specify preprocessing parameters on a per-feature-type basis through the global preprocessing section in Ludwig configs. This is useful for applying certain transformations to their data for every feature of the <strong>same type</strong>. However, there was no equivalent mechanism for global encoder, decoder or loss related parameters.</p><p>In Ludwig 0.6, we are introducing a new defaults section within the Ludwig config to define all feature-type defaults for preprocessing, encoders, decoders, and loss. Default preprocessing and encoder configurations will be applied to all input_features of that feature type, while decoder and loss configurations will be applied to all output_features of that feature type.</p><p>Note that you can still specify feature specific parameters as usual, and these will override any default parameter values that come from the global defaults section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkMRLnQmdGxwcuGzYMO1Lg.png" /><figcaption>Example of a config of a mammography dataset to predict breast cancer that contains many categorical features. In Ludwig 0.6, common encoder parameters can be declared once in the config’s ‘defaults’ section. Here, the encoder defaults for type, dropout and embedding_size are applied to all three categorical features. The he_normal embedding initializer is only applied to tumor_size and inv_nodes since we didn’t specify this parameter in their feature definitions, but breast_quadrant will use the glorot_normal initializer since it will override the value from the defaults section.</figcaption></figure><p>The defaults section enables the same fine-grained control as before with the benefit of making your config easier to define and read.</p><h3>Global Defaults In Hyperopt</h3><p>The defaults section has also been added to hyperopt, so that you can define feature-type level parameters for individual trials. This makes the definition of the hyperopt search space more convenient, without the need to define individual parameters for each of the features in instances where the dataset has a large number of input or output features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yC0kS-MMLvQBFQsslqrUoQ.png" /><figcaption>Example of how to specify feature-type global defaults in the hyperopt sub-config. For example, if you want to hyperopt over different encoders for all text features for each of the trials, you can do so by defining a parameter this way. This will sample one of the three encoders for text features and apply it to all the text features for that particular trial.</figcaption></figure><h3>Configs Blocks In Hyperopt</h3><p>We have extended the range of hyperopt parameters to support parameter choices that consist of partial or complete blocks of nested Ludwig config sections. This allows you to search over a set of Ludwig configs, as opposed to needing to specify config params individually and search over all combinations.</p><p>To provide a parameter that represents a full top-level Ludwig config, the . key name can be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZKR_U31PpTm6g9AgvVctkA.png" /><figcaption>Hyperopt search spaces with configuration blocks are sampled block-wise.</figcaption></figure><h3>Pipelined TorchScript</h3><p>In Ludwig 0.6, we improved the TorchScript model export functionality, making it easier than ever to train and deploy models for high performance inference.</p><p>At the core of our implementation is a pipeline-based approach to exporting models. After training a Ludwig model, you can run the export_torchscript command in the CLI, or call LudwigModel.save_torchscript. If model training was performed on a GPU device, doing so produces three new TorchScript artifacts:</p><pre>torchscript/<br>  inference_preprocessor.pt<br>  inference_predictor_cuda.pt<br>  inference_postprocessor.pt</pre><p>These artifacts represent a single LudwigModel as three modules, each separated by stage: preprocessing, prediction, and postprocessing. These artifacts can be pipelined together using the InferenceModule class method InferenceModule.from_directory, or with some tools such as NVIDIA Triton.</p><p>One of the most significant benefits is that TorchScripted models are backend and environment independent and different parts can run on different hardware to maximize throughput. They can be loaded up in either a C++ or Python backend, and in either, minimal dependencies are required to run model inference. Such characteristics ensure that the model itself is both highly portable and backward compatible.</p><h3>Time-based Dataset Splitting</h3><p>In Ludwig 0.6, we have added the ability to split based on a date column such that the data is ordered by date (ascending) and then split into train-validation-test along the time dimension. To make this possible, we have reworked the way splitting is handled in the Ludwig configuration to support a dedicated split section:</p><pre>preprocessing:<br>    split:<br>        type: datetime<br>        column: created_ts<br>        probabilities: [0.7, 0.1, 0.2]</pre><p>In this example, by setting probabilities: [0.7, 0.1, 0.2], the earliest 70% of the data will be used for training, the middle 10% used for validation, and the last 20% used for testing.</p><p>This feature is important to support <a href="https://en.wikipedia.org/wiki/Backtesting">backtesting</a> strategies where you may need to know if a model trained on historical data would have performed well on unseen future data. If we were to use a uniformly random split strategy in these cases, then the model performance may not reflect the model’s ability to generalize well if the data distribution is subject to change over time. For example, imagine a model that is predicting housing prices. If we both train and test on data from around the same time, we may fool ourselves into believing our model has learned something fundamental about housing valuations when in reality it might just be basing its predictions on recent trends in the market (trends that will likely change once the model is put into production). Splitting the training from the test data along the time dimension is one way to avoid this false sense of confidence, by showing how well the model should do on unseen data from the future.</p><p>Prior to Ludwig 0.6, the preprocessing configuration supported splitting based on a split column, split probabilities (train-val-test), or stratified splitting based on a category, all of which were flattened into the top-level of the preprocessing section:</p><pre>preprocessing:<br>    force_split: false<br>    split_probabilities: [0.7, 0.1, 0.2]<br>    stratify: null</pre><p>This approach was limiting in that every new split type required reconciling all of the above params and determining how they should interact with the new type. To resolve this complexity, all of the existing split types have been similarly reworked to follow the new structure supported for datetime splitting.</p><p><strong>Examples:</strong></p><p>Splitting by row at random (default).</p><pre>preprocessing:<br>    split:<br>        type: random<br>        probabilities: [0.7, 0.1, 0.2]</pre><p>Splitting based on a fixed split column.</p><pre>preprocessing:<br>    split:<br>        type: fixed<br>        column: split</pre><p>Stratified splits using a chosen stratification category column.</p><pre>preprocessing:<br>    split:<br>        type: stratify<br>        column: color<br>        probabilities: [0.7, 0.1, 0.2]</pre><p>Be on the lookout as we continue to add additional split strategies in the future to support advanced usage such as bucketed backtesting. If you are interested in these kinds of scenarios, please reach out!</p><h3>Parameter Update Unit Tests</h3><p>A significant step was taken in this release to improve the code quality of Ludwig components, e.g., encoders, combiners, and decoders. Deep neural networks have many layers composed of a large number of parameters that must be updated to converge to a solution. Depending on the particular algorithm, the code for updating parameters during training can be quite complex. As a result, it is near impossible for a developer to reason through an analysis that confirms model parameters are updated.</p><p>To address this difficulty, we implemented a reusable utility to perform a quick sanity check to ensure parameters, such as tensor weights and biases, are updated during one cycle of a forward-pass / backward-pass / optimizer step. This work was inspired by these earlier blog postings: <a href="https://thenerdstation.medium.com/how-to-unit-test-machine-learning-code-57cf6fd81765">How to unit test machine learning code</a> and <a href="https://towardsdatascience.com/testing-your-pytorch-models-with-torcheck-cb689ecbc08c">Testing Your PyTorch Models with Torcheck</a>.</p><p>This utility was added to unit tests for existing Ludwig components. With this addition, unit tests for Ludwig now ensure the following:</p><ul><li>No run-time exceptions are raised</li><li>Generated output has the correct data type and shape</li><li><em>(New capability) </em>Model parameters are updated as expected</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cagD0gy6Sr-B7zSaML62_Q.png" /><figcaption>Sample code for parameter update unit tests.</figcaption></figure><p>The above is an example of a unit test. First, it sets the random number seed to ensure repeatability. Next, the test instantiates the Ludwig component and processes synthetic data to ensure the component does not raise an error and that the output has the expected shape. Finally, the unit test checks if the parameters are updated under the different combinations of configuration settings.</p><p>In addition to the new parameter update check utility, <a href="https://ludwig.ai/latest/developer_guide/">Ludwig’s Developer Guide</a> contains instructions for using the utility. This allows contributors developing custom encoders, combiners, or decoders, to ensure the quality of their custom component.</p><h3>Stay in the loop</h3><p>Ludwig thriving open source community gathers on <a href="https://join.slack.com/t/ludwig-ai/shared_invite/zt-mrxo87w6-DlX5~73T2B4v_g6jj0pJcQ">Slack</a>, join it to get involved!</p><p>If you are interested in adopting Ludwig in the enterprise, check out <a href="http://predibase.com/">Predibase</a>, the declarative ML platform that connects with your data, manages the training, iteration, and deployment of your models, and makes them available for querying, reducing time to value of machine learning projects.</p><p>Congratulations to our new contributors!</p><ul><li><a href="https://github.com/Marvjowa">@Marvjowa</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2236">#2236</a></li><li><a href="https://github.com/Dennis-Rall">@Dennis-Rall</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2192">#2192</a></li><li><a href="https://github.com/abidwael">@abidwael</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2263">#2263</a></li><li><a href="https://github.com/noahlh">@noahlh</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2284">#2284</a></li><li><a href="https://github.com/jeffkinnison">@jeffkinnison</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2316">#2316</a></li><li><a href="https://github.com/andife">@andife</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2358">#2358</a></li><li><a href="https://github.com/alberttorosyan">@alberttorosyan</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/2413">#2413</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e84bd342769" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/ludwig-v0-6-gradient-boosted-models-schema-validation-and-pipelined-torchscript-2e84bd342769">Ludwig v0.6 — Gradient Boosted Models, Schema Validation, and Pipelined TorchScript</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ludwig 0.5: Declarative Machine Learning, now on PyTorch]]></title>
            <link>https://medium.com/predibase/ludwig-0-5-declarative-machine-learning-now-on-pytorch-1268a6432646?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1268a6432646</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Justin Zhao]]></dc:creator>
            <pubDate>Wed, 29 Jun 2022 19:32:39 GMT</pubDate>
            <atom:updated>2022-06-30T23:04:51.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADY5GfAmrt-E1WGeOlr7CQ.png" /></figure><p>Authors: <a href="https://medium.com/u/1c3f839d01cd">Justin Zhao</a>, <a href="https://medium.com/u/67b11f615a47">Shreya Rajpal</a>, <a href="https://medium.com/u/9714e35acce9">Daniel Treiman</a>, Jim Thompson, <a href="https://medium.com/u/2ef1c9f34ecd">Travis Addair</a>, <a href="https://medium.com/u/eddb48e54738">Piero Molino</a></p><p><a href="https://ludwig-ai.github.io/ludwig-docs/">Ludwig</a> is an open-source declarative deep learning framework that enables individuals from a variety of backgrounds to train and deploy <a href="https://medium.com/ludwig-ai/ludwig-ai-v0-4-introducing-declarative-mlops-with-ray-dask-tabnet-and-mlflow-integrations-6509c3875c2e">state-of-the-art tabular, natural language processing, and computer vision models</a>.</p><p><a href="https://ludwig-ai.github.io/ludwig-docs/">Ludwig 0.5</a> is a complete renovation of Ludwig from the ground up with a focus on <strong>scalability</strong>, <strong>deployment</strong>, <strong>reliability</strong>, and <strong>documentation</strong>. Ludwig v0.5 migrates our entire backend from TensorFlow to PyTorch and introduces several new features and technical improvements, including:</p><ul><li><strong>Step-based training and evaluation</strong> to enable frequent sub-epoch monitoring of model health and evaluation metrics. This is particularly useful when training on large dataset to get feedback more quickly.</li><li><strong>Data balancing</strong>: upsampling and downsampling during preprocessing to train on better proportioned datasets.</li><li><strong>End-to-end torchscript export </strong>to support low-level optimized model deployment, including preprocessing and post-processing, to go directly from example to predictions.</li><li><strong>Ludwig on Ray with </strong><a href="https://docs.ray.io/en/latest/data/dataset.html"><strong>RayDatasets</strong></a> enabling significant training speed boosts for reading large datasets while training Ludwig models on a Ray cluster.</li><li>The addition of <a href="https://arxiv.org/abs/2105.01601">MLPMixer</a> and <a href="https://huggingface.co/docs/transformers/model_doc/vit">ViTEncoder</a> as image encoders for state-of-the-art deep learning on image data.</li><li><strong>AutoML</strong> for <a href="https://medium.com/ludwig-ai/ludwig-automl-for-deep-learning-cf64de9d49c8">tabular</a> and <a href="https://medium.com/ludwig-ai/ludwig-automl-for-text-classification-7c1759f3b150">text classification</a>, integrated with distributed hyperparameter search using <a href="https://docs.ray.io/en/latest/tune/index.html">RayTune</a>.</li><li><strong>Scalability optimizations</strong> with Dask, Modin, and Ray, enabling Ludwig to preprocess, train, and evaluate over datasets hundreds of gigabytes in size in tens of minutes.</li><li><strong>Config validation</strong> using marshmallow schemas revealing configuration typos or bad values early and increasing reliability.</li><li><strong>More tests.</strong> We’ve quadrupled the number of unit tests and end-to-end integration tests and we’ve expanded our CI testing to run in distributed and GPU settings. This strengthens Ludwig’s stability and reliability.</li><li><strong>Export to </strong><a href="https://developer.nvidia.com/nvidia-triton-inference-server"><strong>NVIDIA Triton</strong></a>. <a href="https://github.com/ludwig-ai/ludwig/pull/2078">Deploy Ludwig models</a> directly Triton servers.</li><li><strong>Consolidate hyperopt around </strong><a href="https://docs.ray.io/en/latest/tune/index.html"><strong>RayTune</strong></a><strong> </strong>with the ability to stop and resume hyperopt runs.</li><li><strong>Integration with Aim for experiment tracking</strong>. Use Aim to log Ludwig training runs, and use a beautiful UI to compare them and Aim APIs to query them programmatically.</li></ul><p>Our team at <a href="http://www.predibase.com/">Predibase</a> and the entire open source Ludwig community is thoroughly invested in improving the declarative ML experience, and, as part of the v0.5 release, we’ve revamped the <a href="https://ludwig-ai.github.io/ludwig-docs/latest/getting_started">getting started guide</a>, <a href="https://ludwig-ai.github.io/ludwig-docs/latest/user_guide/">user guide</a>, and <a href="https://ludwig-ai.github.io/ludwig-docs/latest/developer_guide/">developer documentation</a>. We’ve also published a new <a href="https://ludwig-ai.github.io/ludwig-docs/latest/examples/text_classification/">end-to-end tutorials</a> with thoroughly documented notebooks on text, tabular, image, and multimodal classification that provide a deep walkthrough of Ludwig’s functionality.</p><h3>Migrating to PyTorch</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XoGkM8HkkP3TzSpQ.png" /></figure><p>Ludwig’s migration to PyTorch comes from a substantial 6 month undertaking involving <a href="https://github.com/ludwig-ai/ludwig/compare/v0.4...v0.5">230+ commits, changes to 70k+ lines of code, and contributions from 40+ people</a>. This culminated in an <a href="https://medium.com/pytorch/ludwig-on-pytorch-1241776417fc">article published in the official PyTorch blog</a> describing Ludwig on PyTorch in more detail.</p><p>PyTorch’s pythonic design and emphasis on developer experience are well-aligned with Ludwig’s principles of simplicity, modularity, and extensibility. Switching to use PyTorch as Ludwig’s backend of choice was strongly motivated by the increase in productivity in development, debugging, and iteration that the more pythonic PyTorch API affords us as well as the great ecosystem the PyTorch community has built around it. With Ludwig on PyTorch, we’re thrilled to see what developers, researchers, and data scientists in the PyTorch and broader deep learning community can bring to Ludwig.</p><h3>Feature and performance parity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fydw1g5D_cuLjM0D" /><figcaption>The number of examples per second training a model on the <a href="http://wikidata.dbpedia.org/develop/datasets">DBPedia dataset</a> (text classification) on a single machine and using distributed training across multiple workers. While the training speed is similar between v0.4 and v0.5 on a single worker, as we add more workers, training speed increases significantly in PyTorch.</figcaption></figure><p>Over the last several months, we’ve moved all Ludwig <a href="https://ludwig-ai.github.io/ludwig-docs/latest/user_guide/how_ludwig_works/#ecd-architecture">encoders, combiners, decoders, and metrics</a> for <a href="https://ludwig-ai.github.io/ludwig-docs/latest/configuration/features/supported_data_types/">every data modality that Ludwig supports</a>, as well as all of the backend infrastructure on Horovod and Ray, to PyTorch.</p><p>At the same time, we wanted to make sure that the experience of Ludwig users continues to be performant and delightful. We’ve run extensive comparisons between Ludwig v0.5 (PyTorch-based) and Ludwig v0.4 on text, image, and tabular datasets, evaluating training speed, inference throughput, and model performance, to verify that there’s been no degradation.</p><p>Our results, published on the <a href="https://medium.com/pytorch/ludwig-on-pytorch-1241776417fc">official PyTorch blog</a>, reveal roughly the same high GPU utilization (~90%) on several datasets with significant improvements in distributed training speed and memory usage without impacting model accuracy nor time to convergence.</p><h3>New features</h3><p>In addition to the PyTorch migration, Ludwig v0.5 is packed with new functionality, features, and additional changes that make v0.5 the most feature-rich and robust release of Ludwig yet.</p><h3><a href="https://docs.google.com/document/d/1T_CJqvnzH_TAA57-4U-E6vK5IjN8zHKoRHChNUGjR1I/edit#">Step-based training and evaluation</a></h3><p>Ludwig’s train loop is epoch-based by default, with one round of evaluation per epoch (one pass through the dataset).</p><pre>for epoch in num_epochs:<br>	for batch in training_data.batches:<br>		train(batch)<br>        save_model(model_dir)<br>	evaluation(training_data)<br>        evaluation(validation_data)<br>        evaluation(test_data)<br>        print_results()</pre><p>This is an appropriate approach for small datasets that fit in memory and train quickly. However, when training on big unstructured datasets that used to train large models , it leads to getting unfrequent assessments of model performance. With step-based training and evaluation, users can configure a more frequent sub-epoch evaluation cadence to more regularly monitor metrics and model health.</p><p>Use steps_per_checkpoint to run evaluation every N training steps:</p><pre>trainer:<br>    steps_per_checkpoint: 1000</pre><p>Or checkpoints_per_epoch to run evaluation N times per epoch.</p><pre>trainer:<br>    checkpoints_per_epoch: 2</pre><p>Note that it is invalid to specify both checkpoints_per_epoch and steps_per_checkpoint simultaneously.</p><p>To further speed up evaluation, users can skip evaluation on the training set by setting evaluate_training_set to False.</p><pre>trainer:<br>    evaluate_training_set: false</pre><h3><a href="https://ludwig-ai.github.io/ludwig-docs/latest/configuration/preprocessing/#data-balancing">Data balancing</a></h3><p>Users working with imbalanced datasets for binary classification can specify an oversampling or undersampling parameter which will balance the training set during preprocessing.</p><p>In this example, Ludwig will oversample the minority class to achieve a 50% representation in the overall dataset.</p><pre>preprocessing:<br>    oversample_minority: 0.5</pre><p>In this example, Ludwig will undersample the majority class to achieve a 70% representation in the overall dataset.</p><pre>preprocessing:<br>    undersample_majority: 0.7</pre><h3><strong>Data subsampling</strong></h3><p>When developing models, it can be useful to iterate quickly with a smaller portion of the dataset. Ludwig supports this with a new preprocessing parameter, sample_ratio, which subsamples the dataset.</p><pre>preprocessing:<br>    sample_ratio: 0.3</pre><h3><a href="https://ludwig-ai.github.io/ludwig-docs/0.5/user_guide/command_line_interface/#export_torchscript">End-to-end torchscript</a></h3><p>Users can export trained ludwig models to torchscript with ludwig export_torchscript.</p><pre>ludwig export_torchscript –-model=/path/to/model</pre><p>Models that use binary, number, category, and text features now support torchscript-compatible preprocessing, enabling end-to-end torchscript compilation.</p><pre>inputs = {<br>    &#39;cat_feature&#39;: [&#39;foo&#39;, &#39;bar&#39;]<br>    &#39;num_feature&#39;: torch.tensor([42, 7])<br>    &#39;bin_feature1&#39;: torch.tensor([True, False])<br>    &#39;bin_feature2&#39;: [&#39;No&#39;, &#39;Yes&#39;]<br>}</pre><pre>scripted_model = model.to_torchscript()<br>output = scripted_model(inputs)</pre><p>End to end torchscript compilation is also supported for text features that use torchscript-enabled torchtext tokenizers. We are actively working on adding support for other data types.</p><h3>AutoML for text classification</h3><p>In v0.4, we introduced experimental AutoML functionalities into Ludwig.</p><p>Ludwig AutoML automatically creates deep learning models given a dataset, its label column, and a time budget. Ludwig AutoML infers the input and output feature types, chooses the model architecture, and specifies the parameters and ranges across which to perform hyperparameter search.</p><pre>auto_train_results = ludwig.automl.auto_train(<br>   dataset=my_dataset_df,<br>   target=target_column_name,<br>   time_limit_s=7200,<br>   tune_for_memory=False<br>)</pre><p>Our <a href="https://medium.com/ludwig-ai/ludwig-automl-for-deep-learning-cf64de9d49c8">initial AutoML work</a> focused on tabular datasets, since good performance on such datasets is a current area of interest in the deep learning community. In v0.5, we expand on this work to develop and validate <a href="https://medium.com/ludwig-ai/ludwig-automl-for-text-classification-7c1759f3b150">Ludwig AutoML for text classification</a>.</p><h3>Config validation against marshmallow schemas</h3><p>The combiner and trainer sections of Ludwig configurations are now validated against official <a href="https://marshmallow.readthedocs.io/en/stable/">Marshmallow</a> schemas. This centralizes documentation, flags configuration typos or bad values, and helps catch regressions. Other parts of the Ludwig configurations will be covered soon.</p><h3>Better test coverage</h3><p>We’ve quadrupled the number of unit and integration tests and we’ve established new <a href="https://ludwig-ai.github.io/ludwig-docs/latest/developer_guide/unit_test_design_guidelines/">testing guidelines</a> for well-tested contributions going forward. We’ve also expanded our CI testing to run in distributed and GPU settings. This strengthens Ludwig’s stability and reliability, and makes it easier for new contributors to submit PRs with confidence.</p><h3>Export to Triton</h3><p>Export a Ludwig model in torchscript format with config for Triton serving.</p><pre>ludwig export_triton \<br>    --model_path=/path/to/model \<br>    --model_name=&quot;my model&quot; \<br>    --model_version=1.0 \<br>    --output_path=.</pre><h3>Integration with Aim for experiment tracking</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SP9-EnQKNo4oTIRl.gif" /></figure><p>Thanks to the contribution from <a href="https://medium.com/u/a8b279597f5d">Erik Arakelyan</a>, Ludwig now also integrates with Aim for experiment tracking. Aim enables users to log Ludwig training runs, and use a beautiful UI to compare them and APIs to query them programmatically.</p><h3>Backward compatibility</h3><p>Despite all of the code changes, we’ve worked hard to ensure that Ludwig’s simple interface remains consistent and compatible with earlier releases as much as possible. A few minor parameter naming changes in the Ludwig configuration to be aware of:</p><pre>+------------------------+------------------------------+<br>|    old config name     |       new config name        |<br>+------------------------+------------------------------+<br>| training               | trainer                      |<br>| numeric                | number                       |<br>| fc_size                | output_size                  |<br>| tied_weights           | tied                         |<br>| bias                   | use_bias                     |<br>| weight_regularizer     | regularization_{lambda/type} |<br>| bias_regularizer       | regularization_{lambda/type} |<br>| activation_regularizer | regularization_{lambda/type} |<br>+------------------------+------------------------------+</pre><p>The hyperopt section has also been <a href="https://ludwig-ai.github.io/ludwig-docs/0.5/configuration/hyperparameter_optimization/">refactored</a> to be unified with RayTune’s naming conventions.</p><p>Finally, we’ve dropped support for Python 3.6. Please use Python 3.7 going forward.</p><h3>Stay in the loop</h3><p>Ludwig thriving open source community gathers on <a href="https://join.slack.com/t/ludwig-ai/shared_invite/zt-mrxo87w6-DlX5~73T2B4v_g6jj0pJcQ">Slack</a>, join it to get involved!</p><p>If you are interested in adopting Ludwig in the enterprise, check out <a href="http://predibase.com/">Predibase</a>, the declarative ML platform that connects with your data, manages the training, iteration and deployment of your models and makes them available for querying, reducing time to value of machine learning projects.</p><p>Don’t want to miss future updates? Join this email list (you can unsubscribe anytime).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdocs.google.com%2Fforms%2Fd%2Fe%2F1FAIpQLSd5rbNqK0E0080nbe_5jFbRKAWm952XfsFfphdBbN8zuv0AeQ%2Fviewform%3Fembedded%3Dtrue&amp;display_name=Google+Docs&amp;url=https%3A%2F%2Fdocs.google.com%2Fforms%2Fd%2Fe%2F1FAIpQLSd5rbNqK0E0080nbe_5jFbRKAWm952XfsFfphdBbN8zuv0AeQ%2Fviewform%3Fvc%3D0%26c%3D0%26w%3D1%26flr%3D0&amp;image=https%3A%2F%2Flh4.googleusercontent.com%2FXouqOwyWDID_d9unrh8cKAzzjJS_nMDZI5IxKjEJ8LE9MZ46kZ7pqM0u0ricpopHZAVcVuE6C30%3Dw1200-h630-p&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=google" width="760" height="675" frameborder="0" scrolling="no"><a href="https://medium.com/media/eac9035b4d8b43188c17a15983b92395/href">https://medium.com/media/eac9035b4d8b43188c17a15983b92395/href</a></iframe><p>We wanted to thank all the collaborators who helped us, including the Ray team, the PyTorch team, the AimStack team, all the Ludwig contributors and in particular the new contributors:</p><ul><li><a href="https://github.com/vreyespue">@vreyespue</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1213">#1213</a></li><li><a href="https://github.com/Yard1">@Yard1</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1277">#1277</a></li><li><a href="https://github.com/EnricoMi">@EnricoMi</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1442">#1442</a></li><li><a href="https://github.com/q0w">@q0w</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1512">#1512</a></li><li><a href="https://github.com/kriziacicchetti">@kriziacicchetti</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1525">#1525</a></li><li><a href="https://github.com/RebSolcia">@RebSolcia</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1526">#1526</a></li><li><a href="https://github.com/noyoshi">@noyoshi</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1540">#1540</a></li><li><a href="https://github.com/louixs">@louixs</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1552">#1552</a></li><li><a href="https://github.com/dantreiman">@dantreiman</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1576">#1576</a></li><li><a href="https://github.com/connor-mccorm">@connor-mccorm</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1699">#1699</a></li><li><a href="https://github.com/hfurkanbozkurt">@hfurkanbozkurt</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1734">#1734</a></li><li><a href="https://github.com/brightsparc">@brightsparc</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1830">#1830</a></li><li><a href="https://github.com/tirkarthi">@tirkarthi</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1838">#1838</a></li><li><a href="https://github.com/jeffreykennethli">@jeffreykennethli</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1856">#1856</a></li><li><a href="https://github.com/rk0n">@rk0n</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1864">#1864</a></li><li><a href="https://github.com/geoffreyangus">@geoffreyangus</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1882">#1882</a></li><li><a href="https://github.com/jppgks">@jppgks</a> made their first contribution in <a href="https://github.com/ludwig-ai/ludwig/pull/1959">#1959</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1268a6432646" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/ludwig-0-5-declarative-machine-learning-now-on-pytorch-1268a6432646">Ludwig 0.5: Declarative Machine Learning, now on PyTorch</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Predibase: the enterprise declarative machine learning platform]]></title>
            <link>https://medium.com/predibase/introducing-predibase-the-enterprise-declarative-machine-learning-platform-10e2a388d465?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/10e2a388d465</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[declarative]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Piero Molino]]></dc:creator>
            <pubDate>Thu, 12 May 2022 15:30:44 GMT</pubDate>
            <atom:updated>2022-05-18T19:43:59.336Z</atom:updated>
            <content:encoded><![CDATA[<p>A high performance, low-code approach to machine learning for data practitioners and engineers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ooGoPH1tPK-Upe8sMlD2zA.png" /></figure><p>For the last year, we’ve quietly been building Predibase — the first enterprise declarative machine learning platform. Under a common belief that ML shouldn’t be so hard to implement in the enterprise, the founding team came together from Uber AI, Google, and Apple, and created platforms internally and in the open source that expanded the access of ML and reduced complexity through a new declarative approach. Now, with <a href="https://techcrunch.com/2022/05/10/predibase-exits-stealth-with-a-low-code-platform-for-building-ai-models/">backing from our investors</a> (Greylock, Factory and others), we’re bringing Declarative ML and its benefits to more users. Today we’re excited to share our vision for the future of machine learning.</p><p>Predibase is focused on individuals and organizations who have tried operationalizing machine learning, but found themselves re-inventing the wheel each step of the way. Our declarative approach allows users to focus on the “what” of their ML tasks while leaving our system to figure out the “how”. In this post, we’ll share more about our journey, the value we bring to both large Fortune 500 enterprises and high-growth startups, and what’s coming up next.</p><h3>Where things go wrong today</h3><p>Building ML solutions in the enterprise is too slow, too expensive and too few people can do it, but it doesn’t have to be that way.</p><p>Having built ML systems at organizations large and small, we are painstakingly familiar with the process of delivering ML solutions. Building an ML solution often requires writing low-level ML code kludged together with developer tools. After months of work, the result is typically a bespoke solution handed over to other engineers, often hard to maintain in the long term and create technical debt.</p><p>We see this as the COBOL era of machine learning, and are proud to be building towards the SQL moment of machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/0*NMNEltXCcveSbpTX" /></figure><p>This is a familiar pain for most data and ML teams that we’ve spoken to. But leaders of data science organizations are frustrated by both — having to deal with it and of the several no-/low-code platforms that have claimed to solve it. These platforms promise simplified model building, but don’t strike the right balance between ease of use and control for sustained usage by engineers and data scientists. And the unfortunate reality is that when teams use these products, they often struggle to build anything more than a prototype.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/0*dFF4hA1mXTVOcwGz" /></figure><p>In our view, the key is to strike the right abstraction — one that provides an easy out-of-the-box experience while supporting increasingly complex use cases and allowing the users to iterate and improve their solutions.</p><p>Once a satisfactory model has been obtained, it should be ready to move into production without additional engineering effort. But from our team’s experiences on Uber’s Michelangelo machine learning platform and Vertex AI, we’ve seen firsthand how even sophisticated ML organizations struggle to get models from research into production.</p><p>The tools that are built-for-scale (Spark, Airflow, Kubeflow) are not the same tools that are built-for experimentation. The path of least resistance in most data science teams becomes downloading some subset of the data to a local laptop and training a model using some amalgamation of Python libraries like Jupyter, Pandas, and PyTorch. Such models are commonly thrown over the wall to ML engineers tasked with getting them into production, but the process ends up being a complete rewrite of the data scientist’s workflow.</p><p>We devised the new idea of declarative ML systems for addressing these issues and applied it at Uber and Apple where it increased productivity and reduced costs, made it available as open source and we are finally bringing it to the broader enterprise market.</p><h3>Declarative ML Systems: LEGO for Machine Learning</h3><p>The basic idea behind declarative ML systems is to let users specify entire model pipelines as configurations and be intentional about the parts they care about while automating the rest. Like infrastructure-as-code simplified IT, these configurations allow users to focus on the “what” rather than the “how” and have the potential to dramatically increase access while lowering time-to-value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/0*trBviw47xR1FxZ04" /></figure><p>We pioneered declarative ML systems independently, with <a href="https://eng.uber.com/introducing-ludwig/">Ludwig</a> at Uber and <a href="https://venturebeat.com/2019/09/13/apple-details-overton-ai-development-tool-whose-models-have-processed-billions-of-queries/">Overton</a> at Apple. Ludwig served many different applications in production at Uber ranging from customer support automation, fraud detection and product recommendation while Overton processed billions of queries across multiple applications at Apple. Both frameworks made ML more accessible across stakeholders, especially engineers, and massively accelerated the pace of projects.</p><p>Over the last year, we’ve doubled down on our efforts in Ludwig in the open-source.</p><p>Ludwig makes it easy to define deep learning pipelines with a flexible and straightforward data-driven configuration system, suitable for a wide variety of tasks. Depending on the types of the data schema, users can compose and train state-of-the-art model pipelines on multiple modalities at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*gsjCjG1E0Bw3UMXX" /></figure><p>Writing a configuration file for Ludwig is easy, and provides users with ML best practices out-of-the-box, without sacrificing control. Users can choose which part of the pipeline they want to swap new pieces in for, including choosing among state-of-the-art model architectures and training parameters, deciding how to preprocess data and running a hyperparameter search, all via simple config changes. This declarative approach increases the speed of development, makes it easy to improve model quality through rapid iteration, and makes it effortless to reproduce results without the need to write any complex code.</p><p>One of our open source users referred to composing Ludwig configurations as “LEGO for deep learning”. We couldn’t say it better ourselves.</p><p>But as any ML team knows, training a deep learning model alone isn’t the only hard part — building the infrastructure to operationalize the model from data to deployment is often even more complex. That’s where Predibase comes in.</p><h3>Predibase — Bringing declarative ML to the enterprise</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*kluRBOLwMAo8RhdWtpDq3g.gif" /></figure><p>We started Predibase to bring the benefits of declarative ML systems to market with an enterprise-grade platform. There are three key things users do in Predibase:</p><ol><li><strong>Connect data</strong> — users can easily connect their structured and unstructured data stored anywhere on the cloud data stack in a highly secure way.</li><li><strong>Declaratively build models</strong> — users can provide model pipeline configurations and run on a scalable distributed infrastructure to train models efficiently as easily as on a single machine.</li><li><strong>Operationalize models</strong> — users can deploy model pipelines at the click of a button with high efficiency and query them immediately.</li></ol><p>Predibase’s vision is to bring all the stakeholders of data &amp; AI organizations together in one place, making collaboration seamless between data scientists working on models, data engineers working on deployments and product engineers using the models. Let’s take a look at the features we’ve added on top of our open-source foundations that make it possible.</p><h4>Integrated platform, from data-to-deployment</h4><p>Predibase provides the fastest path from data to deployment without cutting any corners along the way. Connect directly to your data sources, both structured data warehouses (ex: Snowflake, BigQuery, Redshift) and unstructured data lakes (ex: S3, GCS, Azure Storage). Any model trained in Predibase can be deployed to production with zero code changes, and configured to automatically retrain as new data comes in. Because both experimentation and productionization go through the same unified declarative configuration, models can continue to be updated and improved even after being deployed to production.</p><h4>Cutting-edge infra made painless</h4><p>Predibase features a true cloud-native, serverless ML infrastructure layer built on top of Horovod, Ray, and Kubernetes. We provide the ability to autoscale workloads across multi-node and multi-GPU systems in a way that is cost effective and tailored to the model and dataset. All of this provides the ability to combine highly parallel data processing, distributed training, and hyperparameter optimization into a single workload, and supports both high throughput batch prediction as well as low-latency real-time prediction via REST.</p><h4>A new way to do iterative modeling</h4><p>The declarative abstraction that Predibase adopts makes it very easy for users to modify model pipelines by just editing their configurations. Predibase monitors performance and quality as models are trained and supports users in their model iteration workflows by keeping track of lineage between models and the data they are trained on. Defining models as configs allows us to show differences between model versions over time in a concise way, making it easy to iterate and improve them. This is where our unique alternative to AutoML comes in: instead of running expensive experiments, Predibase suggests to the user the best subsequent configurations to train depending on the explorations they have already conducted, creating a virtuous cycle of improvement.</p><h4>Supporting multi-personas with PQL</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*xK_vJDUX5Q38-2h6" /></figure><p>With the rise of the modern data stack, the number of data professionals comfortable with SQL has also grown. So, alongside our Python SDK and UI, we’re also introducing PQL — Predictive Query Language — as an interface that brings machine learning closer to the data. Using PQL, users can use Predibase for connecting data, training models and running predictive queries, all through a SQL-like syntax they are already familiar with. We see a future where users run and share predictive queries just as commonly as they share analytical queries today.</p><h3>Our plans</h3><p>Predibase is currently available by invitation only as we scale our platform, but we’ve been lucky to work with multiple customers ranging from the Fortune 500 to start-ups and across industries including banking, healthcare and high-tech. If you are interested in trying Predibase at your organization, please <a href="https://predibase.com/request-early-access">request a demo</a> and we will be more than happy to show you our platform.</p><p>Over the coming months, expect to hear more frequently from us as we release more details about our platform and how you can use it or get involved. In parallel, we’ll also double down on our open source projects — in particular on Ludwig, where you can expect to see some exciting new upgrades soon. Join us on <a href="https://ludwig-ai.slack.com/join/shared_invite/zt-mrxo87w6-DlX5~73T2B4v_g6jj0pJcQ#/shared-invite/email">Slack</a> if you’d like to follow us in the community and watch out for the latest updates on the <a href="https://medium.com/predibase">Predibase blog</a>!</p><h3>About us</h3><p><em>Founders</em></p><ul><li><strong>Piero Molino, CEO</strong> — Piero is the Chief Executive Officer, previously an ML researcher and one of the founding members of the Uber AI organization, where he authored Ludwig — an open source declarative deep learning framework that is at the core of Predibase.</li><li><strong>Travis Addair</strong>, <strong>CTO</strong> — Travis is the Chief Technology Officer, building on experience leading the deep learning training team on Uber’s Michelangelo platform, where he was the co-author of Horovod — an open source distributed deep learning training framework.</li><li><strong>Devvret Rishi, CPO </strong>— Dev is the Chief Product Officer, bringing an academic background in ML and prior experience as a PM on Firebase, Google Assistant and Google Cloud AI Platform, where he was also the first PM for Kaggle — the world’s largest ML community.</li><li><strong>Chris Ré, co-founder </strong>— Professor Chris Ré is a co-founder, who leads the Hazy machine learning research group at Stanford and previously built Overton while at Apple, one of the first declarative ML systems used in industry.</li></ul><p><em>Team</em></p><p>We’re proud of the team behind the Predibase platform, a mix of machine learning researchers, engineers and product designers from leading tech companies like Amazon, Google, Apple, Uber and more. Our team has worked on machine learning systems from research to production, and we are excited to bring our new approach to a broader audience. We’re hiring for strong candidates in engineering and go-to-market, so please <a href="https://predibase.com/contact-us">reach out to us</a> if you are interested!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10e2a388d465" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/introducing-predibase-the-enterprise-declarative-machine-learning-platform-10e2a388d465">Introducing Predibase: the enterprise declarative machine learning platform</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ludwig AutoML for Text Classification]]></title>
            <link>https://medium.com/predibase/ludwig-automl-for-text-classification-7c1759f3b150?source=rss----6792b5a79e9d---4</link>
            <guid isPermaLink="false">https://medium.com/p/7c1759f3b150</guid>
            <category><![CDATA[automl]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[automl-natural-language]]></category>
            <category><![CDATA[text-classification]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Anne Holler]]></dc:creator>
            <pubDate>Tue, 03 May 2022 16:14:36 GMT</pubDate>
            <atom:updated>2022-05-03T18:42:29.958Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Authors: Anne Holler, Justin Zhao, Avanika Narayan,Travis Addair, Devvret Rishi, Piero Molino</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2PGREr8ku9PdWgv2.png" /><figcaption>Ludwig v0.5.0 extends v0.4.1 AutoML for tabular datasets to AutoML for text classification datasets</figcaption></figure><h3><strong>INTRODUCTION</strong></h3><p><a href="https://ludwig-ai.github.io/ludwig-docs/">Ludwig</a> is an open-source declarative deep learning (DL) framework that enables individuals from a variety of backgrounds to train and deploy <a href="https://medium.com/ludwig-ai/ludwig-ai-v0-4-introducing-declarative-mlops-with-ray-dask-tabnet-and-mlflow-integrations-6509c3875c2e">state-of-the-art tabular, natural language processing, and computer vision models</a>. Ludwig is a toolkit for end-to-end machine learning, through which users can experiment with different model hyperparameters using Ray <a href="https://docs.ray.io/en/latest/tune/index.html">Tune</a>, scale up to large out-of-memory datasets and multi-node clusters using <a href="https://horovod.ai/">Horovod</a> and <a href="https://docs.ray.io/en/latest/index.html">Ray</a>, and serve a model in production using <a href="https://mlflow.org/">MLflow</a>. Model architecture, training loop, hyperparameter search range, and backend infrastructure are specified in a YAML file using Ludwig’s declarative interface, eliminating the need to write code. By abstracting away the barriers to training and deploying DL models, Ludwig makes developing DL models a simple iterative process.</p><p>Recently, we extended Ludwig to include AutoML, which automatically creates DL models given a dataset, its label column, and a time budget. Ludwig AutoML infers input and output feature types, chooses the model architecture, and specifies the parameters and ranges across which to perform hyperparameter search. Ludwig AutoML returns a set of trained models, sorted by quality metrics. It can also return the YAML configuration file used to generate those models, allowing further model search refinement by the user. We discuss our glass-box AutoML approach, including its goals, design, implementation, use, and usability in this <a href="https://medium.com/ludwig-ai/ludwig-automl-for-deep-learning-cf64de9d49c8">linked blog</a>.</p><p>Our initial AutoML work focused on tabular datasets, since good performance on such datasets is a current area of interest in the DL community and since transfer learning from pre-trained models, which can reduce training complexity for text or image data, is not applicable. In this blog, we report on our subsequent work developing and validating Ludwig AutoML for text classification. As we expected, the ability to fine-tune pre-trained models did simplify basic model type and search space selection for this new AutoML domain. However, we found that managing the significantly greater resources needed for training text models presented a set of additional challenges, which are addressed in the latest version of Ludwig. In the next section, we discuss our selection of initial text classification AutoML heuristics, the opportunities we discovered and exploited for further heuristics improvement, and the validation of the resulting text classification AutoML algorithm.</p><h3><strong>DEVELOPING TEXT CLASSIFICATION AUTOML</strong></h3><p>The key to creating data-informed Ludwig AutoML for text classification is to develop heuristics which support efficiently and automatically producing Ludwig models that have accuracy competitive (within 2%) with models produced manually by experts. As when creating Ludwig AutoML for tabular data, we ran experiments on a variety of datasets to develop the heuristics, and validated the resulting functionality by running AutoML on a different group of datasets.</p><h3>Choosing Initial Text Classification AutoML Heuristics</h3><p>For text classification AutoML, we formed initial heuristics using data from previous work training text classification models, including a case study performed to show the capabilities of the <a href="https://arxiv.org/pdf/2111.04260.pdf">Ludwig Benchmarking Toolkit [LBT]</a>. For the LBT case study, seven model types were trained across nine text classification datasets spanning four kinds of problems.</p><h3>Heuristics development datasets</h3><p>The nine datasets in the LBT study were chosen for their diversity in average input token length, dataset size, and output classes count. For Ludwig AutoML heuristics development datasets, we used six of the nine LBT datasets, replacing three with more widely-used alternatives and including one additional dataset. The <strong>ten Ludwig text classification AutoML heuristics development datasets</strong> are listed in Table 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFvtsB6wa-xEJNAY5KEm5w.png" /><figcaption>Table 1: Text Classification Datasets used to develop AutoML heuristics for Ludwig. SST3 is derived from SST5 by collapsing positive and negative classes, while keeping the neutral class.</figcaption></figure><p>Ludwig AutoML identifies text classification datasets as those with a single text input feature and a single output feature. For the three datasets not matching this pattern, we dropped unneeded input columns before passing their associated dataframes to AutoML, removing <em>content_id</em> from <em>goemotions</em> and <em>title</em> from <em>agnews</em> and <em>dbpedia</em>, the latter after concatenating <em>title</em> to the primary input text content field. We note that the maximum input token lengths listed in Table 1 were capped at 512 by the tokenizer library, and the average and 99th percentile input token lengths were measured on the truncated output.</p><h3>Initial heuristics selected</h3><ul><li><strong>Model type: BERT-base</strong>. The seven model types in the LBT case study included five pre-trained language models (BERT-base, DistilBERT-base, Electra-base, RoBERTa-base, and T5-small) and two text encoders trained from scratch (RNN and Stacked Parallel CNN). BERT-base produced the most accurate model for five of the nine datasets, and is often <a href="https://arxiv.org/pdf/2004.03705.pdf">recommended</a> for text classification. Hence, we selected BERT-base as the default model type for Ludwig text classification AutoML. BERT-base is a transformer model, having <a href="https://arxiv.org/pdf/2001.08361.pdf">quadratic</a> behavior with respect to input token length. Its maximum supported input token length is 512. In the LBT case study, the input token length was capped well below the BERT-base maximum for a number of the datasets, and competitive models were produced, so we expected that BERT’s quadratic behavior would be manageable.</li><li><strong>Batch size search range: [16, 32, 64,128]. </strong>In the LBT runs, the BERT-base models were trained with fixed batch sizes, set manually per dataset to the maximum value that would fit in the T4 16G GPU memory. For AutoML, we wanted to make batch size a hyperparameter, with its range automatically customized per dataset (if needed) via Ludwig AutoML’s <em>tune_for_memory</em> option. We set the initial batch size search range to [16, 32, 64,128], which is in line with the Google BERT-base <a href="https://github.com/google-research/bert/blob/master/README.md">README</a>. We note that this batch size set contains much lower values than the set used by Ludwig AutoML for tabular models based on TabNet. TabNet is a smaller model type and Ludwig AutoML uses the following set of higher values [256, 512, 1024, 2048, 4096, 8192].</li><li><strong>Learning rate search range: [0.00002, 0.00003, 0.00005]. </strong>In the LBT case study, the learning rate hyperparameter range was sampled loguniform from 0.00002 to 0.01. Based on the learning rates associated with the best performing LBT models and on published <a href="https://arxiv.org/pdf/1905.05583.pdf">results</a> indicating the learning rate values that avoid catastrophic forgetting when fine-tuning pre-trained models, we set the text classification AutoML learning rate search range to [0.00002, 0.00003, 0.00005]. We note that this learning rate range is again very different from that used by Ludwig AutoML for tabular datasets, which is [0.005, 0.01, 0.02, 0.025]; tabular models are trained from scratch and thus not concerned with catastrophic forgetting of pre-trained knowledge.</li><li><strong>Optimizer: AdamW. </strong>For BERT-base fine-tuning, the AdamW optimizer is often used, rather than the Adam optimizer, which is Ludwig’s default. Fast.ai compares the two optimizers <a href="https://www.fast.ai/2018/07/02/adam-weight-decay/">here</a>. We added AdamW support to Ludwig and used AdamW as the default optimizer for Ludwig AutoML for text classification.</li><li><strong>Maximum Hyperparameter Search Trials: 5. </strong>Ludwig AutoML performs async hyperband hyperparameter search using <a href="https://docs.ray.io/en/latest/tune/index.html">Ray Tune</a>. For tabular datasets, AutoML specifies running up to 10 search trials. For text classification datasets, we reduced the maximum search trials to 5, given the smaller search space in terms of parameters and ranges.</li></ul><h3>Initial heuristics results</h3><p>Using these initial heuristics and default options, we ran AutoML on our ten text classification datasets on a Ray Cluster composed of three <a href="https://aws.amazon.com/ec2/instance-types/g4/">g4dn.2xlarge</a> nodes. While we had standardized on a two hour time budget for tabular data AutoML, we experimented with a one hour time budget for text classification AutoML, given the latter’s use of pre-trained models and its smaller search space. For the short datasets that were also narrow enough to fit in T4 GPU memory (<em>sst2</em>, <em>sst3</em>, and <em>sst5</em>), Ludwig AutoML produced models within the one hour time budget that had accuracy within 2% of published manually-tuned results. The remaining datasets failed to train with the initial AutoML heuristics and default options, overflowing GPU memory.</p><h3>Tuning Text Classification AutoML Heuristics</h3><p>Investigating issues seen with the datasets that failed to train with the initial AutoML heuristics and default options, we found a number of opportunities to tune text classification AutoML. We next discuss these opportunities and then present results with the tuned heuristics and options.</p><h3>Heuristics Tuning</h3><ul><li><strong>Improving the model size estimation.</strong>The Ludwig AutoML <em>tune_for_memory</em> option estimates the model memory footprint and adjusts model parameters like batch size to reduce it to fit into the target memory. We found that the option’s original estimation formula did not include <strong>optimizer bytes per model weight</strong>. With that quantity added, its estimate of worst-case memory usage became <em>(model_weight_count) x (bytes_per_weight + </em><strong><em>optimizer_bytes_per_weight</em></strong><em>) x (batch_size).</em> Worst-case memory size for BERT-base assumes input token lengths of 512. For shorter input token lengths, memory usage can be much lower than the worst case. By default, Ludwig itself limits BERT-base maximum input token length to 256, and that maximum can be further reduced via a Ludwig override. We refined the <em>tune_for_memory</em> memory usage estimate to incorporate the dataset’s effective maximum input token length given its Ludwig settings and we enabled the <em>tune_for_memory</em> option for the datasets that had overflowed GPU memory.</li><li><strong>Limiting the input token length before reducing the batch size range. </strong>LBT experiments showed that limiting input token length to allow larger batch sizes was a good trade-off for obtaining competitive model accuracy under memory pressure. And we observe that for several datasets, average token length is an order of magnitude lower than maximum token length and the 99th percentile length is much lower than maximum as well. We updated <em>tune_for_memory</em> to address estimated model memory overflow by first reducing maximum input token length to the 99th percentile capped at 128, and then reducing batch size range if estimated memory size is still too large. With this update, text classification AutoML on <em>ethos_binary</em>, <em>irony</em>, and <em>goemotions</em> produced BERT-base models in one hour, with the first two achieving competitive model accuracy.</li><li><strong>Revising the hyperparameter search and training goal. </strong>The <em>goemotions</em> model accuracy produced in one hour was not competitive with the results reported by LBT and others. The dataset’s target column is of type <em>set</em> and the Jaccard metric is used to assess model quality. In a detailed comparison of the AutoML and LBT results, we found that AutoML’s loss metric was actually better than LBT’s, but its Jaccard metric was worse. By default, Ludwig AutoML defined the hyperparameter search and training goal as minimizing loss on the combined output features. Always using combined loss as the goal simplified Ludwig AutoML code, but meant that its goal could be misaligned with the metric being used to assess model quality. We modified Ludwig AutoML so that, when run on a dataset with a single output feature, it set the hyperparameter search and training goal to match Ludwig’s preferred metric for that output feature type (see Ludwig documentation). With this change, the Jaccard metric was used as AutoML’s goal for the output feature of type set, and the best model produced by AutoML in one hour for <em>goemotions</em> reached a competitive score.</li><li><strong>Tuning the training loop. </strong>We spent time analyzing AutoML’s runtime performance. We were running on pre-release Ludwig v0.5, which replaces the TensorFlow backend with pyTorch. We found (via <a href="https://github.com/benfred/py-spy">py-spy</a>) that this pre-release code had tuning opportunities in its regularization loss calculation, which we addressed. We switched our zero_grad to include set_to_none, as per the PyTorch performance tuning <a href="https://pytorch.org/tutorials/recipes/recipes/tuning_guide.html">guide</a>. We found that Ray Tune workers did not use the GPU after our tune_for_memory Ray job was run; the Ray team fixed the <a href="https://github.com/ray-project/ray/issues/22504">problem</a> in version 1.12. Also, based on our initial hyperparameter runs, we updated several settings used for text classification AutoML. We reduced the learning rate range to remove 0.00005, since the higher performing models were all associated with lower values. We limited per-trial training to 6 epochs since, with fine-tuning, the first few epochs typically produce the most accurate models.</li><li><strong>Increasing the time budget. </strong>Even with <em>tune_for_memory</em> limiting maximum input token length and batch size search range and with our AutoML performance tuning, AutoML did not produce models for the remaining datasets (<em>yelp_polarity</em>, <em>yelp_reviews</em>, <em>agnews</em>, and <em>dbpedia</em>) in one hour. These datasets have a relatively large number of rows (&gt;100K) and a single epoch can take multiple hours. We increased their time budget, to three hours for <em>agnews</em> and six hours for the others, and AutoML was able to generate competitive models. We considered switching the model type for these datasets from BERT-base to <a href="https://arxiv.org/abs/1910.01108">DistilBERT-base</a>, which has 40% fewer weights. However, model accuracy was impacted for several datasets and it was unclear how to characterize when selecting the smaller model type would impact performance. Hence, we choose BERT-base, when the model is estimated to fit memory; else, DistilBERT-base.</li><li><strong>Changing the model checkpoint and evaluation from epoch- to step-based. </strong>Given the large amount of time needed to run a full epoch for the long wide datasets, we updated Ludwig to optionally switch training and evaluation from epoch-based to step-based. Step-based evaluation allows model quality assessment before completing a full epoch. We ran AutoML on the long wide datasets with step-based model checkpointing and evaluation configured. We specified two evaluations per epoch, with the idea that training on 50% of a long dataset would likely yield a model in line with that produced by training on the full epoch. With this configuration, we were able to get competitive models at the half-epoch point, and were able to reduce the three hour time budget for <em>agnews</em> to two hours and the six hour time budget for the other long wide datasets to four hours. We changed AutoML to set <em>checkpoints_per_epoch</em> to two or more, per dataset length, when <em>tune_for_memory</em> was set for long wide datasets.</li><li><strong>Reducing the model intermediate evaluation overhead. </strong>We observed that the training time overhead for intermediate model evaluation, done at model checkpointing time, is substantial and its relative impact is increased when using sub-epoch evaluation. A key source of that overhead is evaluation on the full training set. To reduce the overhead, we made full training set intermediate evaluation optional. With that option disabled, the time budget to produce competitive models for <em>yelp_polarity</em>, <em>yelp_reviews</em>, and <em>dbpedia</em> is reduced to three hours. We updated AutoML to disable training data intermediate evaluation for long wide datasets when <em>tune_for_memory</em> is set.</li></ul><h3>Improved heuristics results</h3><p>We <a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/runstandard.sh">ran</a> Ludwig AutoML with the improved heuristics and option settings on the heuristics development datasets as a sanity-check (see Figure 1). In all cases, the AutoML score with the improved heuristics and option settings is within 2% of the manually-tuned reference score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cQ_X72lY2szl9ju81AMU2w.png" /><figcaption>Figure 1: Model performance of AutoML vs Manually-Tuned Reference on heuristics datasets as a sanity-check (higher score is better)</figcaption></figure><p>Table 2 includes detailed information on the AutoML sanity check runs. We note that selecting an appropriate time budget for text classification AutoML is dependent on the dataset length and choosing to enable AutoML tune_for_memory is dependent on maximum input token length. Max Token Length shows the value used when tune_for_memory was set and the model was estimated to overflow GPU memory; 40% of the datasets ran with the tune_for_memory limit of 128 and produced competitive models. Checkpoints per Epoch reflects that 40% of the datasets ran with more checkpoints per epoch than default, set by tune_for_memory based on the dataset length. Checkpoints Completed lists the number of completed checkpoints for all trials run across the three Ray Tune workers, with Average Seconds per Checkpoint giving the average times to run training and evaluation for those checkpoints. The highest average times and lowest completed checkpoint counts are associated with the long wide datasets that ran multiple checkpoints per epoch. Without sub-epoch evaluation and reduced evaluation overhead, those datasets would require an unnecessarily doubled time budget to produce a competitive model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dfMdv8MxUkbjGEfc-nBF8g.png" /><figcaption>Table 2: Running AutoML on the datasets used to develop its heuristics as a sanity-check</figcaption></figure><h3><strong>Validating Text Classification AutoML Heuristics</strong></h3><h3>Validation datasets</h3><p>We chose five additional datasets (Table 3) to validate text classification AutoML. Unneeded fields were dropped to yield one input text feature: <em>article_id</em> (<em>bbcnews</em>), <em>edge</em> (<em>reuters</em>, <em>ohsumed</em>), <em>title</em> (<em>amazon_reviews</em>, <em>amazon_review_polarity</em>), the latter two <em>after title</em> was concatenated to the primary input text content field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SihKxMmXTN9n1bUdf9NbTg.png" /><figcaption>Table 3: Text Classification Datasets used to validate AutoML heuristics for Ludwig</figcaption></figure><h3>Validation results</h3><p>To validate text classification AutoML on these datasets, we needed to set the time budget and to decide whether to enable the <em>tune_for_memory</em> option. The two <em>amazon</em> datasets have an order of magnitude more rows than the longest heuristics datasets, for which we had used three hour time budgets; we specified a five hour time budget for those datasets. The row count for the other datasets was in line with heuristics datasets for which we had used a one hour time budget, so we used a one hour time budget for them. All of the validation datasets have large maximum input token lengths; we enabled the <em>tune_for_memory</em> option for all of them.</p><p>The results of the validation runs are shown in Figure 2. All AutoML scores are within 2% of the corresponding manually-tuned reference scores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HRhJ8nX9BbWFgHWagjMHOA.png" /><figcaption>Figure 2: Model performance of AutoML vs Manually-Tuned Reference on heuristics datasets as validation (higher score is better)</figcaption></figure><p>In Table 4, we again see AutoML limiting maximum token length, to avoid GPU memory overflow, and setting checkpoints per epoch for long wide datasets, to allow sub-epoch model quality evaluation and stopping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPDntsb-JDKAv3D0FkdL1A.png" /><figcaption>Table 4: Running AutoML on the datasets used to validate its heuristics</figcaption></figure><h3>SUMMARY AND FUTURE WORK</h3><p>We presented our work extending Ludwig AutoML to text classification. We leveraged the pre-trained BERT-base model type and found that, while its use simplified the model search space and produced competitive models, its resource requirements presented tuning challenges. We developed AutoML using ten diverse text classification datasets, and validated it worked well on five additional text classification datasets, confirming that Ludwig AutoML can provide robust accuracy within 2% of, and in some cases better than, manually-tuned models.</p><p>We plan to next focus on tuning Ludwig AutoML for additional tasks such as image classification. Tackling text classification made Ludwig AutoML substantially more robust, in particular to large datasets and memory-hungry models, so we expect a similar beneficial effect by tackling new and demanding tasks.</p><h3>GET INVOLVED!</h3><p>The scripts to run AutoML on all of the datasets in this blog are available <a href="https://github.com/ludwig-ai/experiments/tree/main/automl_nlp">here</a>. We invite you to try Ludwig AutoML on your text classification (or tabular) tasks, and to share your experiences!</p><p>And in general, we welcome discussion or contributions from researchers and practitioners alike, and we welcome you all to join the Ludwig open source community!</p><p>We are actively working on a managed platform to bring this novel approach for automated machine learning to organizations at scale through <a href="http://www.predibase.com/">Predibase</a>, a cohesive end-to-end platform built on top of Ludwig, Horovod, and Ray. We’re excited to share more details soon, and if you’d like to get in touch in the meantime, please feel free to reach out to us at <a href="/service/mailto:team@predibase.com">team@predibase.com</a>.</p><h3>APPENDIX: TEXT CLASSIFICATION AUTOML USE</h3><p>The Ludwig AutoML API is <em>auto_train</em>. Here is a simple example of its invocation:</p><pre>auto_train_results = ludwig.automl.auto_train(<br>    dataset=my_dataset_df, # w/train, validation, &amp; test splits<br>    target=target_column_name,<br>    time_limit_s=7200,<br>    tune_for_memory=False<br>)</pre><p>Ludwig AutoML characterizes as text classification an input dataset with a single input text column and a single output column. Many text classification datasets need <em>tune_for_memory</em> set true to avoid gpu memory overflow.</p><p><a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/sst2/run_auto_train_standard.py">Here</a> is an example using <em>auto_train</em> on the <em>sst2</em> dataset. The <em>sst2</em> dataset out-of-the-box matches the text classification characterization, fits in gpu memory, and includes all three splits. <a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/agnews/run_auto_train_standard.title.py">Here</a> is an example using <em>auto_train</em> on the <em>agnews</em> dataset, needing <em>tune_for_memory</em>. The <em>agnews</em> dataset <a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/agnews/load_util.py">preprocesses</a> the dataframe passed to <em>auto_train</em> to provide a single input text column, formed by concatenating its <em>title</em> and <em>description</em> fields and dropping unneeded columns, and to create the validation split.</p><p>The <em>auto_train</em> API uses the heuristics previously described to create a hyperparameter search configuration and to run it for the specified time limit using Ray Tune Async HyperBand. The result is the set of models produced by the search trials, along with a hyperparameter search report, which can be inspected manually or post-processed by Ludwig tools.</p><p>The <em>create_auto_config</em> API outputs auto_train’s hyperparameter search configuration but skips running the search. It takes the same parameters as <em>auto_train</em>; here is a simple example of its invocation:</p><pre>auto_config = ludwig.automl.create_auto_config(<br>    dataset=my_dataset_df,<br>    target=target_column_name,<br>    time_limit_s=7200,<br>    tune_for_memory=False<br>)</pre><p>The <em>create_auto_config</em> API is useful for examining the types chosen for the input and output features, the model type selected, and the hyperparameters and ranges specified. For manual refinement, the API output can be edited and directly used as the configuration for a Ludwig hyperparameter search job. <a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/sst5/get_auto_train_config.py">Here</a> is an example invocation of <em>create_auto_config </em>on the <em>sst5</em> dataset, with the associated output given <a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/sst5/auto_config.json.automl.master">here</a>.</p><p>The <em>user_config</em> parameter can be passed to <em>auto_train</em> or <em>create_auto_config</em> to override specified parts of the configuration produced. For example, <a href="https://github.com/ludwig-ai/experiments/blob/main/automl_nlp/heuristics/goemotions/run_auto_train_standard.py">this</a> auto_train script for the <em>goemotions</em> dataset specifies that the <em>emotion_ids</em> output feature be set to type <em>set</em> to override Ludwig AutoML type detection system’s characterization of the feature as <em>category</em>.</p><h3>APPENDIX: REFERENCE SCORE LINKS</h3><h3><strong>Figure 1 Reference Score Links</strong></h3><ul><li><a href="https://arxiv.org/pdf/2006.08328v2.pdf">ethos_binary</a></li><li><a href="https://arxiv.org/pdf/2111.04260.pdf">irony</a></li><li><a href="https://paperswithcode.com/paper/fine-grained-sentiment-classification-using">sst2</a></li><li><a href="https://huggingface.co/textattack/bert-base-uncased-yelp-polarity">yelp_polarity</a></li><li><a href="https://huggingface.co/textattack/bert-base-uncased-ag-news">agnews</a></li><li><a href="https://arxiv.org/pdf/2111.04260.pdf">dbpedia</a></li><li><a href="https://scholarworks.iupui.edu/bitstream/handle/1805/27366/AE_Thesis_Fall_2021_Final.pdf?sequence=1">goemotions</a></li><li><a href="https://pythonrepo.com/repo/WadeYin9712-SentiBERT-python-deep-learning">sst3</a></li><li><a href="https://paperswithcode.com/paper/fine-grained-sentiment-classification-using">sst5</a></li><li><a href="https://arxiv.org/pdf/1509.01626.pdf">yelp_reviews</a></li></ul><h3>Figure 2 Reference Score Links</h3><ul><li><a href="https://arxiv.org/pdf/1509.01626.pdf">amazon_review_polarity</a></li><li><a href="https://arxiv.org/pdf/1509.01626.pdf">amazon_reviews</a></li><li><a href="https://www.kaggle.com/competitions/learn-ai-bbc/leaderboard">bbcnews</a></li><li><a href="https://arxiv.org/pdf/1909.08166.pdf">ohsumed_7400</a></li><li><a href="https://arxiv.org/pdf/2111.00702.pdf">reuters_r8</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c1759f3b150" width="1" height="1" alt=""><hr><p><a href="https://medium.com/predibase/ludwig-automl-for-text-classification-7c1759f3b150">Ludwig AutoML for Text Classification</a> was originally published in <a href="https://medium.com/predibase">Predibase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>