<?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[riselab - Medium]]></title>
        <description><![CDATA[RISELab Blogs - Medium]]></description>
        <link>https://medium.com/riselab?source=rss----c78fd354636e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>riselab - Medium</title>
            <link>https://medium.com/riselab?source=rss----c78fd354636e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 25 Jun 2026 21:53:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/riselab" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[So you want to build an open source tool/library as a grad student]]></title>
            <link>https://medium.com/riselab/so-you-want-to-build-an-open-source-tool-library-as-a-grad-student-94596efc31d1?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/94596efc31d1</guid>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[graduate-school]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[berkeley]]></category>
            <dc:creator><![CDATA[Devin Petersohn]]></dc:creator>
            <pubDate>Thu, 12 Aug 2021 15:25:21 GMT</pubDate>
            <atom:updated>2021-08-13T13:57:16.619Z</atom:updated>
            <content:encoded><![CDATA[<h4>This is a collection of experiences and recommendations for building an open source community as a grad student</h4><p>Many grad students and professors have asked me for suggestions on how to build a functioning and thriving open source community while in grad school. This blog post appears as a chapter in my thesis, but ultimately I decided to extract those contents and put them here for easier retrieval and consumption.</p><p>This blog post is part history, part lessons, part advice. I don’t know everything, and the moderate success of my work does not mean that my advice is automatically good. I think there is value in hearing other people’s opinions, but not taking them as truth. I recommend that method of consumption here. Everyone has opinions, every situation is different, judge for yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KudVK0Zf_M0Gen3APjc4WA.jpeg" /><figcaption><a href="https://unsplash.com/photos/ggVH1hoQAac">Courtesy of Unsplash</a></figcaption></figure><h3>My History Building a Successful Open Source Project</h3><p>During my grad school career, I built Modin (<a href="https://github.com/modin-project/modin">https://github.com/modin-project/modin</a>), a full dataframe implementation that, as of writing, has over 6,000 GitHub stars. This effort has been supported by many people over the last few years, and definitely would not be as far as it is without that support. Berkeley is well known for creating some of the most used and most impactful software on the planet, so I did have an unfair advantage in terms of brand.</p><p>My approach toward promoting the work has been fairly successful, however I attribute that largely to luck. The first blog post I published (2018) got a lot of input and feedback from others working on the project at the time. It ended up getting shared on Twitter and HackerNews by many people (I had accounts with neither at the time) and generated a lot of interest. At the time, pandas on Ray (which would become Modin) was a 1 month hack I put together with help from several undergraduate students at Berkeley. It honestly wasn’t ready for the overwhelming interest it received, and yet it has continued to be developed and grown into something that I couldn’t have imagined at the time.</p><p>My role has transitioned away from being the main generator of code to more of a project management role, coordinate many disparate institutions and their contributions and making it easy to contribute. I spend a lot of time reviewing code and telling other people what to do rather than writing all of the code myself.</p><h3>Lessons and Advice</h3><p>This section is likely to be long and difficult to parse, so I’m going to make my advice section headers so it’s easier to skim to find the points you’d like to better understand. The points are not in any specific order.</p><h4>[1] Make your system understandable to your target user, and don’t worry about anyone else</h4><p>This point is something I think we’ve gotten right from the beginning with Modin. From the start, we have abstracted away complex details from the user, including in how we present the system. This has, of course, led many of highly technical people to discount the complexity of abstracting away these details, but that has never bothered me. I don’t care if someone thinks Modin is or isn’t technically interesting, I care that it solves a problem. Because of how I talk about Modin, most people have a simple understanding of the system. That is by design. While working on Modin, we have formalized a new data model, created a new dataframe algebra, and created a truly unique data layout and metadata management system. The people who could understand enough about the underlying system to appreciate it likely wouldn’t use Modin in the first place, because Modin is targeting a less-technical group of users. I think this is really important because when people talk about Modin, they generally focus on the problems it solves rather than the technically interesting parts of the implementation. I am okay with that, but make sure that you are. Do you want people to use your work or do you want them to think you’re really smart? Sometimes you can have both, but often not.</p><h4>[2] Be prepared to defer your graduation and publications</h4><p>This point is less applicable if you have a large team managing the open source, but in my case I was working mostly alone from the open source side. On the research side, we were able to bring together some of the best in databases and machine learning, but many deadlines were missed because of things that came up in the open source. I prioritized the open source community and development over my own graduation and publications. This is a decision you’ll have to make for your own situation. I’m not completely convinced now that you need to do this, but at the time I felt like it was necessary to keep the open source community alive and growing. There’s little overlap between open source community development and grad school requirements. You are going to have to respond to questions, issues, and promote your work.</p><h4>[3] The fun parts of open source are front-loaded</h4><p>At the beginning of any open source project you’re going to be able to move fast. There’s no technical debt, no new issues, and a lot of energy and excitement. As time goes on, your time will go from developing new features and building things to answering issues and emails. If you’re fortunate enough to have a lot of external contributors like Modin does, you’ll end up spending a lot of time reviewing code. These days, I spend maybe 20% of my time writing code and debugging. If you want to get into open source, be prepared to spend a large chunk of time on user issues and support after your project hits a critical mass. If you are mostly doing it alone, the project momentum can easily screech to a halt and feel like it’s not moving anywhere for weeks. My recommendations here are to (1) avoid romanticizing the idea of managing a highly visible open source project and (2) learn to bin your time. At first, it’s easy to answer issues as they come in, eventually you will not get anything done if you always answer issues immediately.</p><h4>[4] Promotion is important</h4><p>If you want people to use your project, you have to tell them about it. Part of the difficulty in deciding how to promote is around deciding when. Promotion takes away from development in a small team, and so there needs to be some good reason to promote. Early on, I had planned on curating a series of blog posts that could archive the journey. That was quickly thrown out after the reception from the first blog post. My main advice is to be careful not to overpromote: each update should be substantial. This is mostly personal taste, but I don’t like reading a lot of fluffy blogs that have hardly any new content. Honestly, most people aren’t going to read the blog anyway, they will skim the headers or scroll to the bottom to read the conclusion. In terms of promotion, getting multiple friendly people to tweet about your blog is probably the best way to promote. HackerNews is not what I would consider a good distribution channel, rather a good place for discussion about topics surrounding a blog’s title and content. Podcasts are another way to spread the word, and they are a common way that people hear about new projects.</p><h4>[5] Make your work easy to install and use</h4><p>The biggest hurdle to using something is getting started, and the lower the barrier the more people will try it. This might seem obvious but easy means different things to different people so I’ll try to be concrete here. Do you require users to pull your Docker container? Do you require users to build from source? Does installation change the user’s environment? Does installation take more than a couple of steps? If you answered yes to any of these questions you’re going to have a hard time getting people to do more than look at your README. Making something easy to use is important to getting a community off the ground, if people don’t use it they won’t tell their friends about it (probably).</p><p>The second component to easy use is examples: you need really good useful examples, not toys. Users want to see what they can do with your tool, and showing them how to do a trivial map over a list of integers is not going to give users a good idea of what they can do. Your examples should show off a variety of use cases and capabilities on actual workloads. Examples overlap a bit with the next point on documentation.</p><h4>[6] Write documentation</h4><p>Everyone says this, nobody does it.</p><h4>[7] Primarily use communication channels that are Googleable</h4><p>Slack is not internet searchable, and Gitter search results are terrible. When people have a problem they will often go to Google first to see if others have solved the problem. In Modin, we use GitHub issues and Discourse boards for discussions to make sure that people looking for solutions can find them. This also has the nice side effect of being able to point to those pages when someone asks the same question.</p><h4>[8] Give talks at small venues and meetups, not just the big ones</h4><p>Promoting work via talks at big venues does give you more visibility, but ultimately the smaller more intimate venues are where you’re more likely to make good connections with people who will actually use your project. It’s tempting at the beginning to try to go straight for giving talks at the big international conferences, but I’ve found that small meetups are both more focused (people are more likely to have the problem you’re solving) and more willing to talk. I gave talks to meetup groups as small as 6 people, and in those meetups I had more engaging conversations that in the larger venues. You need these relationships with your users early on to build momentum. Otherwise, once you do talk at these large venues and people will ask “Who is using your project?”. In the large conferences people claim to be looking for the next big technology to adopt, but really they just want to use what everyone else is using. Having users will get you more users, but you need the early adopters, and often you will meet them in small venues or meetups.</p><h4>[9] Make it easy to reach you</h4><p>This point will contradict with the point about communication channels being Googleable, but in general you need to be able to be reached by people who run into problems. Don’t make the communication overhead of reporting a bug a barrier to discovering the bug exists. In Modin, for example, we set up a couple of emails and if something went wrong internally we asked them to email us a bug report as a part of the error message. It has been pretty successful and there are several bugs we found that weren’t discoverable otherwise. We rarely get these today, which is a good indication that things are getting more stable.</p><p>Generally, to solve the issue of search indexability, I will ask people who email to open an issue if I triage it to be serious and new. I’ve found people are easier to go back/forth with over email, so you can get the simple stuff out of the way quickly as well (e.g. user environment issues or user errors).</p><h4>[10] Scale your efforts later, build a community first</h4><p>A lot of what I propose here doesn’t scale, and it will get worse as the number of users grows. This is by design. Even after you have a critical mass, it’s not likely you’ll have a large group of contributors outside of your organization (it took roughly 2 years for Modin to get serious outside contributor groups). Building a community is largely a social effort, and you need broadcasting on Twitter is not going to be enough to get the ball rolling. Everyone is doing that. If you want to actually build a community, you need to do things like talk to individuals and answer individual emails. The personal connections are more important than trying to make noise in a very noisy world, and they will get you farther than clicks or views on your tweets and blog posts.</p><h4>[11] Make it easy to contribute and ask for contributions</h4><p>Making your project easy to contribute to is a good way to help build a community. There are always people who are interested in working on projects on the side, and getting these people involved is important. Often, projects are too difficult to jump into years later. It is difficult to build a community when you’re the only person who knows how to do anything. You’re going to need people who can help with issues so you can take some time off every now and then to recharge. This is obvious, but it takes good design and a lot of DevOps work, which doesn’t necessarily equate to more code being output. In fact, often helping others will often reduce your own productivity and the overall code velocity of the project. This code velocity cost (on an individual basis) may actually never be recouped, but I argue that there are intangible benefits to working with other people:</p><ol><li>You need to justify your designs</li><li>Producing code is not a good metric of productivity — there are more important things than new features</li><li>Excited contributors often also become evangelists</li></ol><p>Adding contributors will not always yield more code or more bugfixes, but it helps build a community.</p><h3>Concluding thoughts</h3><p>I hope this has been helpful. It’s a lot of work to keep a community going, and the work is mostly social. There’s a lot of engineering in building something, but actually getting the word out and keeping in contact with users takes significant effort.</p><p>This list is by no means complete, but I hope it’s enough to help you get off the ground. Grad school is a great time to explore a bunch of different things, including open source community building and project management. I hope you can be as successful as I was (or more!) and that this list can help you plan how to execute on your great ideas. Please don’t hesitate to reach out to me directly if you have any questions (<a href="https://www.linkedin.com/in/devinpetersohn/">https://www.linkedin.com/in/devinpetersohn/</a>). I don’t consider myself an expert on open source community building (having only done it once!), but I will do my best to answer any questions you might have. Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94596efc31d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/so-you-want-to-build-an-open-source-tool-library-as-a-grad-student-94596efc31d1">So you want to build an open source tool/library as a grad student</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Feature Stores: The Data Side of ML Pipelines]]></title>
            <link>https://medium.com/riselab/feature-stores-the-data-side-of-ml-pipelines-7083d69bff1c?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/7083d69bff1c</guid>
            <category><![CDATA[feature-store]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[real-time-analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sarah Wooders]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 18:56:04 GMT</pubDate>
            <atom:updated>2021-04-29T20:08:36.814Z</atom:updated>
            <content:encoded><![CDATA[<p><em>We need a principled way of managing state in real-time ML pipelines.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mI9NnhfWah_TVTgo" /><figcaption>Written by <a href="http://sarahwooders.com/">Sarah Wooders</a>, <a href="https://pschafhalter.com/">Peter Schafhalter</a>, and<a href="https://people.eecs.berkeley.edu/~jegonzal/"> Joey Gonzalez</a></figcaption></figure><h3>The RISE of Feature Stores</h3><p>As more models are deployed in real-world pipelines, the recurring lesson is that data and <em>data featurization</em> matters above all else. The last generation of big data systems scaled ML to real-world datasets, and now<strong> </strong>feature stores are quickly emerging as a new frontier for connecting models to real-time data [1].</p><blockquote><em>Keeping features up-to-date is critical for model accuracy, but expensive and hard to scale.</em></blockquote><p>Feature stores, as the name implies, store features derived from raw data and serve them to downstream models for training and inference. For example, a feature store might store the last few pages a user browsed (i.e., a sliding window over the clickstream) as well as the current predicted user demographics (i.e., a model prediction) both of which would be high-value features for an ad targeting model.</p><blockquote><em>Unfortunately, many feature stores being built today are </em>Frankensteinian<em> amalgamations of batch, streaming, caching, and storage systems.</em></blockquote><p>In this post, we (1) define what feature stores are and how they are used today, (2) highlight some of the design limitations of the current generation of feature stores, and (3) describe how innovation in feature store designs could transform production machine learning by managing state across training and inference pipelines in a more principled way.</p><h3>Background</h3><h4>Why feature stores?</h4><p>A simple ML pipeline trains a model from a static dataset, then serves the model to respond to user inference requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dc0NaOOs4xo1cH4O" /><figcaption>Predictions are generated from model parameters and request data.</figcaption></figure><p><strong>However, in order to adapt to a continuously changing world, modern ML pipelines need to make decisions which depend on real-time data [2]. </strong>For example a model predicting ETA might use <a href="https://doordash.engineering/2021/03/04/building-a-declarative-real-time-feature-engineering-framework/">features like the recent order fulfillment times of a restaurant</a>, or a content recommendation model could consider a user’s most recent clicks. Model training and inference therefore rely on <em>real-time features </em>derived from joining, transforming, and aggregating over incoming streams of data. Because the featurization step can be expensive, features need to be pre-computed and cached to avoid redundant computation and to meet tight prediction latency requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5VqSzEyloJrA9UwS" /><figcaption>Predictions also rely on features derived from live streams of data.</figcaption></figure><h3>What are feature stores?</h3><p><em>Feature stores</em> are used to store and serve features across multiple branches of the pipeline, allowing for shared computation and optimizations. While different feature stores vary in their functionality, they typically manage the following:</p><ul><li><em>Serving features to meet varying query latency requirements</em> — Features are usually placed in both a fast “online store” (to query during inference) and durable “offline store” (to query during training).</li><li><em>Making features composable and extensible — </em>Once a feature is defined, it should be easy to connect it to downstream models, derive additional features from it, or redefine the feature’s schema or featurization function.</li><li><em>Maintaining features derived from real-time data</em> — Maintaining features is resource intensive, but stale features can negatively affect prediction performance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VYmA0l4dXrPbD-n5" /></figure><p>Certain features (e.g. a 1 minute time window aggregate) are very sensitive to staleness and need to be ultra-fresh, while others (e.g. 30 day windows) may only need periodic batch updates. As the system that interfaces with both updates to and requests for features,<strong> feature stores are well positioned to optimize the tradeoffs between <em>freshness, latency, and cost.</em></strong></p><h3>Feature Stores Today: Challenges &amp; Limitations</h3><p>Many companies today have implemented feature stores internally to make features accessible to models deployed in production.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64f005665bfa6f8737f57b55c18d3bcc/href">https://medium.com/media/64f005665bfa6f8737f57b55c18d3bcc/href</a></iframe><p>Feature stores today are built atop existing streaming, batch, caching, and storage systems. While each of these systems solve challenging problems in isolation, their constraints are problematic for feature stores.</p><ul><li><strong>Batch processing systems</strong> like Spark enable complex queries over static datasets, but introduce excessive latency when serving features and trigger total recomputations when backfilling data.</li><li><strong>Streaming systems</strong> such as Flink and Spark Streaming enable low-latency pipelines, but fall short when asked to maintain large amounts of state. Lambda architectures combine both batch and streaming systems, but result in costly duplicate computation and complex maintenance of both streaming and batch codebases.</li><li><strong>Streaming databases </strong>with materialized views can offer advantages of both rapid computation and storage, but these are difficult to adapt to arbitrary featurization operations. Their query latencies may also be too high for prediction serving.</li><li>I<strong>n-memory key-value stores</strong> like Redis provide a fast way to access features, but these are typically difficult to update in a consistent manner and expensive to scale.</li></ul><p>Many of the requirements for feature stores can be met with a combination of these systems. However, the resulting pipeline is rigid and hard to optimize end-to-end. For example, prioritizing featurization tasks based on their impact on overall prediction accuracy would require coordination between the data store receiving queries, the streaming system pushing live updates, and the batch processing system for processing historical data. Rather than awkwardly combining multiple compute engines with multiple databases to meet multiple latency targets, feature stores should take advantage of their access to incoming events and query patterns to optimize latency, compute cost, and prediction accuracy in a centralized way.</p><h3>The Future of Feature Stores</h3><p>We believe feature stores can offer centralized state management for ML pipelines, and have exciting potential for:</p><ol><li><strong>Lineage Management: Feature stores open the door to a new, data-centric abstraction for developing and tuning machine learning pipelines. </strong>The complexity of existing machine learning pipelines often makes it difficult to ensure basic reproducibility, apply pipeline changes, or perform optimizations across the pipeline. While meticulous versioning and synchronization can solve these problems to a certain extent, applying these techniques to constantly evolving datasets and pipelines is <em>simply hard to think about</em>. A data-centric view on pipelines (for example, <a href="https://scattered-thoughts.net/writing/an-opinionated-map-of-incremental-and-streaming-systems">treating data pipelines as materialized views</a>) has the potential to introduce new abstractions which simplifies the process for propagating data and operator changes.</li><li><strong>End-to-End Optimization: Feature stores are well positioned to enable new end-to-end optimizations across ML data pipelines.</strong> Current systems restrict computation to running in <a href="https://huyenchip.com/2020/12/27/real-time-machine-learning.html#stream_pipeline">either an event-based or request-based manner</a>, making it difficult to schedule tasks in a way that optimizes common metrics like prediction performance and cost. Practitioners should be able to configure their pipelines to optimize for cost saving (lazy computation/updates, approximate results), inference latency (eager computation), or overall prediction performance (update features with most impact).</li><li><strong>Scalable State Management: Feature stores indicate the need to scalably maintain and persist state within ML pipelines. </strong>Real-time, production ML pipelines often need to maintain tens of million of features derived from multiple, dense incoming streams of data. Feature sets may be too large to persist in memory or update with every incoming stream event as a stream processing system would by default, but also need to be updated more frequently than a batch processing system allows.</li></ol><h3>Conclusion</h3><p>We’re actively studying the design of feature store systems, so let us know if you’re interested in staying up-to-date or collaborating!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Foxusywtskdx.typeform.com%2Fto%2FOpUD4C4b%3Ftypeform-embed%3Doembed%26typeform-medium%3Dembed-oembed%26format%3Djson&amp;display_name=Typeform&amp;url=https%3A%2F%2Foxusywtskdx.typeform.com%2Fto%2FOpUD4C4b&amp;image=https%3A%2F%2Fimages.typeform.com%2Fimages%2FFYUps4mFKPYK%2Fimage%2Fdefault&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=typeform" width="900" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/2eecfd8942a608c3a01e5d1f86e20dd5/href">https://medium.com/media/2eecfd8942a608c3a01e5d1f86e20dd5/href</a></iframe><p>If you’d like to get involved with our research, feel free to reach out to wooders@berkeley.edu.</p><h3>Notes</h3><p><em>[1] By “real-time data”, we are referring to data that needs to be processed in real time, both in the context of online prediction serving and maintaining data freshness for features.</em></p><p><em>[2] Updates for “real-time” data typically need to be on the order of seconds, but can vary between workloads.</em></p><h3>Acknowledgments</h3><p>Thank you to Manmeet Gujral, Gaetan Castelein, and Kevin Stumpf from Tecton, as well as Joe Hellerstein, Natacha Crooks, Simon Mo, Richard Liaw, and other members of the RISELab for providing feedback on this post.</p><h3>References</h3><ol><li><a href="https://nchammas.com/writing/data-pipeline-materialized-view">https://nchammas.com/writing/data-pipeline-materialized-view</a></li><li><a href="https://scattered-thoughts.net/writing/an-opinionated-map-of-incremental-and-streaming-systems">https://scattered-thoughts.net/writing/an-opinionated-map-of-incremental-and-streaming-systems</a></li><li><a href="https://doordash.engineering/2020/11/19/building-a-gigascale-ml-feature-store-with-redis/">https://doordash.engineering/2020/11/19/building-a-gigascale-ml-feature-store-with-redis/</a></li><li><a href="https://www.tecton.ai/blog/what-is-a-feature-store/">https://www.tecton.ai/blog/what-is-a-feature-store/</a></li><li><a href="https://netflixtechblog.com/system-architectures-for-personalization-and-recommendation-e081aa94b5d8">https://netflixtechblog.com/system-architectures-for-personalization-and-recommendation-e081aa94b5d8</a></li><li><a href="https://huyenchip.com/2020/12/27/real-time-machine-learning.html#stream_pipeline">https://huyenchip.com/2020/12/27/real-time-machine-learning.html#stream_pipeline</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7083d69bff1c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/feature-stores-the-data-side-of-ml-pipelines-7083d69bff1c">Feature Stores: The Data Side of ML Pipelines</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI and Memory Wall]]></title>
            <link>https://medium.com/riselab/ai-and-memory-wall-2cb4265cb0b8?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/2cb4265cb0b8</guid>
            <category><![CDATA[hardware-accelerator]]></category>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Amir Gholami]]></dc:creator>
            <pubDate>Mon, 29 Mar 2021 15:30:16 GMT</pubDate>
            <atom:updated>2024-03-22T05:42:10.597Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Update: An extended version of this blogpost is published in IEEE Micro Journal and is available </strong><a href="http://arxiv.org/abs/2403.14123"><strong>online here</strong></a>.</p><p>(This blogpost has been written in collaboration with <strong>Zhewei Yao, Sehoon Kim, Michael W. Mahoney, and Kurt Keutzer. </strong>The data used for this study is available <a href="https://github.com/amirgholami/ai_and_memory_wall">online</a>.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8a7LMmRtEc0wRrRRa7f0Cw.png" /><figcaption>Figure 1: The amount of compute, measured in Peta FLOPs, needed to train SOTA models, for different CV, NLP, and Speech models, along with the different scaling of Transformer models (750x/2yrs)*¹ [<a href="https://github.com/amirgholami/ai_and_memory_wall/blob/main/imgs/pdfs/ai_and_compute.pdf">Download This Image</a>]</figcaption></figure><p>The amount of compute needed to train SOTA Transformer models, has been growing at a rate of 750x/2yrs. This exponential trend has been the main driver for AI accelerators that focus on increasing the peak compute power of hardware, often at the expense of simplifying and/or removing other parts such as memory hierarchy.</p><p>However, these trends miss an emerging challenge with training and serving these models: memory and communication bottlenecks. In fact, several AI applications are becoming bottlenecked by intra/inter-chip and communication across/to AI accelerators rather than compute. In particular, the flagship LLM model sizes has been increasing at a rate of 410x every 2 years. See Figure 2. Similarly, Large Recommendation System models have reached O(10) TB parameters. Contrast this with accelerator DRAM memory, which has only scaled at a rate of 2x every 2 years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gjCcFBQi-7yygm7jrqYQw.png" /><figcaption>Figure 2: The evolution of the number of parameters of SOTA models over the years, along with the AI accelerator memory capacity (green dots). The number of parameters in large Transformer models has been exponentially increasing with a factor of 410x every two years*², while the single GPU memory has only been scaled at a rate of 2x every 2 years.*³ [<a href="https://github.com/amirgholami/ai_and_memory_wall/blob/main/imgs/pdfs/model_size_scaling.pdf">Download This Image</a>]</figcaption></figure><p>It is important to note that the memory requirements to train AI models are typically several times larger than the number of parameters. This is because training requires storing intermediate activations, and this typically adds 3–4x more memory than the number of parameters (excluding embeddings). This is illustrated in Figure 3, where the total training memory footprint is shown for training different flagship AI models throughout the years. We can clearly see how the design of SOTA Neural Network (NN) models has been implicitly influenced by the DRAM capacity of the accelerators in different years.</p><p>These challenges are commonly referred to as the <strong>memory wall</strong> problem, a term originally coined by William Wulf and Sally Mckee in 1995 [25]. The memory wall problem involves both the limited capacity and the bandwidth of memory transfer. This entails different levels of memory data transfer. For example, data transfer between compute logic and on-chip memory, or between compute logic and DRAM memory, or across different processors on different sockets. For all these cases, the capacity and the speed of data transfer has been significantly lagging behind hardware (HW) compute capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjJYBC04yGMGq-fgF3i3tA.png" /><figcaption>Figure 3: The amount of memory required to train different NN models. Here, the optimizer used for CV models is SGD+Momentum, and for NLP models is ADAM. There is an interesting trend in discovering/designing new models, based on the available GPU memory size. Every time the GPU memory capacity is increased, data scientists have designed newer models. As such, breaking this so-called <em>GPU memory wall</em> could further allow new innovations. See [2] for more details on checkpointing. [<a href="https://github.com/amirgholami/ai_and_memory_wall/blob/main/imgs/pdfs/gpu_memory_wall.pdf">Download This Image</a>]</figcaption></figure><p>One might hope that we can use distributed-memory parallelism by <em>scaling-out</em> the training to multiple accelerators to avoid the single HW’s limited memory capacity and bandwidth. However, distributing the work over multiple processes also faces the <strong>memory wall </strong>problem: the communication bottleneck of moving data between NN accelerators, which is even slower and less efficient than on-chip data movement. Similar to the single system memory case, we have not been able to overcome the technological challenges to scale the network bandwidth. This can be seen from Figure 4, where we show how the peak compute has increased by 60,000x over the past 20 years, as opposed to 100x for DRAM or 30x for interconnect bandwidth. Unfortunately, it has been very difficult to overcome the fundamental challenges of increasing DRAM/Interconnect bandwidth [1]. As such, scale-out only works for highly compute-bound problems with very little communication and data transfer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qty8oEjinArM-wIAly_ZdA.png" /><figcaption>Figure 4: The scaling of the bandwidth of different generations of interconnections &amp; Memory, as well as the Peak FLOPS. As can be seen, the bandwidth is increasing very slowly.*⁴ [<a href="https://github.com/amirgholami/ai_and_memory_wall/blob/main/imgs/pdfs/hw_scaling.pdf">Download This Image</a>]</figcaption></figure><p><strong>Promising Solutions for Breaking the Wall:</strong></p><p>“<strong>No exponential can continue forever,</strong>” and delaying an exponential scaling at the rate of 410x/2yrs is not going to be feasible for long, even for large hyperscalar companies. This coupled with the increasing gap between compute and bandwidth capability will soon make it very challenging to train larger models, as the cost will be exponentially higher.</p><p>To continue the innovations and break the memory wall, we need to rethink the design of AI models. There are several issues here. First, the current methods for designing AI models are mostly ad-hoc, and/or involve very simple scaling rules. For instance, recent large Transformer models are mostly just a scaled version of almost the same base architecture proposed in the original BERT model [22]. Second, we need to design more data efficient methods for training AI models. Current NNs require a huge amount of training data and hundreds of thousands of iterations to learn, which is very inefficient. Some might note that it is also different from how human brains learn, which often only require very few examples per concept/class. Third, the current optimization and training methods need a lot of hyperparameter tuning (such as learning rate, momentum, etc.), which often results in hundreds of trial and error sweeps to find the right setting to train a model successfully. As such, the training cost reported in Figure 1 is only a lower bound of the actual overhead, and the true cost is typically much higher. Fourth, the prohibitive size of the SOTA NN models makes their deployment for inference very challenging. This is not just restricted to models such as GPT-3. In fact, deploying large recommendation systems (which are similar to Transformers but which have much larger embedding and very few MLP layers afterwards [23]) that are used by hyperscalar companies is a major challenge. Finally, the design of hardware accelerators has been mainly focused on increasing peak compute with relatively less attention on improving memory-bound workloads. This has made it difficult both to train large models, as well as to explore alternative models, such as Graph NNs which are often bandwidth-bound and cannot efficiently utilize current accelerators.</p><p>All of these issues are fundamental problems in machine learning. Here, we briefly discuss recent research (including some of our own) that has targeted the last three items.</p><p><strong>Efficient Training Algorithms</strong></p><p>One of the main challenges with training NN models is the need for brute-force hyperparameter tuning. This includes finding the learning rate, its annealing schedule, the number of iterations needed to converge, etc. This adds (much) more overhead for training SOTA models. Many of these problems arise from the first-order SGD methods used for training. While SGD variants are easy to implement, they are not robust to hyperparameter tuning, and are very hard to tune for new models for which the right set of hyperparameters are unknown. One promising approach to address this is to use second-order stochastic optimization methods such, as in our recently-developed ADAHESSIAN method [4]. These methods are typically more robust to hyperparameter tuning, and they can achieve SOTA. However, current methods have 3–4x higher memory footprint, which needs to be addressed. A promising line of work for that is the Zero paper from Microsoft, which showed how one can train 8x bigger models with the same memory capacity by removing/sharding redundant optimization state variables [21, 3]. If the overhead of these higher-order methods could be addressed, then they can signficantly reduce the total cost of training large models.</p><p>Another promising approach includes reducing the memory footprint and increasing the data locality of optimization algorithms, at the expense of performing more computations. One simple example is to only store/checkpoint a subset of activations during the forward pass, instead of saving all activations, to reduce the feature map’s memory footprint shown in Figure 3. The rest of the activations could then be recomputed when needed. Even though this will increase compute, one can significantly reduce the memory footprint by up to 5x [2] with just 20% more compute.</p><p>Another important solution is to design optimization algorithms that are robust to low precision training. In fact, one of the major breakthroughs in AI accelerators has been the use of half-precision (FP16) arithmetic, instead of single precision [5,6]. This has enabled more than 10x increase in hardware compute capability. However, it has been challenging to further reduce the precision from half-precision to INT8 without accuracy degradation with current optimization methods.</p><p><strong>Efficient Deployment</strong></p><p>Deploying recent SOTA models such as GPT-3 or large recommendation systems is quite challenging, as they require distributed-memory deployment for inference. One promising solution to address this is to compress these models for inference, by reducing the precision (i.e., quantization) or removing (i.e., pruning) their redundant parameters.</p><p>The first approach is quantization, a method that can be applied at the training and/or inference steps. While it has been very challenging to reduce the training precision much below FP16, it is possible to use ultra-low precision for inference. With current methods, it is relatively easy to quantize inference down to INT4 precision, with minimal impact on accuracy. This results in up to 8x reduction in model footprint and latency [7,8,19,20]. However, inference with sub-INT4 precision is more challenging and is currently a very active area of research.</p><p>Another possibility is to completely remove/prune redundant parameters in the model. With current methods, it is possible to prune up to 30% of neurons with structured sparsity, and up to 80% with unstructured sparsity, with minimal impact on accuracy [9,10]. Pushing beyond this limit, however, is very challenging, and it often results in fatal accuracy degradation. Resolving this is an open problem.</p><p><strong>Rethinking the Design of AI Accelerators</strong></p><p>There are fundamental challenges in increasing both the memory bandwidth and the peak compute capability of a chip at the same time [1]. However, it is possible to sacrifice peak compute to achieve better compute/bandwidth trade-offs. This is not an impossible task, and in fact, the CPU architecture already incorporates a well-optimized cache hierarchy. This is why CPUs have much better performance than GPUs for bandwidth-bound problems. Such problems include large recommendation problems. However, the main challenge with today’s CPUs is that their peak compute capability (i.e., FLOPS) is about an order of magnitude less than AI accelerators such as GPUs or TPUs. One reason for this is that AI accelerators have mainly been designed to achieve maximum peak compute. This often requires removing components such as cache hierarchy in favor of adding more compute logic. One could imagine an alternative architecture in between these two extremes, preferably with more efficient caching, and importantly with higher capacity DRAM (possibly a hierarchy of DRAMs with different bandwidths). The latter could be very helpful in mitigating the distributed-memory communication bottlenecks [18].</p><p><strong>Conclusion</strong></p><p>The computational cost of training recent SOTA Transformer models in NLP has been scaling at a rate of 750x/2yrs, and the model parameter size has been scaling at 400x/2yrs. In contrast, the peak hardware FLOPS is scaling at a rate of 3x/2yrs, while both the DRAM and interconnect bandwidth have been increasingly falling behind, with a scaling rate of 1.6x/2yrs and 1.4x/2yrs, respectively. To put these numbers into perspective, peak hardware FLOPS has increased by 60,000x over the past 20 years, while DRAM/Interconnect bandwidth has only scaled by a factor of 100x/30x over the same time period. With these trends, memory — in particular, intra/inter-chip memory transfer — will soon become the main limiting factoring in training large AI models. As such, we need to rethink the training, deployment, and design of AI models as well as how we design AI hardware to deal with this increasingly challenging memory wall.</p><p>We would like to thank Suresh Krishna, and Aniruddha Nrusimha for their valuable feedback.</p><p>[Update]: This article was updated on Sep, 2, 2023 with newer hardware and model data available.</p><p>*¹ We are specifically not including the cost of training Reinforcement Learning models in this graph, as the training cost is mostly related to the simulation environment and there is currently no consensus on a standard simulation environment. Also note that we report the PFLOPs required to train each model to avoid using any approximation for hardware deployment utilization, as the latter depends on the specific library and the hardware used. Finally, all the rates in this document have been computed by solving a linear regression to fit the data shown in each graph.</p><p>*² The growth rate shown in Figure 2 is calculated by only considering the Transformer based models (blue circles), and not the recommendation systems.</p><p>*³ The GPU memory is plotted by dividing the corresponding memory size by 6 as an approximate upper bound for the largest model that can be trained with the corresponding capacity.</p><p>*⁴ We are normalizing hardware peak FLOPS with the R10000 system, as it was used to report the cost of training Lenet-5 in the seminal work of [24].</p><p><strong>REFERENCES:</strong></p><p>[1] Patterson DA. Latency lags bandwidth. Communications of the ACM. 2004 Oct 1;47(10):71–5.</p><p>[2] Jain P, Jain A, Nrusimha A, Gholami A, Abbeel P, Keutzer K, Stoica I, Gonzalez JE. Checkmate: Breaking the memory wall with optimal tensor rematerialization. arXiv preprint arXiv:1910.02653. 2019 Oct 7.</p><p>[3] Rajbhandari S, Rasley J, Ruwase O, He Y. Zero: Memory optimizations toward training trillion parameter models. InSC20: International Conference for High Performance Computing, Networking, Storage and Analysis 2020 Nov 9 (pp. 1–16). IEEE.</p><p>[4] Yao Z, Gholami A, Shen S, Keutzer K, Mahoney MW. ADAHESSIAN: An adaptive second order optimizer for machine learning. arXiv preprint arXiv:2006.00719. 2020 Jun 1.</p><p>[5] Ginsburg B, Nikolaev S, Kiswani A, Wu H, Gholaminejad A, Kierat S, Houston M, Fit-Florea A, inventors; Nvidia Corp, assignee. Tensor processing using low precision format. United States patent application US 15/624,577. 2017 Dec 28.</p><p>[6] Micikevicius P, Narang S, Alben J, Diamos G, Elsen E, Garcia D, Ginsburg B, Houston M, Kuchaiev O, Venkatesh G, Wu H. Mixed precision training. arXiv preprint arXiv:1710.03740. 2017 Oct 10.</p><p>[7] Yao Z, Dong Z, Zheng Z, Gholami A, Yu J, Tan E, Wang L, Huang Q, Wang Y, Mahoney MW, Keutzer K. HAWQV3: Dyadic Neural Network Quantization. arXiv preprint arXiv:2011.10680. 2020 Nov 20.</p><p>[8] Gholami A, Kim S, Yao Z, Dong Z, Mahoney M, Keutzer K, A Survey of Quantization Methods for Efficient Neural Network Inference, arxiv preprint, arxiv:arXiv:2103.13630, 2021.</p><p>[9] Gale T, Elsen E, Hooker S. The state of sparsity in deep neural networks. arXiv preprint arXiv:1902.09574. 2019 Feb 25.</p><p>[10] Hoefler T, Alistarh D, Ben-Nun T, Dryden N, Peste A. Sparsity in Deep Learning: Pruning and growth for efficient inference and training in neural networks. arXiv preprint arXiv:2102.00554. 2021 Jan 31.</p><p>[11] Iandola FN, Han S, Moskewicz MW, Ashraf K, Dally WJ, Keutzer K. SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and&lt; 0.5 MB model size. arXiv preprint arXiv:1602.07360. 2016 Feb 24.</p><p>[12] Gholami A, Kwon K, Wu B, Tai Z, Yue X, Jin P, Zhao S, Keutzer K. Squeezenext: Hardware-aware neural network design. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops 2018 (pp. 1638–1647).</p><p>[13] Wu B, Iandola F, Jin PH, Keutzer K. Squeezedet: Unified, small, low power fully convolutional neural networks for real-time object detection for autonomous driving. InProceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops 2017 (pp. 129–137).</p><p>[14] Shaw A, Hunter D, Landola F, Sidhu S. SqueezeNAS: Fast neural architecture search for faster semantic segmentation. InProceedings of the IEEE/CVF International Conference on Computer Vision Workshops 2019.</p><p>[15] Wu B, Wan A, Yue X, Keutzer K. Squeezeseg: Convolutional neural nets with recurrent crf for real-time road-object segmentation from 3d lidar point cloud. In2018 IEEE International Conference on Robotics and Automation (ICRA) 2018 May 21 (pp. 1887–1893). IEEE.</p><p>[16] Iandola FN, Shaw AE, Krishna R, Keutzer KW. SqueezeBERT: What can computer vision teach NLP about efficient neural networks?. arXiv preprint arXiv:2006.11316. 2020 Jun 19.</p><p>[17] Howard AG, Zhu M, Chen B, Kalenichenko D, Wang W, Weyand T, Andreetto M, Adam H. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861. 2017 Apr 17.</p><p>[18] Krishna S, Krishna R. Accelerating Recommender Systems via Hardware” scale-in”. arXiv preprint arXiv:2009.05230. 2020 Sep 11.</p><p>[19] Kim S, Gholami A, Yao Z, Mahoney MW, Keutzer K. I-BERT: Integer-only BERT Quantization. arXiv preprint arXiv:2101.01321. 2021 Jan.</p><p>[20] Patrick Judd, Senior Deep Learning Architect, Integer Quantization for DNN Acceleration, Nvidia, GTC 2020.</p><p>[21] Bottou L, Curtis FE, Nocedal J. Optimization methods for large-scale machine learning. Siam Review. 2018;60(2):223–311.</p><p>[22] Devlin J, Chang MW, Lee K, Toutanova K. BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805. 2018 Oct 11.</p><p>[23] Naumov M, Mudigere D, Shi HJ, Huang J, Sundaraman N, Park J, Wang X, Gupta U, Wu CJ, Azzolini AG, Dzhulgakov D. Deep learning recommendation model for personalization and recommendation systems. arXiv preprint arXiv:1906.00091. 2019 May 31.</p><p>[24] LeCun Y, Bottou L, Bengio Y, Haffner P. Gradient-based learning applied to document recognition. Proceedings of the IEEE. 1998 Nov;86(11):2278–324.</p><p>[25] W. A. Wulf and S. A. McKee, “Hitting the memory wall: Implications of the obvious,” ACM SIGARCH computer architecture news, vol. 23, no. 1, pp. 20–24, 1995.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cb4265cb0b8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/ai-and-memory-wall-2cb4265cb0b8">AI and Memory Wall</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why every data scientist using pandas needs Modin — Bringing SQL to Dataframes]]></title>
            <link>https://medium.com/riselab/why-every-data-scientist-using-pandas-needs-modin-bringing-sql-to-dataframes-3b216b29a7c0?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/3b216b29a7c0</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jorge Torres]]></dc:creator>
            <pubDate>Mon, 22 Mar 2021 16:35:49 GMT</pubDate>
            <atom:updated>2021-03-25T19:09:38.465Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Bringing SQL to Dataframes — </strong>Why every data scientist using pandas needs Modin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*JMKPcpCW-twDS2ur5BKLEw.png" /><figcaption>Written by <a href="https://medium.com/u/5d6686a53741">Jorge Torres </a>and <a href="https://medium.com/u/c3e3336d01b8">Devin Petersohn</a></figcaption></figure><p>While recently speaking with a data scientist friend from the <a href="https://rise.cs.berkeley.edu/">RiseLab</a> in Berkeley who primarily operates in the pandas API using <a href="https://github.com/modin-project/modin">Modin</a>. She mentioned that she was trying to solve a problem for a client who required her to write a query in SQL that she would normally write in pandas. As she was looking on StackOverflow, she noticed that there is a whole world of questions around “What is the SQL equivalent of this pandas query?” and vice-versa.</p><p>She also noted that sharing code and notebooks with other data scientists in her company was difficult when they were not comfortable with the pandas API. If her colleague had a follow-up question, they would either need to go back and forth with questions and answers or schedule a meeting to figure it out in-person with one person at the keyboard. Her colleagues could not just run queries in their preferred language without rewriting the entire notebook.</p><p>Data Scientists are increasingly required to do and learn more, but tools have largely lagged supporting all of these new requirements. Moving between languages and computing environments is expensive and costs data scientists hours of productivity every week.</p><p><strong>To improve data science productivity, </strong><a href="https://mindsdb.com/"><strong>MindsDB</strong></a><strong> has teamed up with </strong><a href="https://github.com/modin-project/modin"><strong>Modin</strong></a><strong> to bring in-memory SQL to distributed Modin Dataframes.</strong> Now you can run SQL alongside the pandas API without copying or going through your disk. What this means is that you can now have a SQL solution that you can seamlessly scale horizontally and vertically, by leveraging the incredible power of <a href="https://github.com/ray-project/ray">Ray</a>.</p><h3><strong>Presenting modin.sql</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*0feM9tZj5aVImEtgKT098A@2x.jpeg" /></figure><p>Here is a summary by example:</p><p>Imagine you have data about reviews for apps in the google store, this information is in two tables, one for the store apps and another one for the reviews, that you can join by the app column, lets start with the apps table:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4d2fb18cf4484e503d2e23a9079088e/href">https://medium.com/media/f4d2fb18cf4484e503d2e23a9079088e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-KCRXZnmgfkiAZZlBOMnIA.png" /></figure><p>Imagine that you want to quickly select from ‘gstore_apps_df’ the columns <em>App, Category, and Rating, where Price is ‘0’.</em></p><p>In SQL, this looks like this:</p><pre><strong>&quot;SELECT App,Category,Rating FROM gstore_apps WHERE Price = &#39;0&#39; &quot;</strong></pre><p>However, for many of us, the solution to many of these problems often starts like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wcOUJD8sPr6ETqEfwXE9Ww.png" /></figure><p>In the end, you get something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb5b8d6cce6a846b5b9c5c56647ded90/href">https://medium.com/media/fb5b8d6cce6a846b5b9c5c56647ded90/href</a></iframe><p>Which makes sense if Pandas is your way of doing these tasks. But, for those of you that know some SQL, we want to introduce an in-memory SQL engine that operates on Dataframes, so you can have more options when it comes to using the incredible power of distributed dataframes of Modin.</p><p>The function to access that engine is called “<strong><em>modin.experimental.sql.query</em></strong>”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9fb11c5a41c02378e9ff74de8c4cdd2/href">https://medium.com/media/d9fb11c5a41c02378e9ff74de8c4cdd2/href</a></iframe><p>The in-memory SQL engine for data-frames, allows you to run complex queries. You can in a very explicit SQL statement, perform operations such as joins and aggregations.</p><p>Let’s bring the other table (reviews) to illustrate the powers of SQL on Dataframes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11b8f02b5c7b9b228cffa004e9d31b03/href">https://medium.com/media/11b8f02b5c7b9b228cffa004e9d31b03/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8nNTIaWtVtfcd-bszAMdg.png" /></figure><p>Imagine that you want to know what are the best-reviewed app categories where there is little subjectivity: Get the top 10 app categories ranked by best average ‘<em>sentiment_polarity’</em> where the average ‘sentiment_subjectivity’ is less than 0.5.</p><p>Since ‘<em>Category’</em> is on the <strong>gstore_apps_df </strong>and s<em>entiment_polarity</em> is on <strong>gstore_reviews_df </strong>this requires that we join the two tables, and operate averages on that join.</p><p>You can solve this by doing it all in one single SQL query:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd1c24a9f4379737873983d6e1acfb4d/href">https://medium.com/media/bd1c24a9f4379737873983d6e1acfb4d/href</a></iframe><p>Or, you can bring the best of doing this in python and do it in parts (it’s up to you), but we believe that this certainly gives you more powers than if you were to do this in say Redshift.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad070c58bbe1fbc2a6b8fcc71f49d6fa/href">https://medium.com/media/ad070c58bbe1fbc2a6b8fcc71f49d6fa/href</a></iframe><p>The crazy thing here is that if you have a cluster or even a computer with more than one core, you can write SQL and Modin will run those queries in a distributed and optimized way. You can think of Modin + SQL as an Open-source alternative to Snowflake.</p><p>In our next article, we would like to present some benchmarks of running SQL on Distributed Modin Dataframes vs some SQL databases and Data-lakes. Thanks to our friends at Intel, that have provided us with some fancy computers where we can run Modin on many cores with lots of Memory.</p><p>In the meantime, you can check out, our Notebook with more examples and ideas <a href="https://github.com/mindsdb/dfsql/blob/stable/testdrive.ipynb">https://github.com/mindsdb/dfsql/blob/stable/testdrive.ipynb</a></p><p><em>Special thanks to the Modin and MindsDB team, </em><a href="https://medium.com/u/8f5647239ee"><em>Boris Tseitlin</em></a><em>, the Rise Lab </em><a href="https://medium.com/u/255942f15b34"><em>UC Berkeley</em></a><em>, and </em><a href="https://medium.com/u/fb610dd2569b"><em>Intel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b216b29a7c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/why-every-data-scientist-using-pandas-needs-modin-bringing-sql-to-dataframes-3b216b29a7c0">Why every data scientist using pandas needs Modin — Bringing SQL to Dataframes</a> was originally published in <a href="https://medium.com/riselab">riselab</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 ensure a data scientist is never productive]]></title>
            <link>https://medium.com/riselab/how-to-ensure-a-data-scientist-is-never-productive-6702d2990bd3?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/6702d2990bd3</guid>
            <category><![CDATA[modin]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[dataframes]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Devin Petersohn]]></dc:creator>
            <pubDate>Wed, 07 Oct 2020 15:13:34 GMT</pubDate>
            <atom:updated>2020-10-07T15:13:34.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwvlwa4UjBVZD7QGgGBiPA.jpeg" /><figcaption>Photo by Andrea Piacquadio (pexels.com)</figcaption></figure><h4>We need to start placing a higher value on data scientists’ time than we do on machine time</h4><p>While data science tools are being optimized to perform well on microbenchmarks, they are becoming more and more difficult to use. Is the benchmark performance worth the human time cost it takes to get there? <strong>(Spoiler: it would take up to 200 years to recoup the upfront cost to learning a new tool, even if the new tool performs 10x faster)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ylLesDSk6T3Vt5V3itKmZg.png" /><figcaption>Time to recoup the cost of learning a new tool, see below for detailed calculation</figcaption></figure><p><strong>Modin (</strong><a href="https://github.com/modin-project/modin"><strong>https://github.com/modin-project/modin</strong></a><strong>)</strong> is designed and optimized for Data Scientist time, enabling performance without code changes.</p><h3>Pushing complexity onto the data scientist</h3><p>Let’s design a system. If we want to ensure data scientists are not productive, the first thing we probably want to do is force them to learn a lot of new and unnecessary concepts for tuning performance, like partitioning and resource management. To further reduce data scientist productivity, let’s also introduce a completely new API. This has the nice side-effect of system lock-in, making it harder to leave once adopted. In any case, <strong>trading human time for machine time</strong> is the most effective way to ensure that data scientists are not productive.</p><p>I want to do a thought experiment to see exactly how much the overheads of learning an entirely new ecosystem and new distributed computing expertise actually cost. Then we can model how much computation a new system would need to save to begin to make returns on the time cost. This way we can see how much productivity we actually cost the user.</p><h4>Modeling the cost of learning a new tool (that does the same thing)</h4><p>To model the user, we will first simulate “proficiency” with a linear relationship to time. To make things simple, let’s say it takes an average of 2 years to be as proficient in a new tool as they are with an existing tool. This 2 years includes gaining an understanding of the new requirements of the system, like distributed computing, partitioning, etc. Let’s also say that proficiency and productivity are 1:1 correlated, so proficiency is a proxy for productivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pK1mG231HLKkSnc3rZE22w.png" /></figure><p>Because of the linear relationship we are using the total productivity loss is 1/2 of the 2 years it took to become proficient. According to Glassdoor, the average yearly salary of a data scientist in the United States is $113,000 USD as of writing this. So by our back of the envelope calculation, we have an estimated total productivity cost of $113,000 <strong>per data scientist</strong>. <strong>The productivity loss for a team of 5 exceeds $500,000 USD.</strong></p><h4>How long will it take to recoup the $113,000 investment on compute?</h4><p>For simplicity let’s use the per-hour cost of the AWS m4.4xlarge, as of writing it is $0.80 per hour. m4.4xlarge has 16 CPU cores and 64GB RAM. To recoup the $113,000 productivity cost of the one year lost, <strong>you would need to save</strong>, in aggregate, over 16 years worth of compute time on this instance. To get the number of CPU years per core, we just multiply 16 years x 16 CPU cores = 256 CPU years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VoNoRscg7Qj7vpvVURyKLg.png" /></figure><p>How many compute years does the average data scientist use in a given day? If we assume a single CPU is running 50% of work hours (which it isn’t), we get 4 hours/day, or 12.5% of the day. Extrapolating to the entire year, 12.5% of the year is spent running compute with these numbers, so <strong>it takes 8 real years to accumulate one CPU year in productive compute</strong>. Remember this number, it will be important shortly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_KM-QJyp0Hyg_rjVQirZVQ.png" /></figure><p>If we need to save 256 CPU years and the new system is 10x faster or with 10x more data, it will take about 25 CPU years in the new tool to make up for that time compared to the old tool. But wait, it takes 8 real years to accumulate one CPU year. <strong>At a 10x improvement, it would take 200 years to recoup the upfront cost of losing 1 year of productivity!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P522NOFPV8VSoj_6ZyyIFQ.png" /></figure><p>This simple calculation cannot possibly reflect all of the details of every data scientist’s reality, but the goal is not to perfectly model reality. Instead, its purpose is to demonstrate that <strong>the human time cost to come up to speed on a new ecosystem is so much higher than any compute cost saved that talking purely about benchmarking performance pales in comparison.</strong></p><p>Improved performance does not equate 1:1 to improved productivity. The benchmarks presented in blogs and conferences always hide upfront costs.</p><ul><li>Do you have to learn a new API to do something you can already do?</li><li>Do you have to change file formats to get performance?</li><li>Do you have to tune performance to avoid being punished by a new tool?</li><li>Do you need to provision resources or request workers for the new tool?</li><li>How much <strong>human time</strong> does all of this cost?</li></ul><h3>Modin: Putting the focus back on the Data Scientist</h3><p><strong>Modin (</strong><a href="https://github.com/modin-project/modin"><strong>https://github.com/modin-project/modin</strong></a><strong>)</strong> is a data science platform designed around empowering data scientists without adding complexity and new requirements. It exposes the pandas API, with many other APIs and modes of interaction in the pipeline.</p><pre># import pandas as pd<br>import modin.pandas as pd # a drop-in replacement!</pre><p>Suddenly, our typical data science setup goes from this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XsHKqu0oLnIjyNUsZUa7eg.png" /></figure><p>To a workflow without costly conversion between ecosystems:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atswhC2hexEY4De5fraq-Q.png" /></figure><p><strong>Modin is disrupting the data science tooling space by prioritizing the data scientists time over hardware time.</strong> To this end, Modin has:</p><ol><li>No upfront cost to learning a new API</li><li>Integration with the Python ecosystem</li><li>Integration with Ray/Dask clusters (Run on/with what you have!)</li><li>Scalability and performance with <strong>no changes to existing pandas code</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MoyAD0bwXfNR7rWJSLS4Xw.png" /><figcaption>Modin performance scales as the number of nodes increases (with no changes to existing pandas code). Maximum time to startup the cluster was 3 minutes in each case, data from NYC Taxi. No performance tuning was performed. Baseline of pandas was not possible at this data scale.</figcaption></figure><p>Remember, the goal of data scientists is not to execute individual queries as fast as possible, it is to extract as much value as possible from their data. <strong>Tools should work for the data scientist, data scientists shouldn’t have to work for their tools.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6702d2990bd3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/how-to-ensure-a-data-scientist-is-never-productive-6702d2990bd3">How to ensure a data scientist is never productive</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The State of the Serverless Art]]></title>
            <link>https://medium.com/riselab/the-state-of-the-serverless-art-78a4f02951eb?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/78a4f02951eb</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[serverless-computing]]></category>
            <dc:creator><![CDATA[Joe Hellerstein]]></dc:creator>
            <pubDate>Mon, 24 Aug 2020 19:54:55 GMT</pubDate>
            <atom:updated>2020-08-24T19:54:55.928Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="A photo of the cloud from https://www.flickr.com/photos/kky/704056791" src="https://cdn-images-1.medium.com/max/1024/1*d82Z-lDS-cAaIA2SQSECLg.jpeg" /><figcaption><em>Serverless computing is beginning to deliver on the vision of allowing developers to program the cloud.</em></figcaption></figure><p>Over the past 2 years, the <a href="http://hydro-project.github.io">Hydro</a> team I lead at Berkeley’s <a href="http://rise.cs.berkeley.edu">RISELab</a> has been running hard and fast in the area of serverless computing. We designed and built a stateful Functions-as-a-Service platform called <a href="https://github.com/hydro-project/cloudburst">Cloudburst</a>. I like to say “Cloudburst puts the state into the state-of-the-art” in serverless computing.</p><p>In addition to the software prototype, papers on Cloudburst and serverless computing have been rolling out at quite a clip:</p><ul><li>Cloudburst system architecture in <a href="https://arxiv.org/abs/2001.04592">VLDB 2020</a>. (<a href="#0343">overview below</a>)</li><li>Transactional causally-consistent caching in <a href="https://dl.acm.org/doi/pdf/10.1145/3318464.3389710">SIGMOD 2020</a>. (<a href="#0efd">overview below</a>)</li><li>Atomic Fault Tolerance (AFT) in <a href="https://arxiv.org/pdf/2003.06007">Eurosys 2020</a>. (<a href="#4dff">overview below</a>)</li><li>Optimized Serverless ML Prediction Serving using CloudFlow over Cloudburst at <a href="https://arxiv.org/abs/2007.05832">arXiv</a>. (<a href="#3314">overview below</a>)</li><li>A critique of the (prior) state of the art serverless systems in CIDR 2019. (<a href="#1f5e">overview below</a>)</li><li>All this on top of the two award-winning papers on the Anna serverless KVS at <a href="https://dsf.berkeley.edu/jmh/papers/anna_ieee18.pdf">ICDE18</a> and <a href="https://dsf.berkeley.edu/jmh/papers/anna_vldb_19.pdf">VLDB19</a>. (<a href="#b632">overview below</a>)</li></ul><p>In this post I go into the background of the serverless computing space, and how we got to where we are today. For better or worse, this is a long post. If you want to skip the background, you can <a href="#b632">jump straight to descriptions of the new results</a>.</p><h3>Programming for The Biggest Computer Ever Built</h3><p>I got interested in serverless computing because of my ongoing obsession with techniques for <em>programming the cloud</em>. Why obsess about that, you might ask?</p><p>To put a fine point on it, <em>the public cloud is the most powerful general-purpose computer ever assembled</em>. Forget the race for the “biggest supercomputer”, secreted away in a government lab. The cloud is orders of magnitude bigger, and growing every day. Even better, it’s not locked up in a lab — anyone can rent out its power at any scale, on demand. Everyone in computer science should be excited about this, as it’s arguably the biggest game-changer in computing access since the rise of the PDP-11 and UNIX in the early 1970s.</p><p>Unfortunately, raw computing power does not translate directly to useful computation. The cloud is not just massive, it is also a data-rich distributed system, which raises notoriously difficult computer science problems, including parallel programming, mid-flight failures of participating nodes, and data inconsistencies across distributed machines. For general-purpose cloud programming, developers today are forced to (a) write sequential programs to run on each machine they want to use, (b) ensure that code works together in concert to achieve desired outcomes in the face of the core CS problems described above, and (c) figure out how to deploy and manage all that complexity. As a result, it is very difficult today for developers to harness the power of the cloud at scale. To continue the analogy, the cloud is like the PDP-11 <em>without</em> UNIX and C — we’re programming it with the distributed systems equivalent of assembly code (though honestly it’s far harder than that from a correctness perspective).</p><h3>Background: Where Did a Decade Go?</h3><p>One of the reasons we’re moving so fast in my Hydro team recently is because my students and I have been beavering away in this space for over a decade at Berkeley. Ten years ago this fall, at <a href="http://www09.sigmod.org/sigmod/record/issues/1003/p05.article.hellerstein.pdf">ACM PODS 2010</a>, I issued a call to arms in a keynote talk:</p><blockquote>It is now within the budget of individual developers to rent massive resources in the worlds’ largest computing centers. But … this computing potential will go untapped unless those developers can write programs that harness parallelism, while managing the heterogeneity and component failures endemic to very large clusters of distributed computers.</blockquote><p>Given that imperative, I assembled <a href="http://boom.cs.berkeley.edu">the BOOM project team</a> back in 2010 to explore and demonstrate new ways to write programs. We started designing programming languages like <a href="https://www2.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-173.html">Dedalus</a> and <a href="http://bloom-lang.net">Bloom</a> that use the data in the cloud to drive computation, rather than worrying about which computer is doing what and when. Our early message was not lost on the tech press, which <a href="https://www.technologyreview.com/2009/12/16/207596/less-clumsy-code-for-the-cloud/">covered the ideas</a> and <a href="http://www2.technologyreview.com/news/418545/tr10-cloud-programming/">flagged the promise</a> of our work <a href="https://archive.fortune.com/galleries/2010/technology/1007/gallery.smartest_people_tech.fortune/27.html">quite a bit</a>.</p><p>But the agenda of general-purpose cloud programming got surprisingly little uptake in the ensuing decade, either in practice or research.</p><p>In retrospect, the likely distraction was easier money. Amazon Web Services spent the better part of the ‘teens demonstrating that well-capitalized firms could disrupt the enterprise software market <em>without</em> third-party developers or radical new software. Forget cultivating an iPhone-style “app for that” developer community! It was easier to go after aging giants like Oracle and IBM, and offer traditional software to traditional use cases, exploiting the radical new platform solely to lower administrative overheads.</p><p>And so a decade went by, and we wrote a bunch of papers, built some prototypes, and graduated some new PhDs. We felt pretty excited about the work, and we got plenty of academic recognition. But as the old joke goes, “if you’re so smart, why ain’t you rich”? I have to admit that Jeff Bezos made more money on AWS in the last decade than I did at Berkeley doing research. So to be clear, I’m not arguing that the <a href="https://www.statista.com/statistics/250520/forecast-of-amazon-web-services-revenue/">hundreds of billions of dollars</a> of “boring” cloud revenue was a bad play for businesses.</p><p>Nonetheless, the deeper technical revolution in cloud programming still awaits. Now that the cloud market has real competition, and the on-premises software market is back on its heels, we’re entering a new era where enabling the new stuff is going to matter.</p><h3>Commercial Serverless: FaaS</h3><p>As part of that new era, the cloud vendors have finally made some moves to empower developers outside their walls. The moniker they’ve chosen? <em>Serverless computing. </em>It’s not my favorite term, but it will have to do for now.</p><p>In its first incarnation, the idea of serverless computing has been embodied with an API called <em>Functions as a Service</em> (<em>FaaS</em>). As expected, Amazon was first with their AWS Lambda offering, but Microsoft Azure Functions and Google Cloud Functions followed quickly. The idea is simple: a developer writes a function in their favorite traditional programming language. They then upload the function to the cloud, and are given APIs to invoke the function remotely at will. Whenever data arrives at the function input, computation spins up in the cloud, and the result is passed to the output. The developer spends zero time configuring servers. The cloud resources auto-scale up and down dynamically according to usage, and the developer pays as they go, according to that usage.</p><p>To be clear, FaaS is only a first step in cloud programming. It is targeted at launching single-threaded sequential code in traditional languages, i.e. the “assembly language of distributed programming” I mention above. Still, while programming may be rudimentary, at least I don’t need to be a cloud devops wizard as well! And I only pay for what I use. That is, without question, progress.</p><p>In late 2018, a bunch of us in the <a href="http://rise.cs.berkeley.edu">RISELab</a> at Berkeley started looking at serverless computing. The systems folks in the lab began a writing-by-committee effort to describe the movement of this bandwagon in one of their “<a href="https://rise.cs.berkeley.edu/blog/a-berkeley-view-on-serverless-computing/">Berkeley View</a>” assessment papers. Having already spent a decade thinking about the future of cloud programming, I had stronger opinions. As a counterpoint to the committee effort, my team laid out our frank assessment of the basic pros and cons of first-generation FaaS in a paper entitled <a href="http://cidrdb.org/cidr2019/papers/p119-hellerstein-cidr19.pdf">Serverless Computing: One Step Forward, Two Steps Back</a>. In a nutshell:</p><ul><li><strong>Forward: Autoscaling.</strong> Third-party software is automatically scaled up and down according to usage patterns, in a pay-as-you go manner.</li><li><strong>Back: Slow Data Access.</strong> Serverless functions see embarrassingly high-latency and costly access to stored data.</li><li><strong>Back: No Distributed Computing.</strong> Functions are not allowed to communicate with one another except through high-latency storage, making most distributed computing techniques impossible.</li></ul><p>Some folks, especially <a href="https://news.ycombinator.com/item?id=18689544">at the orange website</a>, cast the article as a hit job from clueless academics. But the <a href="https://blog.acolyer.org/">Morning Paper</a>, which has followed our work <a href="https://blog.acolyer.org/2014/11/13/the-declarative-imperative-experiences-and-conjectures-in-distributed-logic/">since the beginning</a>, <a href="https://blog.acolyer.org/2019/01/14/serverless-computing-one-step-forward-two-steps-back/">got the spirit of it</a>:</p><blockquote>[this is ] an appeal from the heart to not stop where we are today, but to continue to pursue infrastructure and programming models truly designed for cloud platforms</blockquote><p>Also I like to think we’re not totally clueless (nor totally academic). While writing that paper we were already moving forward, getting past the challenges that the first-gen serverless offerings had dodged. In the papers and prototypes we’ve released since then, we are demonstrating what’s possible.</p><h3>Stateful Serverless Infrastructure 1: Storage</h3><p>In the early days of the RISElab, we wanted to demonstrate that the lessons of the BOOM project — notably avoiding coordination in the style of the <a href="https://arxiv.org/abs/1901.01930">CALM</a> Theorem — could be realized in a high-performance system. So Chenggang Wu set out to build a key-value storage (KVS) database called <a href="https://github.com/hydro-project/anna">Anna</a> that embraced and extended those lessons.</p><p>The first goal of Anna—and the name of the <a href="https://dsf.berkeley.edu/jmh/papers/anna_ieee18.pdf">original paper</a>—was to perform well <em>at any scale</em>. What did we mean by that? Well, <a href="https://research.google.com/people/jeff/WSDM09-keynote.pdf">conventional wisdom</a> said that systems have to be rearchitected every time they expand 10x beyond plan. Anna was designed to demonstrate that the lessons of coordination-freeness could result in a system that offered world-beating performance at the small scale on a single multicore box, <em>and </em>at massive scale on machines distributed across the globe.</p><p>The Anna story is richer than just the any-scale story. Anna is the subject of two earlier posts of mine (<a href="https://databeta.wordpress.com/2018/03/09/anna-kvs/">here</a> and <a href="https://databeta.wordpress.com/2018/09/07/significant-update-to-anna/">here</a>) and two award-winning research papers (<a href="https://dsf.berkeley.edu/jmh/papers/anna_ieee18.pdf">ICDE18</a> and <a href="https://dsf.berkeley.edu/jmh/papers/anna_vldb_19.pdf">VLDB19</a>), and given the length of this post I’ll be brief here, focusing on technical headlines:</p><ul><li><strong>Anna is crazy fast.</strong> In simple workloads Anna is as fast as anything around at any scale. Under contention, Anna is <em>orders of magnitude</em> faster than the fastest KVSes out there, including Redis, Masstree, and Intel’s TBB hashtable. This is because Anna never coordinates (no locks, no atomics, no consensus protocols!), whereas those systems spend 90+% of their time coordinating under contention.</li><li><strong>Anna offers flexible autoscaling.</strong> This is the hallmark of a good serverless infrastructure: scales up when you use it hard, scales down to save money and power when you don’t. Again, coordination-freeness is key: there’s no need to maintain distributed membership information, so the cost to add or remove nodes remains low at every scale.</li><li><strong>Anna provides rich data consistency.</strong> Even under parallel and distributed execution, Anna can offer various consistency guarantees to allow programmers to reason about data across machines, including powerful classical notions including causal consistency or repeatable read transactional isolation.</li><li><strong>Anna provides unified caching/tiering.</strong> Many KVS systems today are designed for one level of storage: either disks, or RAM. In contrast, you can deploy Anna as a caching tier in memory, as a database on disk, or as a multitiered system with a smaller cache on top of a larger database. Anna moves data up and down the tiers, and provides uniform consistency guarantees across both.</li></ul><p>There is no storage offering from any cloud vendor today that compares with what Chenggang has done with Anna. I believe Anna identifies and can fill a significant hole in the current cloud architectures.</p><h3>Stateful Serverless Infrastructure 2: Stateful Compute</h3><p>As Anna was maturing, we were ready to move up the stack and contemplate programming. As our first phase, we decided to try and build a FaaS system that tackles the “two steps backward” that plague the commercial FaaS services. This means two things:</p><ol><li><strong>Allow cloud functions to communicate with each other over the network. </strong>Commercial FaaS systems prevent 2 functions from communicating directly; they have to share any information via some slow distributed storage system. This is true even for simple stuff like passing the results of <em>g(x) </em>to another function <em>f </em>so you can compute <em>f(g(x)). </em>Beyond the basics, fast point-to-point communication is absolutely essential if you hope to do any non-trivial distributed computing other than batch jobs. The potential problem here is that serverless functions come and go pretty often, so their IP addresses aren’t reliable endpoints. This is solved with a classic level of indirection: a lookup service, implemented as some kind of lightweight distributed database. DNS is arguably too heavyweight to deploy for this setting, which is perhaps why the cloud vendors refuse to support networking for FaaS. Fortunately we have Anna—a lightweight autoscaling database. So functions can look each other up by “name” in Anna, and get a current IP address for that name. In a direct sense, Anna serves both as a database and as a Distributed Hash Table overlay network, a <a href="http://p2.cs.berkeley.edu/">duality we explored years ago</a>.</li><li><strong>Provide cloud functions with low-latency data access (LDPC).</strong> All the interesting challenges in distributed computing begin with data, or as some people like to say, the <em>state </em>of a program. Commercial FaaS vendors are targeted at <em>stateless</em> programs that simply map inputs to outputs with no “side effects” like data updates. But most applications of note these days manage data (state), often in complex ways. Adding to the complexity here is the trend towards <a href="https://en.wikipedia.org/wiki/Disaggregated_Storage">disaggregation of storage from compute</a>.<em> </em>In a big cloud environment, you don’t know when and how you need to scale out or upgrade your storage tier or your compute tier, so it’s best to keep them separate. The challenge is that storage services like DynamoDB or ElastiCache become very “far away” in latency terms. To get good latency, we still want <em>some</em> physical colocation of storage near our functions, even if the two tiers are managed and scaled separately. This is what we call <a href="https://arxiv.org/abs/2001.04592"><em>Logical Disaggregation with Physical Colocation (LDPC)</em></a><em>. </em>On this front we needed to innovate, and colocate a data cache on the same machines as the cloud functions, while still providing consistency in concert with Anna.</li></ol><p>This is where a lot of our energy has been spent in the last year. I’ve learned a lot along the way — while the programming problem remains, the system infrastructure space was interesting in its own right, and I think we got a good handle on the big issues. Here is a rundown of the recent results:</p><ul><li><strong>Cloudburst System Architecture: </strong>The big ideas, overall architecture and some of the details are spelled out in our <a href="https://arxiv.org/abs/2001.04592">VLDB 20 paper on Cloudburst</a>. We argue for the LDPC principle and describe the resulting architecture. Then the paper goes into detail on how we automatically encapsulate a developer’s mutable Python state in coordination-avoiding, <a href="https://dsf.berkeley.edu/papers/socc12-blooml.pdf">composable lattice structures</a> so arbitrary Python objects can be integrated into the coordination-free consistency model of Anna. We also describe how we achieve a simple version of causal consistency through these caches. Microbenchmarks show that we can outperform commercial serverless platforms by 1–2 orders of magnitude, and compete with hand-managed serverful distributed frameworks like Dask. We also show end-to-end numbers for two applications: ML prediction serving, and the Retwis twitter clone. Although we did nothing special to tune for ML prediction serving, we outperform AWS Sagemaker, a system specially designed for the task. (We also outperform AWS Lambda by quite a bit more.)</li><li><strong>Hydrocache and TCC: </strong>The <a href="https://dl.acm.org/doi/10.1145/3318464.3389710">Hydrocache paper in SIGMOD 2020</a> delves deeper into the ways we keep caches and the database consistent, while still providing low latency. We set the consistency bar even higher in this paper, with the goal of offering transactional causal consistency (TCC). You do not get this level of consistency from the typical distributed caches or KVS systems (looking at you, Redis Cluster!) Yet we show it can be done with very low latency. There’s no question that this paper is quite technical, though. Enjoy :-)</li><li><strong>Atomic Fault Tolerance (AFT)</strong>: The question of fault tolerance should be on your mind when reading about any distributed system. The FaaS vendors are quite naive about it right now — they tell developers that any function may fail and have to be retried, so it’s up to the developer to ensure that their code is <em>idempotent</em>, meaning it has the same effect whether run once or more than once. That’s not very nice, nor is it very likely to be guaranteed. <em>(OK pop quiz time. Stop what you’re doing. Did you write any code this week? Cool. Is it idempotent? How do you know? Is it reasonable to expect you to worry about that? I thought not!) </em><strong><em>But it gets worse.</em></strong><em> </em>If your function modifies stored state (say by issuing a call to a database), and it fails a fraction of the way through execution, it will have visibly run a <em>fractional</em> number of times. That is, the partial execution of your function is now exposed in storage and may be read by other code. This paper points out that what’s needed for FaaS fault tolerance is <em>Atomicity,</em> i.e. the “A” from the ACID guarantees. All your function’s external effects should occur, or none should. Idempotence then becomes easy — just include a unique ID for the request, and regardless of how messy it is, we can run it 0 or at most 1 times. That’s how idempotence is <em>supposed</em> to be exposed. This paper leans on our prior work on <a href="https://dl.acm.org/doi/10.1145/2909870">Read Atomic isolation</a>, and provides a surprisingly simple implementation as a “shim” layer that works in <em>any FaaS architecture.</em><strong><em> </em></strong>We have it running in the Cloudburst/Anna stack, but the paper shows how to deploy it in the AWS Lambda/S3 stack.</li><li><strong>Model Serving. </strong>Our first foray into model serving in the VLDB 20 Cloudburst architecture paper whet our appetite to do better. A few years back, when my co-conspirator <a href="https://people.eecs.berkeley.edu/~jegonzal/">Joey Gonzalez</a> was leading the <a href="http://clipper.ai/">Clipper</a> model serving project, I needled him by saying “hey I think all these optimizations you’re exploring — cascades and ensembles and whatnot — could be written as simple <a href="http://bloom-lang.net">Bloom</a> programs”. And I proceeded to sketch them as dataflows on a whiteboard. Well, with the Cloudburst infrastructure under his belt, Vikram Sreekanti took up that idea and made it real. He implemented a simple dataflow language called Cloudflow, and deployed it over Cloudburst. Then he proceeded to explore optimization opportunities exposed by the combination of explicit dataflow and stateful serverless computing, including things like (a) placing code on the right HW resources (i.e. GPUs) or colocated with the right data (i.e. in a Hydrocache), (b) autoscaling different stages of an ML pipeline differently, (c) fusing operators so they run colocated with each other, and (d) running competing versions of operators in parallel to let the fastest execution win. What’s really nice here is that the ML code remains a black box, so this is compatible with your favorite ML libraries (<a href="http://www.tensorflow.org">Tensorflow</a>, <a href="http://pytorch.org">PyTorch</a>, <a href="http://mxnet.apache.org">MXNet</a>, <a href="http://scikit-learn.org">Scikit-Learn</a>, etc.) Joey and I feel like Vikram really made the case that this is the right way to architect a model serving system.</li></ul><p>In sum, Cloudburst is our answer to the critiques of FaaS we raised 2 years ago. Cloudburst shows that FaaS can provide 3 steps forward, and provide an underpinning for general-purpose cloud programming. Most programming tasks that can benefit from <em>the world’s biggest computer </em>absolutely<em> </em>require efficient and consistent management of program state, and that’s where much of the hard computer science lies in this space.</p><h3>Summing Up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d82Z-lDS-cAaIA2SQSECLg.jpeg" /></figure><p>Obviously all this work was done by a team. The lion’s share was done by the lead PhD students, <a href="http://twitter.com/vsreekanti">Vikram Sreekanti</a> and <a href="http://twitter.com/cgwu0530">Chenggang Wu</a>, who are truly a dynamic duo. <a href="http://twitter.com/mejoeyg">Joey Gonzalez</a> was my co-conspirator as faculty advisor. Other contributors include <a href="http://twitter.com/sauravchh">Saurav Chhatrapati</a>, <a href="https://charlesl.in/">Charles Lin</a>, Yihan Lin, and <a href="http://twitter.com/hsubbaraj">Hari Subbaraj</a>, with wise input from <a href="http://twitter.com/jmfaleiro">Jose Faleiro</a>, <a href="http://twitter.com/jssmith">Johann Schleier-Smith</a>, and <a href="http://twitter.com/alsched">Alexey Tumanov</a>.</p><p>Our ability to slay some dragons in this space in recent years is also thanks to a long line of research from an even bigger group of collaborators from <a href="http://boom.cs.berkeley.edu">BOOM</a> and <a href="http://p2.cs.berkeley.edu">P2</a> days. There’s more to come from our end, and I expect to see more good stuff from the community at large. Programming the cloud is one of the biggest challenges and opportunities in computer science, and we’ll continue pushing forward.</p><p><em>In addition to NSF CISE Expeditions Award CCF-1730628, this research is supported by gifts from Alibaba, Amazon Web Services, Ant Financial, CapitalOne, Ericsson, Facebook, Futurewei, Google, Intel, Microsoft, Nvidia, Scotiabank, Splunk and VMware.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a4f02951eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/the-state-of-the-serverless-art-78a4f02951eb">The State of the Serverless Art</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Estimating the fatality rate is difficult but doable with better data]]></title>
            <link>https://medium.com/riselab/estimating-the-fatality-rate-is-difficult-but-doable-with-better-data-18401865f13?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/18401865f13</guid>
            <category><![CDATA[sars-cov2]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[coronavirus]]></category>
            <category><![CDATA[covid19]]></category>
            <dc:creator><![CDATA[Anastasios Angelopoulos]]></dc:creator>
            <pubDate>Tue, 28 Jul 2020 16:33:52 GMT</pubDate>
            <atom:updated>2020-07-28T16:33:51.957Z</atom:updated>
            <content:encoded><![CDATA[<p>A. N. Angelopoulos, R. Pathak, R. Varma, M. I. Jordan. <strong>On Identifying and Mitigating Bias in the Estimation of the COVID-19 Case Fatality Rate</strong>. Harvard Data Science Review Special Issue 1 — COVID-19: Unprecedented Challenges and Chances. 2020.</p><h3>Summary</h3><p>The case fatality rate quantifies how dangerous COVID-19 is, and how risk of death varies with strata like geography, age, and race. Current estimates of the COVID-19 case fatality rate (CFR) are biased for dozens of reasons, from under-testing of asymptomatic cases to government misreporting. We provide a careful and comprehensive overview of these biases and show how statistical thinking and modeling can combat such problems. Most importantly, data quality is key to unbiased CFR estimation. We show that a relatively small dataset collected via careful contact tracing would enable simple and potentially more accurate CFR estimation.</p><h3>§1 What is the case fatality rate, and why do we need to estimate it?</h3><p>The case fatality rate (CFR) is the proportion of fatal COVID-19 cases. The term is ambiguous, since its value depends on the definition of a ‘case.’ No perfect definition of the case fatality rate exists, but in this article, I define it as the proportion of deaths among all COVID-19-infected individuals.</p><p>The CFR is a measure of disease severity. Furthermore, the relative CFR (the ratio of CFRs between two subpopulations) is a useful target for data-informed resource-allocation protocols because it measures relative risk. In other words, the CFR tells us how drastic our response needs to be; the relative CFR helps us allocate scarce resources to populations that have a higher risk of death.</p><p>Although the CFR is defined as the number of fatal infections, we can not expect that dividing the number of deaths by the number of cases will give us a good estimate of the CFR. The problem is that both the numerator (#deaths) and the denominator (#infections) of this fraction are uncertain for systematic reasons due to the way data is collected. For this reason, we call that estimator “<strong>the naive estimator”, or simply deaths/cases</strong>.</p><h3>§2 Why are (all) CFR estimators biased?</h3><figure><img alt="A directed acyclic graphical model illustrating dozens of biases incurred when collecting COVID-19 surveillance data." src="https://cdn-images-1.medium.com/max/1024/1*VMG_CobUPA6xCumaXSqcdA.png" /><figcaption><strong>Fig. 1 </strong>Dozens of biases (§2) can corrupt the estimation of the CFR. Surveillance data gives partial information within the ‘sampling frame’ (light blue rectangle). Edges on the graph correspond roughly to conditional probabilities; e.g., the edge from D to DF is the probability a person dies if they are diagnosed with COVID-19.</figcaption></figure><p>In short, because the data is biased, <a href="https://hdsr.mitpress.mit.edu/pub/l7a2t45s/release/1">we are losing at least 99.8% of our sample efficiency</a>. There’s a well known ‘’butterfly effect’’ in statistics: a tiny correlation between your sampling method and the quantity you’re seeking can have huge, destructive effects on your estimator. Even assuming a tiny 0.005 correlation between the population we test and the population infected, testing 10,000 people for SARS-CoV-2 is equivalent to testing 20 individuals randomly. For estimating the fatality rate, the situation is even worse, since we have many reasons to believe that severe cases are preferentially diagnosed and reported. In the words of Xiao-Li Meng, <a href="https://statistics.fas.harvard.edu/files/statistics-2/files/statistical_paradises_and_paradoxes.pdf">‘’compensating for [data] quality with quantity is a doomed game.’’</a> In our HDSR article, we show that in order for the naive estimator to converge to the correct CFR, there must be no correlation between fatality and being tested — but severe cases are much more likely to be tested. Government and health organizations have been explicitly reserving tests for severe cases due to shortages, and severe cases are likely to go to the hospital and get tested, while asymptomatic ones are not.</p><p>The primary source of COVID-19 data is population surveillance: county-level aggregate statistics reported by medical providers who diagnose patients on-site. Usually, somebody feels sick and goes to a hospital, where they get tested and diagnosed. The hospital reports the number of cases, deaths, and sometimes recoveries to local authorities, who release the data usually on a weekly basis. Of course, this is an idealized model, and in reality, there are many differences in data collection between nations, local governments, and even hospitals.</p><p>Dozens of biases are induced by this method of surveillance, falling into roughly five categories: under-ascertainment of mild cases, time lags, interventions, group characteristics (e.g. age, sex, race), and imperfect reporting and attribution. An extensive (but not exhaustive) discussion of the magnitude and direction of these biases is in our article. Without mincing words, this data is extremely low quality. The vast majority of people who get COVID-19 go undiagnosed, there are misattributions of symptoms and deaths, data reported by governments is often (and perhaps purposefully) incorrect, cases are defined inconsistently across countries, and there are many time-lags (for example, cases are counted as ‘diagnosed’ before they are ‘fatal’, leading to a downward bias in the CFR if the number of cases is growing over time). <strong>Figure 1</strong> has a graphical model describing these many relationships; look to the paper for a very detailed explanation of what biases occur across each edge.</p><p>Correcting for biases is sometimes possible using outside data sources, but can result in a worse estimator overall due to partial bias cancellation. This is easier to see through example than it is to explain. Assume the true CFR is some value p in the range 0 to 1 (i.e., deaths/infections is equal to <em>p</em>). Then, assume that because of under-ascertainment of mild cases, there are too many fatal cases being reported, which means deaths/cases converges to <em>bp&gt;p</em> (in other words, it is higher than it should be by a factor of <em>b</em>). But at the same time, assume that because of the time-lag between diagnosis and death causes the proportion of deaths to diagnoses to be too low by the same factor, <em>b</em>. Then, deaths/cases converges to <em>b(p/b)=p</em>, the correct value. So, even though it might seem to be an objectively good idea to correct for time-lag between diagnosis and death, it would actually result in a worse estimator in this case, since time-lag is helping us out by cancelling out under-ascertainment.</p><p>The mathematical form of the naive estimator allows us to see easily what we need to do to make it unbiased. With <em>p</em> being the true CFR, <em>q</em> being the reporting rate, and <em>r</em> being the covariance between death and diagnosis, the mean of deaths/cases is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*VhcYde0FYl2CDXaJ.png" /></figure><p>This equation is pretty easy to understand. We wanted <em>μ</em> to be equal to <em>p</em>. Instead, we got an expression that depends on <em>r</em>, <em>q</em>, and <em>N</em>. The <em>r/q </em>term is the price we pay if people who are diagnosed are more likely to eventually die. We want<em> r/q</em>=0, but in practice,<em> r/q</em> is probably much larger than p. (Actually, if we assume the CFR is around 0.5% and the measured CFR is 5.2% on June 22, 2020, then <em>r/q</em>≥0.047&gt;&gt;0.005.) In other words,<em> r/q</em> is the bias, and it can be large. The term <em>p</em> is, of course, the true CFR, which we want. And the factor <em>(1−(1−q)N)</em> is what we pay because of non-response; however, it’s not a big deal, because it disappears quite fast as the number of samples <em>N</em> grows. So really, our primary concern should be is achieving <em>r=0</em>, because — and I cannot stress this enough — <strong><em>r/q </em>does not decrease with more samples; it only decreases with higher quality samples</strong>.</p><h3>§3 What are strategies for fixing the bias?</h3><p>In our article, we outline a testing procedure that helps fix some of the above dataset biases. If we collect data properly, we think even the naive estimator can be a good estimator of the CFR within a particular population. In particular, by following a procedure like the following:</p><ul><li><strong>1.</strong> Diagnose person <em>P</em> with COVID-19 by any means, like at a hospital.</li><li><strong>2.</strong> Reach out to contacts of <em>P</em>. If a contact has no symptoms, ask them to commit to getting a COVID-19 test.</li><li><strong>3.</strong> Test committed contacts after the virus has incubated.</li><li><strong>4.</strong> Keep data with maximum granularity while respecting ethics/law.</li><li><strong>5.</strong> Follow up after a few weeks to ascertain the severity of symptoms.</li><li><strong>6.</strong> For committed contacts who didn’t get tested, call and note if they are asymptomatic.</li></ul><p>This protocol is meant to decrease the covariance between fatality and diagnosis. If patients commit to testing before they develop symptoms, there cannot be a covariance between disease severity and diagnosis. However, there may still be issues with people dropping out of the study; if this is a problem in practice, it can be mitigated by a combination of incentives (payments) and post-stratification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NH4H3RJKSdJAji3-vXVhmQ.png" /><figcaption><strong>Fig. 2 </strong>Assuming data collection induces no correlation between disease severity and diagnosis, as the true CFR decreases, it requires more samples to estimate. The variable <em>p</em> is the true CFR, and <em>q</em> is the response rate. Each histogram represents the probability the naive estimator will take on a certain value, given <em>N</em> samples of data (different colors correspond to different values of <em>N</em>). The three stacked plots correspond to different values of <em>p</em>; the smaller <em>p</em> is, the harder it is to estimate, since death becomes an extremely rare event.</figcaption></figure><p><strong>Figure 2</strong> represents an idealized version of this study. In the best case scenario, there is no covariance between death and diagnosis. In that case, we only need <em>N</em>=66 samples for our estimator of the CFR to be approximately unbiased, even if <em>p</em>=0.001 (1/1000 cases die). Problems remain in the case that p is small; namely, death is so rare that we need tons of samples to decrease the variance of our estimator. This will require lots of samples. But even if no deaths are observed, that gives us lots of information about <em>p</em>; specifically, if <em>N</em>=1000 and we have not observed a single death, then we can confidently say that <em>p</em>&lt;0.01 within the population we are sampling. This is simply because in the second panel of <strong>Figure 2</strong>, there is nearly zero mass in the <em>N</em>=1000 histogram at deaths/cases=0. With this in mind, we could find the largest possible <em>p</em> that is consistent with our data — this would be a conservative upper bound on <em>p</em>, but it would be much closer to the true value than we can get with current data.</p><p>This strategy mostly resolves what we believe is the largest set of biases in CFR estimation — under-ascertainment of mild cases and time-lags. However, there will still be lots of room for improvement, like understanding the dependency of CFR on age, sex, and race. (In other words, the CFR is a random quantity itself, depending on the population being sampled.) Distinctions between CFRs of these strata may be quite small, requiring a lot of high-quality data to analyze. If <em>p</em> is extremely low, like 0.001, and we take a purely frequentist approach as in <strong>Figure 2</strong>, this may require collecting <em>N</em>=100,000 or <em>N</em>=1,000,000 samples <em>per group</em>. Perhaps there are ways to lower that number with Bayesian hierarchical modeling. Even though making correct inferences will require careful thought (as always), this data collection strategy will make it much simpler.</p><p>I’d like to re-emphasize a point here: collecting data as above will make the naive estimator unbiased <em>for the sampled population</em>. But the sampled population may not be the population we care about. However, there is a set of statistical techniques collectively called ‘post-stratification’ that can help deal with this problem effectively — though not perfectly.</p><p>If you read our academic article, we provide some thoughts on how to use time-series data and outside information to correct time-lags and relative reporting rates. Our work was very heavily based on one of <a href="https://www.umass.edu/sphhs/person/faculty/nicholas-g-reich">Nick Reich’s</a> papers. However, as I claimed earlier, even fancy estimators cannot overcome fundamental problems with data collection. I’ll defer discussion of that estimator, and the results we got from it, to the article. It’s best parsed by experts looking for a perspective on how to perform these estimations honestly. I’d love to hear your thoughts.</p><p>CFR estimation is clearly a difficult problem — but with proper data collection and estimation guided by data scientists, I still believe that we can get a useful CFR estimate. This will help guide public policy decisions about this urgent and ongoing pandemic.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FpY97BmGghTQ%3Fstart%3D188%26feature%3Doembed%26start%3D188&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DpY97BmGghTQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FpY97BmGghTQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/19da5b2dccb63cf1029d718e7036eb4b/href">https://medium.com/media/19da5b2dccb63cf1029d718e7036eb4b/href</a></iframe><p>A. N. A. was partially supported by the National Science Foundation Graduate Research Fellowship Program. R. P. was partially supported by a UC Berkeley University Fellowship via the ARCS Foundation. A. N. A. and R. P. are <a href="https://rise.cs.berkeley.edu/people/">RISELab</a>/<a href="https://bair.berkeley.edu/">BAIR</a> members and M. I. J. is a core faculty member in both groups.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18401865f13" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/estimating-the-fatality-rate-is-difficult-but-doable-with-better-data-18401865f13">Estimating the fatality rate is difficult but doable with better data</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure Collaborative XGBoost on Encrypted Data]]></title>
            <link>https://medium.com/riselab/secure-collaborative-xgboost-on-encrypted-data-1c7275086259?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c7275086259</guid>
            <category><![CDATA[secure-enclave]]></category>
            <category><![CDATA[federated-learning]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Rishabh Poddar]]></dc:creator>
            <pubDate>Thu, 16 Jul 2020 20:01:33 GMT</pubDate>
            <atom:updated>2020-07-16T20:01:32.939Z</atom:updated>
            <content:encoded><![CDATA[<h4>A library for multi-party training and inference of XGBoost models using secure enclaves</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YDVMWHTJA06-axuqtl-F0g.png" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Markus Spiske</a> on <a href="https://towardsdatascience.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a> (modified).</figcaption></figure><p>We recently released <a href="https://github.com/mc2-project/secure-xgboost"><strong>Secure XGBoost</strong></a>, a library that enables<strong> collaborative XGBoost training and inference on encrypted data</strong>. Secure XGBoost is part of the umbrella <a href="https://github.com/mc2-project/mc2"><strong>MC² project</strong></a>, under which we are working on a variety of tools for privacy-preserving machine learning.</p><p>In particular, Secure XGBoost facilitates <strong>secure collaborative learning</strong> — where mutually distrustful data owners can jointly train a model on their data, but without revealing their data to each other. Secure collaborative learning is a powerful paradigm that could be the key to unlocking more resilient and robust models.</p><p>We’ve been partnering with some teams in industry, including Scotiabank and Ant Financial, to deploy Secure XGBoost for efforts towards anti-money laundering and fraud detection.</p><p><strong>For more information, please read our detailed writeup on Secure XGBoost </strong><a href="https://towardsdatascience.com/secure-collaborative-xgboost-on-encrypted-data-ac7bc0ec7741"><strong>here</strong></a><strong>.</strong> The source code for all MC² projects<strong> </strong>is available on <a href="https://github.com/mc2-project/secure-xgboost">Github</a>.</p><h4>Acknowledgments</h4><p><em>This work was supported in part by the NSF CISE Expeditions Award CCF-1730628, and gifts from the Sloan Foundation, Bakar Program, Alibaba, Amazon Web Services, Ant Financial, Capital One, Ericsson, Facebook, Futurewei, Google, Intel, Microsoft, Nvidia, Scotiabank, Splunk, and VMware.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c7275086259" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/secure-collaborative-xgboost-on-encrypted-data-1c7275086259">Secure Collaborative XGBoost on Encrypted Data</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Context-Aware Fast Food Recommendation at Burger King with RayOnSpark]]></title>
            <link>https://medium.com/riselab/context-aware-fast-food-recommendation-at-burger-king-with-rayonspark-2e7a6009dd2d?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/2e7a6009dd2d</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[rays]]></category>
            <category><![CDATA[spark]]></category>
            <dc:creator><![CDATA[Jason Dai]]></dc:creator>
            <pubDate>Wed, 08 Jul 2020 15:36:56 GMT</pubDate>
            <atom:updated>2020-07-20T02:03:44.901Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Authors</strong>: Luyang Wang (<a href="mailto:lwang1@rbi.com">lwang1@rbi.com</a>), Kai Huang (kai.huang@intel.com), Jiao Wang (jiao.wang@intel.com), Shengsheng Huang (shengsheng.huang@intel.com), Jason Dai (jason.dai@intel.com)</blockquote><p>Deep learning based recommendation models have been widely used in real world recommendation systems. Common methods perform concatenation of user and item embedding vectors, then feed them into MLP (multilayer perceptron) to generate final predictions. However, these methods fail to capture real-time user behavior signals and do not take the important context features (such as time and location) into consideration; as a result, the final recommendations are not ideal to reflect the real-time user preferences. User behavior sequences and context features become even more important for fast food recommendation because:</p><ol><li>Users are not likely to purchase another soft drink when they already have soft drinks added in the cart.</li><li>User purchase preference can drastically change given location, time, and current weather conditions. For example, people almost never buy kids meals at midnight and are very unlikely to buy frozen drinks on a cold rainy day.</li></ol><p>In this blog post, we present our Transformer Cross Transformer (TxT) model that exploits the sequence of each order as well as the context information to infer a user’s preference at the moment. The key advantage of our model is that we apply <a href="https://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf">Transformer encoders</a> to capture both user order behavior sequence and complicated context features and combine both transformers through latent cross to generate recommendations.</p><p>In addition, we have leveraged <a href="https://medium.com/riselab/rayonspark-running-emerging-ai-applications-on-big-data-clusters-with-ray-and-analytics-zoo-923e0136ed6a?source=friends_link&amp;sk=5af060f6dae6a5ec7036014b7786373e">RayOnSpark</a> in <a href="https://github.com/intel-analytics/analytics-zoo">Analytics Zoo</a> to build an end-to-end recommendation system using <a href="https://github.com/ray-project/ray">Ray</a>*, <a href="http://spark.apache.org/">Apache Spark</a>* and <a href="https://mxnet.apache.org/">Apache MXNet</a>*. It integrates data processing (with Spark) and distributed training (with MXNet and Ray) into a unified analysis and AI pipeline, which runs on the same cluster where our big data is stored and processed. We have successfully deployed the recommendation system at Burger King, and our solution achieves superior results in the production environment.</p><h3><strong>T<em>x</em>T Model for Recommendation</strong></h3><p>We propose the <em>Transformer Cross Transformer</em> model (T<em>x</em>T), which uses a <em>Sequence Transformer</em> to encode guest order behavior, a<em> Context Transformer</em> to encode context features (such as weather, time and location), and then uses an element-wise product to combine them (the “cross” part) to produce the final output, as shown in <strong>Figure 1</strong>. We implement our model code leveraging MXNet API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*il1tsPgohkWYkinn.png" /><figcaption>Figure 1: T<em>x</em>T Model architecture.</figcaption></figure><h4>Sequence Transformer</h4><p>We construct a <em>Sequence Transformer,</em> based on the <a href="https://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf">Transformer</a> architecture, to learn the sequence embedding vector of each item in the guest order basket, as shown in the lower left part of <strong>Figure 1</strong>. To ensure that the item position information can be considered in its original add-to-cart sequence, we perform positional embedding on input items in addition to the item feature embedding. The embedding outputs are then added together and fed into a multi-head self-attention network.</p><p>To extract the vector representation of the whole guest order basket information from the hidden vectors of each item, we concatenate mean pooling and max pooling separately against final sequence transformer output. In this way, pooling output can consider all products contained in the product sequence while focusing on a small number of key products and their salient features.</p><p>Sequence Transformer can be constructed using the API in Analytics Zoo below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e869bbbbcffd1015a73d13af8f8467eb/href">https://medium.com/media/e869bbbbcffd1015a73d13af8f8467eb/href</a></iframe><h4>Context Transformer</h4><p>A common way to incorporate context features is to directly concatenate them with sequential inputs. But it is less meaningful to simply concatenate non-sequence features with sequence features. Some previous solutions use element-wise sum to deal with multiple context features. However, sum can only represent how context features aggregately contribute to the output, but most of the time these context features do not contribute equally to a user’s final decision.</p><p>Therefore, we use a <em>Context Transformer </em>to encode the contextual information, as shown in the bottom right part of <strong>Figure 1</strong>. Using Transformer’s multi-head self-attention, we can capture not only the individual effect of each context feature, but also the internal relationship and complicated interactions across different context features.</p><p>Context Transformer can be constructed using the API in Analytics Zoo below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5eadd327e1051d9a87ec084399a9adf9/href">https://medium.com/media/5eadd327e1051d9a87ec084399a9adf9/href</a></iframe><h4>Transformer Cross Transformer</h4><p>To jointly train <em>Sequence Transformer</em> and <em>Context Transformer</em>, we perform an element-wise product between these two transformer outputs. Through this cross Transformer training, we are able to optimize all the parameters such as item embeddings, context features embeddings and their interactions at the same time. Finally, we apply relu as the activation function followed by a softmax layer to predict the probabilities of each candidate item.</p><p>T<em>x</em>T, which consists of Sequence Transformer and Context Transformer, can directly be constructed using the API in Analytics Zoo below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf981f8c5ec002922a157c0ecc30cd6d/href">https://medium.com/media/cf981f8c5ec002922a157c0ecc30cd6d/href</a></iframe><h3>End-to-End System Architecture</h3><p>Conventional approaches to build a standard recommendations pipeline would set up two separate clusters, one for big data processing, and the other dedicated to deep learning (e.g., a GPU cluster). But this not only introduces a lot of data transfer overhead, but also requires additional efforts for managing separate workflows and systems in production. To address these challenges, we have built the recommendation system on top of <a href="https://medium.com/riselab/rayonspark-running-emerging-ai-applications-on-big-data-clusters-with-ray-and-analytics-zoo-923e0136ed6a">RayOnSpark</a> in <a href="https://github.com/intel-analytics/analytics-zoo">Analytics Zoo</a>, which integrates Spark data processing and distributed MXNet training (using Ray) into a unified pipeline that runs on a single Xeon cluster.</p><p><strong>Figure 2</strong> illustrates the overall architecture of our system. In the Spark program, a <em>SparkContext</em> object is created on the driver node and it is responsible for launching multiple Spark executors to run Spark tasks. RayOnSpark additionally creates a <em>RayContext</em> object on the Spark driver, which will automatically launch Ray processes alongside each Spark executor and create a <em>RayManager </em>inside each Spark executor to manage Ray processes<em> </em>(e.g., automatically shutting down the processes when the program exits).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/0*BAEWNC47EjS1IFFe.png" /><figcaption>Figure 2: Overview of the recommendation system based on RayOnSpark.</figcaption></figure><p>In our recommendation system, we first launch Spark tasks to extract our restaurant transactions data stored on distributed file systems, followed by data cleaning, ETL and preprocessing steps using Spark. After the Spark tasks complete, the processed in-memory Spark RDD are directly fed into the Ray cluster through Plasma for distributed training.</p><p>Inspired by the design of <a href="https://medium.com/distributed-computing-with-ray/faster-and-cheaper-pytorch-with-raysgd-a5a44d4fd220">RaySGD</a>, we have implemented an <em>MXNet Estimator</em> that provides a lightweight shim layer to automatically deploy distributed MXNet training on Ray. Both MXNet workers and parameter servers run as Ray actors, and they communicate with each other via the distributed key-value store provided by MXNet; each MXNet worker takes its local data partition in Plasma to train the model. As a result, the user can seamless scale the MXNet training code from a single node to production clusters through Ray, using a simple scikit-learn style API below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f79b51326fbafb46a71fa01d7c10571e/href">https://medium.com/media/f79b51326fbafb46a71fa01d7c10571e/href</a></iframe><p>Such a unified design architecture integrates Spark data processing and Ray-based distributed MXNet training into an end-to-end, in-memory pipeline, which runs on exactly the same cluster where our big data is stored. Consequently, we only need to maintain a single cluster for the entire AI pipeline, with no extra data transfer across different clusters and no extra cluster maintenance efforts. This achieves the full utilization of the cluster resources and significantly improves the end-to-end performance of the whole system.</p><h3>Model Evaluation</h3><p>We conducted offline experiments using the customer transaction records of Burger King in the past 12 months. The historical data of the first 11 months is used as training data and the last month is used for validation. The models are trained based on these data to predict the next best product for the guest to purchase. From <strong>Table 1</strong>, We can see superiority of T<em>x</em>T over baseline models (including <a href="https://en.wikipedia.org/wiki/Association_rule_learning">Association Rule Learning</a> and <a href="https://arxiv.org/pdf/1511.06939.pdf">GRU4Rec</a>). When comparing T<em>x</em>T and GRU4Rec, we can see that incorporating various context features greatly improves the Top1 and Top3 accuracy (by approximately 5.65% and 7.32% respectively).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*da0PuJZgVovDdM_G.png" /><figcaption>Table 1: Offline training results of different recommendation models.</figcaption></figure><p>To evaluate the effectiveness of our T<em>x</em>T model in the real-world production environment, we ran our recommendation system in Burger King’s mobile application side by side with <a href="https://cloud.google.com/recommendations">Google Recommendation AI</a>*, a state-of-art recommendation service provided by <a href="https://cloud.google.com/">Google Cloud Platform</a> (GCP)*. We evaluate online performance from two aspects: recommendation conversion rate and add-on sales. We ran A/B testing for 4 weeks. For the control group, we randomly select 20% users and present them with a previous rule-based recommendation system. As shown in <strong>Table 2</strong>, T<em>x</em>T improved recommendation conversion on the checkout page by 264% and add-on sales by 137% when compared to the control group. This also stands for +100% conversion gain and +73% add-on sales gain when compared to other test groups running GCP Recommendation AI service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/0*2dKVZpu_RqPSKX5B.png" /><figcaption>Table 2: Online results of different recommendation solutions.</figcaption></figure><h3>Conclusion</h3><p>This blog post describes how we build and productionize an end-to-end recommendation pipeline in Burger King. It successfully captures user order behaviors and complex context features through the <em>Transformer Cross Transformer</em> (T<em>x</em>T) model, and implements a unified data processing (with Spark) and DL training (with Ray) pipeline using <em>RayOnSpark</em>. Both the <a href="https://github.com/intel-analytics/analytics-zoo/blob/master/pyzoo/zoo/models/recommendation/txt.py">T<em>x</em>T model</a> and <a href="https://github.com/intel-analytics/analytics-zoo/tree/master/pyzoo/zoo/ray">RayOnSpark</a> have been open sourced in the <a href="https://github.com/intel-analytics/analytics-zoo">Analytics Zoo</a> project.</p><p><em>*Other names and brands may be claimed as the property of others</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e7a6009dd2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/context-aware-fast-food-recommendation-at-burger-king-with-rayonspark-2e7a6009dd2d">Context-Aware Fast Food Recommendation at Burger King with RayOnSpark</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Decision Trees Accurate Again: Explaining what Explainable AI did not]]></title>
            <link>https://medium.com/riselab/making-decision-trees-accurate-again-explaining-what-explainable-ai-did-not-abb73e285f22?source=rss----c78fd354636e---4</link>
            <guid isPermaLink="false">https://medium.com/p/abb73e285f22</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[interpretability]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[decision-tree]]></category>
            <category><![CDATA[explainability]]></category>
            <dc:creator><![CDATA[Alvin Wan]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 20:47:24 GMT</pubDate>
            <atom:updated>2020-04-20T03:04:23.229Z</atom:updated>
            <content:encoded><![CDATA[<h4>Combining neural networks and decision trees for accurate <em>and</em> interpretable computer vision models (and how our method works).</h4><p><em>This is an extended version with an expanded methods description of the Towards Data Science article </em><a href="https://towardsdatascience.com/what-explainable-ai-fails-to-explain-and-how-we-fix-that-1e35e37bee07"><em>“What Explainable AI fails to explain (and how we fix that)”</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rqvaFJVWE4P2AZrXC-T6hA.jpeg" /><figcaption>Designed by author⁰</figcaption></figure><p>The interpretability of neural networks is becoming increasingly necessary, as deep learning is being adopted in settings where accurate <em>and</em> justifiable predictions are required. These applications range from finance to medical imaging. However, deep neural networks are notorious for a lack of justification. Explainable AI (XAI) attempts to bridge this divide between accuracy and interpretability, but as we explain below, <em>XAI justifies decisions without interpreting the model directly</em>.</p><h3>What is “Interpretable”?</h3><p>Defining explainability or interpretability for computer vision is challenging: What does it even <em>mean</em> to explain a classification for high-dimensional inputs like images? As we discuss below, two popular definitions involve <em>saliency maps</em> and <em>decision trees</em>, but both approaches have their weaknesses.</p><h3>What Explainable AI Doesn’t Explain</h3><h4>Saliency Maps¹</h4><p>Many XAI methods produce saliency maps, but saliency maps focus on the input and neglect to explain <em>how</em> the model makes decisions. For more on saliency maps, see <a href="https://medium.com/datadriveninvestor/visualizing-neural-networks-using-saliency-maps-in-pytorch-289d8e244ab4">these</a> <a href="https://medium.com/@thelastalias/saliency-maps-for-deep-learning-part-1-vanilla-gradient-1d0665de3284">saliency</a> <a href="https://towardsdatascience.com/saliency-based-image-segmentation-473b4cb31774">tutorials</a> and <a href="https://github.com/utkuozbulak/pytorch-cnn-visualizations">Github</a> <a href="https://github.com/PAIR-code/saliency">repositories</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/0*fAxBtdp59kmAz37r.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/0*sm35AzggY3BHld3i.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/0*I5GDqbGn9jqSryta.png" /><figcaption>Picturing the original image (left), saliency map using a method called Grad-CAM (middle), and another using Guided Backpropagation (right). The picture above is the canonical example for “class-discrimination”. The above saliency maps are taken from <a href="https://github.com/kazuto1011/grad-cam-pytorch">https://github.com/kazuto1011/grad-cam-pytorch</a>.</figcaption></figure><h4>What Saliency Maps Fail to Explain</h4><p>To illustrate why <strong>saliency maps do not fully explain how the model predicts</strong>, here is an example: Below, the saliency maps are identical, but the predictions differ. Why? Even though both saliency maps highlight the correct object, one prediction is incorrect. How? Answering this could help us improve the model, but as shown below, saliency maps fail to explain the model’s decision process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/112/0*rxG-OAHGJ22DsSb3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/112/0*c1ouuj58lv05c9C0.png" /><figcaption>(Left) The model predicts Eared Grebe. (Right) The model predicts Horned Grebe. These are Grad-CAM results for a ResNet18 model trained on Caltech-UCSD Birds-200–2011, or CUB 2011 for short. Although the saliency maps look extremely similar, the model predictions differ. As a result, saliency maps do not explain how the model reached its final prediction.</figcaption></figure><h4>Decision Trees</h4><p>Another approach is to <strong>replace neural networks with interpretable models</strong>. Before deep learning, decision trees were the gold standard for accuracy and interpretability. Below, we illustrate the interpretability of decision trees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FK_VHnCfB2hFdnKG.jpg" /><figcaption>Instead of only predicting “Super Burger” or “Waffle fries”, the above decision tree will output a sequence of decisions that lead up to a final prediction. These intermediate decisions can then be verified or challenged separately. As a result, classic machine learning calls this model “interpretable”.</figcaption></figure><p>For accuracy, however, <strong>decision trees lag behind neural networks by up to 40% accuracy</strong> on image classification datasets². Neural-network-and-decision-tree hybrids also underperform, failing to match neural networks on even the dataset CIFAR10, which features tiny 32x32 images like the one below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/32/0*7uRJh5gXeSlB3xxh.png" /><figcaption>Example to show just how tiny 32x32 is. This is a sample from the CIFAR10 dataset.</figcaption></figure><p>As we show in our <a href="https://arxiv.org/abs/2004.00221">paper</a> (Sec 5.2), this accuracy gap damages interpretability: <em>high-accuracy, interpretable models are needed to explain high-accuracy neural networks.</em></p><h3>Enter Neural-Backed Decision Trees</h3><p>We challenge this false dichotomy by building models that are both interpretable and accurate. Our key insight is to combine neural networks with decision trees, preserving high-level interpretability while using neural networks for low-level decisions, as shown below. We call these models <a href="http://nbdt.alvinwan.com"><strong>Neural-Backed Decision Trees</strong></a> (NBDTs) and show they can <strong>match neural network accuracy while preserving the interpretability of a decision tree.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LptccZg1ozHGFcZ3.jpg" /><figcaption>In this figure, each node contains a neural network. The figure only highlights one such node and the neural network inside. In a neural-backed decision tree, predictions are made via a decision tree, preserving high-level interpretability. However, each node in decision tree is a neural network making low-level decisions. The “low-level” decision made by the neural network above is “Has sausage” or “no sausage”.</figcaption></figure><p><strong>NBDTs are as interpretable as decision trees. </strong>Unlike neural networks today, NBDTs can output intermediate decisions for a prediction. For example, given an image, a neural network may output <em>Dog</em>. However, an NBDT can output both <em>Dog</em> and <em>Animal</em>, <em>Chordate</em>, <em>Carnivore</em> (below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6W7gm8i-91NIPJH8.png" /><figcaption>In this figure, each node contains a neural network. The figure only highlights one such node and the neural network inside. In a neural-backed decision tree, predictions are made via a decision tree, preserving high-level interpretability. However, each node in decision tree is a neural network making low-level decisions. The “low-level” decision made by the neural network above is “Has sausage” or “no sausage”. The photos above are taken from pexels.com, under the Pexels License.</figcaption></figure><p><strong>NBDTs achieve neural network accuracy.</strong> Unlike any other decision-tree-based method, NBDTs match neural network accuracy (&lt; 1% difference) on CIFAR10, CIFAR100, and TinyImageNet200. NBDTs also achieve accuracy within 2% of neural networks on ImageNet, setting a new state-of-the-art accuracy for interpretable models. The NBDT’s ImageNet accuracy of 75.30% outperforms the best competing decision-tree-based method by a whole ~14%.</p><h3>How and what Neural-Backed Decision Trees Explain</h3><h4>Justifications for Individual Predictions</h4><p>The most insightful justifications are for objects the model has never seen before. For example, consider an NBDT (below), and run inference on a <em>Zebra</em>. Although this model has never seen <em>Zebra</em>, the intermediate decisions shown below are correct — <em>Zebras</em> are both <em>Animals</em> and <em>Ungulates</em> (hoofed animal). The ability to see justification for individual predictions is quintessential for unseen objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a-FG_DuC_U-o4zEn.png" /><figcaption>NBDTs make accurate intermediate decisions even for unseen objects. Here, the model was trained on CIFAR10 and has never seen zebras before. Despite that, the NBDT correctly identifies the Zebra as both an Animal and an Ungulate (hoofed animal). The photos above are taken from pexels.com, under the Pexels License.</figcaption></figure><h4>Justifications for Model Behavior</h4><p>Furthermore, we find that with NBDTs, interpretability improves <em>with</em> accuracy. This is contrary to the dichotomy in the introduction: NBDTs not only have both accuracy and interpretability; they also make both accuracy and interpretability the same objective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f0bv3hATAe23ACW4.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BuyDxE8yjshnJpub.jpg" /><figcaption>The ResNet10 hierarchy (left) makes less sense than the WideResNet hierarchy (right). In this hierarchy, Cat, Frog, and Airplane are placed under the same subtree. By contrast, The WideResNet hierarchy cleanly splits Animals and Vehicles, on each side of the hierarchy. The pictures above are taken directly from the CIFAR10 dataset.</figcaption></figure><p>For example, ResNet10 achieves 4% lower accuracy than WideResNet28x10 on CIFAR10. Correspondingly, the lower-accuracy ResNet⁶ hierarchy (left) makes less sense, grouping <em>Frog</em>, <em>Cat</em>, and <em>Airplane</em> together. This is “less sensible,” as it is difficult to find an obvious visual feature shared by all three classes. By contrast, the higher-accuracy WideResNet hierarchy (right) makes more sense, cleanly separating <em>Animal</em> from <em>Vehicle</em> — thus, the higher accuracy, the more interpretable the NBDT.</p><h3>Understanding Decision Rules</h3><p>With low-dimensional tabular data, decision rules in a decision tree are simple to interpret e.g., if the dish contains a bun, then pick the right child, as shown below. However, decision rules are not as straightforward for inputs like high-dimensional images.</p><p>As we <em>qualitatively</em> find in the <a href="https://arxiv.org/abs/2004.00221">paper</a> (Sec 5.3), the model’s decision rules are based not only on object type but also on context, shape, and color.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QlM2suqUHmdNTRsi.jpg" /><figcaption>This example demonstrates how decision rules are easy to interpret with low-dimensional, tabular data. To the right is example tabular data for several items. To the left is a decision tree we trained on this data. In this case, the decision rule (blue) is “Has bun or not?” All items with a bun (orange) are sent to the top child, and all items without a bun (green) are sent to the bottom child.</figcaption></figure><p>To interpret decision rules <em>quantitatively</em>, we leverage an existing hierarchy of nouns called WordNet³; with this hierarchy, we can find the most specific shared meaning between classes. For example, given the classes <em>Cat</em> and <em>Dog</em>, WordNet would provide <em>Mammal</em>. In our <a href="https://arxiv.org/pdf/2004.00221.pdf">paper</a> (Sec 5.2) and pictured below, we quantitatively verify these WordNet hypotheses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6RryKYzOd2CcgE1u.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/0*oz2CR1-i0LHE5y-5.jpg" /><figcaption>The WordNet hypothesis for the left subtree (red arrow) is Vehicle. The WordNet hypothesis for the right (blue arrow) is Animal. To validate these meanings qualitatively, we tested the NBDT against unseen classes of objects: 1. Find images that were not seen during training. 2. Given the hypothesis, determine which child each image belongs to. For example, we know that Elephant is an Animal so is *supposed to go the right subtree. 3. We can now evaluate the hypothesis, by checking how many images are passed to the correct child. For example, check how many Elephant images are sent to the Animal subtree. These accuracies per-class are shown to the right, with unseen Animals (blue) and unseen Vehicles (red) both showing high accuracies.</figcaption></figure><p>Note that in small datasets with 10 classes i.e., CIFAR10, we can find WordNet hypotheses for all nodes. However, in large datasets with 1000 classes i.e., ImageNet, we can only find WordNet hypotheses for a subset of nodes.</p><h3>How it Works</h3><p>The training and inference process for a Neural-Backed Decision Tree can be broken down into four steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U9RAuA-tVl0QOHOT.jpg" /><figcaption>Training an NBDT occurs in two phases: First, construct the hierarchy for the decision tree. Second, train the neural network with a special loss term. To run inference, pass the sample through the neural network backbone. Finally, run the last fully-connected layer as a sequence of decision rules.</figcaption></figure><ol><li>Construct a hierarchy for the decision tree, called the <strong>Induced Hierarchy</strong>.</li><li>This hierarchy yields a particular loss function, which we call the <strong>Tree Supervision Loss</strong>.</li><li>Start inference by passing the sample through the neural network backbone. The backbone is all neural network layers before the final fully-connected layer.</li><li>Finish inference by running the final fully-connected layer as a sequence of decision rules, which we call <strong>Embedded Decision Rules</strong>. These decisions culminate in the final prediction.</li></ol><h3>Running Embedded Decision Rules</h3><p>We first discuss inference. As explained above, our NBDT approach featurizes each sample using the neural network backbone. To understand what happens next, we will first construct a degenerate decision tree that is equivalent to a fully-connected layer.</p><p><strong>Fully-Connected Layer: </strong>Running inference with a featurized sample is a matrix-vector product, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4PUIR-vrhVl65UvU.png" /></figure><p>This yields a matrix-vector product yields a vector of inner products, which we denote with y-hat. The index of the largest inner product is our class prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0HvXPfprfo0asMmD.jpg" /></figure><p><strong>Naive Decision Tree</strong>: We construct a basic decision tree with one root node and a leaf for each class. This is pictured by “B — Naive” in the figure above. Each leaf is directly connected to the root and has a representative vector, namely a row vector from W (Eqn. 1 above).</p><p>Also pictured above, running inference with a featurized sample x means taking inner products between x and each child node’s representative vector. Like the fully-connected layer, the index of the largest inner product is our class prediction.</p><p>The direct equivalence between a fully-connected layer and a naive decision tree motivates our particular inference method, using an inner-product decision tree. In our work, we then extend this naive tree to deeper trees. However, that discussion is beyond the scope of this article. Our <a href="https://arxiv.org/abs/2004.00221">paper</a> (Sec. 3.1) discusses how this works, in detail.</p><h3>Building Induced Hierarchies</h3><p>This hierarchy determines which sets of classes the NBDT must decide between. We refer to this hierarchy as an <strong>Induced Hierarchy</strong> because we build the hierarchy using a pretrained neural network’s weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oB4C91BHI-G1jO12.jpg" /></figure><p>In particular, we view each row vector in the fully-connected layer’s weight matrix W as a point in d-dimensional space. This is illustrated by “Step B — Set Leaf Vectors“. We then perform hierarchical agglomerative clustering on these points. The successive clustering then determines the hierarchy, as illustrated above. Our <a href="https://arxiv.org/abs/2004.00221">paper</a> (Sec. 3.2) discusses this in more detail.</p><h3>Training with Tree Supervision Loss</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9vkamHUMmZjOITOS.jpg" /></figure><p>Consider “A — Hard” in the figure above. Say the green node corresponds to the <em>Horse</em> class. This is just one class. However, it is also an <em>Animal </em>(orange). As a result, we know that a sample arriving at the root node (blue) <em>should</em> go to the right, to <em>Animal</em>. The sample arriving at the node <em>Animal </em>also <em>should</em> go to the right again, towards <em>Horse</em>. We train each node to predict the correct child node. We call the loss that enforces this the <strong>Tree Supervision Loss</strong>, which is effectively a cross entropy loss for each node.</p><p>Our <a href="https://arxiv.org/abs/2004.00221">paper</a> (Sec. 3.3) discusses this in more detail and further explains “B — Soft”.</p><h3>Trying NBDTs in under a minute</h3><p>Interested in trying out an NBDT, <em>now</em>? Without installing anything, you can <a href="http://nbdt.alvinwan.com">view more example outputs online</a> and even <a href="http://nbdt.alvinwan.com/demo/">try out our web demo</a>. Alternatively, use our command-line utility to run inference (Install with pip install nbdt). Below, we run inference on a <a href="https://images.pexels.com/photos/126407/pexels-photo-126407.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;w=200">picture of a cat</a>.</p><pre>nbdt https://images.pexels.com/photos/126407/pexels-photo-126407.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;w=32  # this can also be a path to local image</pre><p>This outputs both the class prediction and all the intermediate decisions.</p><pre>Prediction: cat // Decisions: animal (99.47%), chordate (99.20%), carnivore (99.42%), cat (99.86%)</pre><p>You can load a pretrained NBDT in just a few lines of Python as well. Use the following to get started. We support several WideResNet28x10, ResNet18 for CIFAR100, CIFAR100, and TinyImageNet200.</p><pre>from nbdt.model import HardNBDT</pre><pre>from nbdt.models import wrn28_10_cifar10</pre><pre>model = wrn28_10_cifar10()</pre><pre>    model = HardNBDT(</pre><pre>    pretrained=True,</pre><pre>    dataset=&#39;CIFAR10&#39;,</pre><pre>    arch=&#39;wrn28_10_cifar10&#39;,</pre><pre>    model=model)</pre><p>For reference, see the <a href="https://github.com/alvinwan/neural-backed-decision-trees/blob/master/nbdt/bin/nbdt">script for the command-line tool</a> we ran above; only ~20 lines are directly involved in transforming the input and running inference. For more instructions on getting started and examples, see our <a href="https://github.com/alvinwan/neural-backed-decision-trees">Github repository</a>.</p><h3>Conclusion</h3><p>Explainable AI does not <em>fully</em> explain how the neural network reaches a prediction: Existing methods explain the image’s impact on model predictions but do not explain the decision process. Decision trees address this, but unfortunately, images⁴ are kryptonite for decision tree accuracy.</p><p>We thus combine neural networks and decision trees. Unlike predecessors that arrived at the same hybrid design, our neural-backed decision trees (NBDTs) simultaneously address the failures (1) of neural networks to provide justification and (2) of decision trees to attain high accuracy. This primes a new category of accurate, interpretable NBDTs for applications like medicine and finance. To get started, see the <a href="http://nbdt.alvinwan.com">project page</a>.</p><p><em>By </em><a href="http://alvinwan.com/"><em>Alvin Wan</em></a><em>, *</em><a href="https://github.com/lisadunlap"><em>Lisa Dunlap</em></a><em>, *</em><a href="https://github.com/daniel-ho"><em>Daniel Ho</em></a><em>, </em><a href="https://www.linkedin.com/in/jihanyin/"><em>Jihan Yin</em></a><em>, </em><a href="https://www.linkedin.com/in/scottjlee98/"><em>Scott Lee</em></a><em>, </em><a href="https://www.linkedin.com/in/henryjin99/"><em>Henry Jin</em></a><em>, </em><a href="https://spetryk.github.io/"><em>Suzanne Petryk</em></a><em>, </em><a href="https://cs-people.bu.edu/sbargal/"><em>Sarah Adel Bargal</em></a><em>, </em><a href="https://people.eecs.berkeley.edu/~jegonzal/"><em>Joseph E. Gonzalez</em></a></p><p><em>where * denotes equal contribution</em></p><p>[0] Designed by author Alvin Wan. Footnote exists to clarify we have rights to use this graphic.</p><p>[1] There are two types of saliency maps: one is white-box, where the method has access to the model and its parameters. One popular white-box method is Grad-CAM, which uses both gradients and class activation maps to visualize attention. You can learn more from the paper, “Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization” <a href="http://openaccess.thecvf.com/content_ICCV_2017/papers/Selvaraju_Grad-CAM_Visual_Explanations_ICCV_2017_paper.pdf">http://openaccess.thecvf.com/content_ICCV_2017/papers/Selvaraju_Grad-CAM_Visual_Explanations_ICCV_2017_paper.pdf</a>. The other type of saliency map is black-box, where the model does not have access to the model parameters. RISE is one such saliency method. RISE masks random portions of the input image and passes this image through the model — the mask that damages accuracy the most is the most “important” portion. You can learn more from the paper “RISE: Randomized Input Sampling for Explanation of Black-box Models”, <a href="http://bmvc2018.org/contents/papers/1064.pdf">http://bmvc2018.org/contents/papers/1064.pdf</a>.</p><p>[2] This 40% gap between decision tree and neural network accuracy shows up on TinyImageNet200.</p><p>[3] WordNet is a lexical hierarchy of various words. A large majority of words are nouns, but other parts of speech are included as well. For more information, see the <a href="https://wordnet.princeton.edu/">official website</a>.</p><p>[4] In general, decision trees perform best with low-dimensional data. Images are the antithesis of this best-case scenario, being extremely high-dimensional.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abb73e285f22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riselab/making-decision-trees-accurate-again-explaining-what-explainable-ai-did-not-abb73e285f22">Making Decision Trees Accurate Again: Explaining what Explainable AI did not</a> was originally published in <a href="https://medium.com/riselab">riselab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>