SBTB 2023: Jonas Mueller, Keys to Data-Centric AI: Asking AI to Improve its own Dataset.
Recording: SBTB 2023: Jonas Mueller, Keys to Data-Centric AI: Asking AI to Improve its own Dataset.
thanks for coming out I'm yonas and I'm one of the co-founders and chief scientists at clean laab and today I'm here to talk to you about data Centric Ai and really One Vision for this field and the idea of you know turning AI back on the data and trying to improve your data itself so that you can use AI to improve data so you can get even better machine learning in Ai and I'll probably skip through most of this uh motivation pretty quickly given you're all here um so but you know like there's this common figure that 80 80% of data scientist and AI developers time is spent on data preparation like from Andrew in and really you know bad quality data is costing a lot of money and those of you who have worked on any AI or data science projects probably have seen this firsthand and you've also probably seen firsthand that you know the data is just as important as what kind of modeling you're doing and there's a quote I really like which is uh you are what you eat uh tends to e apply exponentially more to AI than to most humans um so all the top organizations you know doing machine learning training those most famous models that uh have really uh impacted a lot of users they all recognize the value of this so like do uh from open AI when they were training Dolly 2 which is this image uh text to image generation model actually I should probably update this to Dolly 3 now but um this is from their blog on the release of Dolly 2 they essentially invest a huge amount on filtering out all of the bad data um that could be in the training sets that they're using for this model and in particular because it's just really hard once you fine-tune models with bad data to make the models forget that you know incorrect information some of the problems in the data set that they were using for Dolly 2 included like a lot of duplicates a lot of really low information images and mislabeled data and so they have this video and they say if it's taught if Dolly 2 is taught with objects that are incorrectly labeled like a plane labeled as a car then when a user tries to generate a car dolly May create a plane which is not very shocking but just sort of shows you the basic amount of data curation work that require that's required to go into you know producing a high quality model like this and really yeah the main takeaway is just the reliability of these models in order to produce these products that really work reliably at scale really depends on having highquality training data the same as holds for other companies like Tesla like this is a slide from uh the former AI director at Tesla Andre capry and just showing you know how much time they spent curating data sets instead of worrying about what kind of machine learning model are they going to use what kind of you know training algorithms are they going to use and really they built this big system at Tesla that covers some of the things I'm going to talk about today that they call the data engine which is essentially just the idea of you know training your models then using your trained model to notice problems about your data set amplifying those kinds of signals in your data set uh in various ways that I'm going to cover and then you know iterating that process to get even better models uh one particular type of data problem that's near and dear to my heart is uh label errors in supervised learning data in particular um and I'll talk about these in a little bit but these are you know just like in the famous uh machine learning data sets like mnist or imagenet there's just a ton of data in there that is straight up mislabeled even though these have been studied by thousands of machine learning researchers and these are data sets where getting a 0.001% increase in accuracy you know can be a big deal for the field of machine learning research and so actually me and my two co-founders we were grad students and we did some research on an algorithm that I'm going to talk about called confident learning and uh that was essentially an algorithm to discover these mislabeled uh images or mislabeled examples in a data set and we just ran this on all of the most famous uh data setes at that time that were being used in machine learning research and just looked at you know like how many of the labels are actually incorrect when we go validate them with Mechanical Turk and we just found a lot of these data sets just have a high error rates especially data sets like imet where there's a huge number of classes some very confusing classes there's just a lot of mislabeled data in there and this was very uh surprising to the field for some reason um because nobody just wanted to go through and look at you know the data and figure out what's uh you know mislabeled in there and that actually gets to the point of data Centric AI I think which is a lot of people just think you know like data Centric AI That's just like a synonym for machine learning like all AI nowadays is data Centric but really what we think about data Centric AI we think about the idea of actually using AI to improve your data set much more systematically using automation not you know just manually uh being uh doing all the work manually yourself to improve the data set and so the tral uh sort of picture for a traditional ml project would be the data set the data scientist is expected to just manually do exploratory data analysis figure out you know all the problems in the day set improve them all just based on all their knowledge that they've acquired over the years in a really intuitive way just as they see the problems they come up with fixes on the spot and then they switch kind of from that data prep mode into modeling mode and they just start training their initial ml model and dive straight into you know trying to improve this model through better architectures better regularization strategies or training strategies you know tweaking the hyper parameters and really there's sort of this two modes of working data prep and then modeling and there's not really this idea of revisiting the data once you've transitioned into modeling uh mode but actually a trained machine learning model already knows a lot about your data after just by virtue of having been trained on that data and you can actually use that knowledge to find a bunch other kinds of issues in a much more automa automated and systematic way um using some algorithms that I'll cover in this talk but also a whole class of other techniques that just try and use the information in your initial ml model to help you understand different kinds of problems that are existing in your data and so the idea here in data Centric AI as we see it is you can go try and train that that initial ml model as quickly as possible obviously you still have to do some data prep work some data transformation some exploratory data analysis to get to the point where you can even train that initial ml model but once you have that Baseline model you can try and use that model to essentially help you automatically detect a bunch of issues in your data and even fix some and then you can produce a better version of your data set that then you can use that better version to go back into modeling mode and you know use all the same tricks you were using before to just focus on trying to improve the machine learning model but what you can also do is actually just retrain that initial machine learning model on this improved version of your data set and you know because the data is now better quality you will actually get a stronger machine learning model just for free without any change in any of your machine learning code and then you can iterate this process and that really gets the heart of this idea of a data engine because now this machine learning model trained on better data is able to better Det detect the remaining issues in the data and so you get this virtuous cycle of data Improvement and model Improvement that you can iterate um most of what I'm going to be talking about today we've uh freely open sourced in this Library called clean laab and this is uh the most popular library for data Centric AI today um and it's just a python library that you can go check out on GitHub and it works all of these ideas work for most of the data modalities because really we're not going to talk too much about uh algorithms that actually touch the raw data themselves so obviously you can come up with many many automated solutions that could find a bunch of kinds of problems and data by actually you know inspecting the raw data the raw image the raw text but what we're going to talk about is techniques that use trained machine learning models and the information therein to detect these issues and so all we sort of require is that you have trained an initial machine learning model on your data and then we're going to just only access your data through that machine learning model that makes this really generally applicable and also the techniques we're going to talk about um are really designed to work with any machine learning model trained in any way and that's really important because a lot of uh the field of you know data mining data science machine learning research there's thousands of papers on many topics and you'll often find that some of these topics or some of these methods that researchers have proposed are model specific which means at the year they were proposed you know maybe back in 2016 they were actually better than any other method that existed when used with the models that had existed at that time but the machine learning progress has just been uh increasing relentlessly and the models are just getting better and better and so we find essentially that today you can take really simple techniques use them with a very powerful model and just do astronomically better than the best you know most sophisticated technique that existed 5 years ago applied with models that existed then but that technique technique is no longer even easy to apply to the models today because it required changing the way the model was trained it had to be deeply integrated into the model in some way um so what running this kind of code can look like um is an example is here where the code is super simple to find uh issues in a say a classification data set or some kind of labeled data set where essentially um the two key inputs that we ask for from the machine learning model are embeddings of the data so like representation of the data that are in numerical form which pretty much every machine learning model can give you as well as uh predicted class probabilities or predicted probabilistic predictions essentially coming out of your trained model for each data point and based on those two inputs alone we can uh identify all kinds of issues in the data automatically using algorithms that essentially only operate on these and never touch the raw data and so the kinds of uh issues that can be detected include things like uh this label data as I mentioned before so here we have like a cat dog you know really toy binary classification data set say and we're going to circle the kinds of issues that can be automatically detected imagine this data set you know has millions of examples and it would be very hard to find these kinds of issues yourself manually um but things like uh mislabeled data nearly duplicated data um outliers which often indicate you know problems in your data sources that you didn't expect um as well as non-independent or drift uh data where two different data samples may be related in ways that you had no idea about and so detecting all of these you'll notice actually requires to some degree understanding the information in the data itself which is where you know having that trained machine learning model is so powerful having those embeddings and predictions from that model is so powerful for capturing a lot of this uh information in the data set um and all of this can apply to Text data as well because again we're just not touching the raw text ever for example finding mislabeled data in say customer chat requests where they're labeled by their the intent of each customer um going back to my point previously um a lot of algorithms exist for certain kinds of data issues that I'm going to talk about and many of these algorithms are very complicated but for example for detecting outliers this is you know a very very standard topic that has been studied by I don't know how many researchers and what we found uh doing this at the beginning of uh last year was essentially just measuring how far each data point is to the K nearest Neighbors in the embedding space of the model uh works really really well compared to like much more sophisticated techniques when you have a very good modern model like a vision transformer for images and essentially you know what kind of model you're using there matters so much more than the actual outlier algorithm that you are using and so that's just getting to this idea that we can apply pretty simple algorithms with modern models and get really good data understanding data results and it's really important that these algorithms remain simple so that they can be applied with to tomorrow's models and the models five years from now that you know will just be astronomically better um so one thing I'm going to jump a little more into in detail is the issue of mislabeled data because um yeah this is really where we got our start in this field and really the origins of the open source clean lab Library came from the fact that we had published some research on you know this confident learning method and we had run it on all these famous machine learning data sets and said like hey look there's all these label errors in these and we were presenting this at conferences and professors would just say basically like I don't believe this is possible you're telling me you can like train the machine learning on the messed up data and it's going to find which data is messed up like there's no way that could work and so we were just like I'm not going to argue with you we'll just uh you know open source the code and make it slightly more usable than uh most research code and that Library really became really popular and used by a ton of companies and a ton of data scientists across all kinds of Industries um but yeah it all started with just this confident learning algorithm originally and since then has grown into you know a collection of algorithms that are all designed to take in machine learning model inputs and output a bunch of kinds of data issues but Focus ing back to confident learning the core idea here is you have a classification data set and you're trying to understand uh How likely is each data point mislabeled as well as which subset of the data is mislabeled so that includes you know like how many data points are mislabeled how many data points from each class are mislabeled so you can characterize how noisy the each class's labels are perhaps to improve your anator instructions and really the uh key idea of this algorithm I'm not going to go go into the math here but you can check out the paper um is to use any models predicted class probabilities right so every classification model that pretty much exists gives you some form of predicted class probabilities and that makes this algorithm usable with any trained machine learning model um but the key idea is you're going to use those predicted class probabilities to find these label errors and really what you're trying to adjust for is when is my model doing a bad job right so a baseline approach would just be to say anytime the model makes a difference prediction than the data we're going to say the data is wrong but that's going to give you a really huge range of false positives because the model typically is not that great and it's making tons of Errors because it's trained on limited data and it makes you know it likes to predict certain classes more than others just for whatever reason it uh makes certain kinds of Errors when it sees certain kind of feature values for whatever reason and so the key idea here is we try and account for the typical shortcomings that trained machine learning models tend to display and adjust for those so that we're only focused on the predictions from the model where we're really confident that that prediction is super trustworthy and that prediction greatly differs from the data such that you know like if the model really likes to just predict say the dog class for whatever reason we're going to really discount um data that as being not that likely mislabeled when the model predicts actually this should have been a dog because we just know the model tends to overpredict dogs and so you can think of this as essentially like a form of calibration uh confidence calibration that is more specifically focused on helping us understand when we can trust the model over the data itself and also helping us account for you know the inherent types of uncertainty in these models such as alator uncertainty due to the labels just being stochastically related to the features inherently like trying to predict you know somebody's height from their weight you're never going going to get 100% accuracy because there's inherent uh non-determinism and similarly um trying to understand the epistemic uncertainty um in certain regions of the feature space like you might just have never seen examples that are similar to this and therefore the machine learning model is not expected to do a good job in his predictions and we're going to Discount those predictions even if they strongly disagree with the given label and just to get you a sense of like the kind of complexity here even when we're just talking about you know classification data sets mislabeled data there's just a lot of different kinds of errors that can appear in such data and confident learning actually can detect all of them pretty well um so one is just non-agreement or ambiguity inherent ambiguity where even you know many human annotators if they were given such images might disagree on what is actually the correct ground truth and we've often seen folks just waste like a lot of annotation budgets on having many uh people label such images when there's not not that much to be gained unless you typically you can gain a lot more by changing your annotator instructions or by having an expert you know like a second tier annotator review these that has some additional information then we have often in classification data sets you know in these famous machine learning data sets especially there's no like other class or none class and so every example is really expected to fall into one of the K classes in the data set but that's just not true there's like a bunch of images and all these data sets that you know there's this graph here for whatever reason I think this is in Caltech 256 that I have no idea why that graph exists in the data set but data is just messy and yeah that graph does not correspond to any of the classes in that data set then we have just a problem with framing you know certain problems as multiclass classification in the first place where actually you know sometimes some of the examples belong to more than one class simultaneously um for example this hamster uh you know also could match the cup class and then finally there's just straight up unambiguous uh errors where you know humans are just for whatever reason making data entry mistakes making incorrect judgments when they're labeling this data and is just you know very clearly wrong and these are in some sense the very worst examples you can include in machine learning training data they're basically like having a teacher that you know is randomly lying to you every 50 statements they just tell you something that's like totally not true um and it's just hard to learn from that um one other point I want to make with this slide is that we are here we compared um essentially this confident learning style methodology as well as a few other data Centric methodologies and what makes these methodologies data Centric is they're all about just doing some kind of estimation of what is the bad data and then we just delete all the data that's estimated to be bad you know so two-step process really automated and we compare these so there's other automated methods you know to deal with machine learning with noisy data and that's like a whole subfield of research and most of these other methods are what I call model Centric which means a they're not agnostic of what kind of model you're using they're somehow like integrated into the model or its training process which doesn't future proof them first of all and second of all they are essentially trying to learn something really hard which is like a quantitative measure of like how noisy each data point is and then they're adjusting some kind of regularizer some kind of loss function or training procedure based on those estimates and the problem is that when those estimates inevitably have errors and they do because the data is bad um those errors just remain in the data set and they kind of propagate um whereas when you just delete bad data as long as you're doing a decent job at deleting mostly bad data it's just you know completely gotten rid of that from the training set and we find here that these data Centric methods just give you much better performance in really noisy data sets than these model Centric methods that are specifically do designed for these noisily labeled data sets um so everybody here is probably super excited about llms and let's just focus on you know the most easy use case of llms which is for just classification of text and all of this applies as I mentioned to any kind of machine learning model so we can take uh say an open Ai llm and fine-tune it for you know text classification in this case for uh classifying how polite some text is uh from some online forums I think or from some kind of projects and essentially here we see you know a data set that looks like this and this data like any other data has all these kind of Errors so we can run our open source clean lab library on it using the predictions from the llm as the input for this library and we find you know uh data points that are just straight up uh seem incorrect very clearly like this data point here does not seem very impolite and so what we can do to deal with this uh mislabeled data is uh so we're going to evaluate you know how good is our fine-tuned open AI model on test data and crucially this is going to be test data that's high quality so we actually had multiple annotators label each test data point so we know that the labels are high quality and reliable and in Black we're showing the performance of just directly fine-tuning the llm on the original raw data and we did this for three different uh llms that are fine-tunable from open AI uh now you can fine-tune I think one more so that's exciting since Dev day um but yeah these were the only ones available at that time and you can see you know you get some performance on these high quality test labels in Orange what we're showing is running this one line of code to find all of the mislabel data automatically or estimate I should say you know it's not going to be perfect but it can do a pretty good job at estimating the the what data is mislabeled automatically we can just delete all of that estimated bad data and then recall the same exact fine-tuning code on the remaining filtered data set so this is you know like a trivial process that involved almost no human labor and was just one line of extra code to call clean laab library and estimate the mislabeled data and then another line of code to just delete that all and you see that the performance uh has gone up like a really big amount and this holds across many types of llms but even better is actually when we estimate which data is mislabeled that's just a small fraction of the original data set so we can go in and actually have you know a human go try and understand what's going on there and actually fix some of these examples rather than just deleting them all and maybe some of them do need to be deleted because like they don't match any of the labels for example or they're too ambiguous um but in this case um we just had our annotator go through and fix just that subset of the data which is you know a tiny fraction of the whole data set and you get really really large uh performance gains as a result and in that's being shown in blue here and the key thing to note is that between these three uh results it's all the same machine learning code right this has become very evident to people using openai there's not even much you can do when you're using it like you just call fine tune and it fine tunes for you pretty much all you can do is change your data and so this uh kind of data Centric thinking has become a lot more popular and a lot more important in today's age as well um all of this also just holds with arbitrary kinds of machine learning models and data sets as I've been trying to clarify so here we're looking at you know some tabular classification problems in this case predicting grades from some student information and this is the exact same plot I just showed with the open AI results but here we're just using EX boost everybody's favorite tabular data model and we're again training it on the original raw data in Black we're evaluating everything on verified uh labels that are high quality and we are and we are applying clean lab and confident learning to automatically estimate which labels are bad deleting those automatically and retraining the thing with no change in the machine learning code and getting better results and even better is fixing the subset of the data that has been flagged by this library to get the best possible quality results in the end uh all of this also applies to you know rhf which is becoming it's still early days but it's starting to become really popular way for companies to create their own llms that behave you know according to the uh desired Behavior at that company and again in rhf a human is supposed to annotate which of the two llm completions is preferable for a particular uh prompt and humans just make mistakes like with any other human annotation task there's always all these mistakes and confident learning can automatically uh help you detect you know which data is uh the has annotator error and you should consider not including that and this noisy data is a really big problem for R rlf it's uh really slowing down the learning process and making it really expensive such that today pretty much only the biggest AI companies are even successfully using rhf as far as I'm aware um this correction is also important for um test data not only for training data especially for ensuring you know that you're evaluating your models properly it's really important that you have uh good data that you're evaluating on espe here we're just showing the impacts if we're trying to choose between two different prompts again for some open AI llm um that these data errors can lead you to choose a worse prompt that actually looks better in the noisy data evaluation but when you go clean the data actually that prompt actually did statistic I istically significantly worse on the clean data set and this holds across you know various types of prompts whether it be Chain of Thought or F shot and with fot prompts especially here you're starting to stick data into your uh llm itself right like into your prompt itself and it's so crucial when you're sticking not that much data into the prompt that you know you're being really rigorous in ensuring the data here is not mislabeled and not noisy and actually while you know you can man sometimes manually inspect the examples you're going to stick in by running things like confident learning and actually getting the most confidently correctly labeled examples and sticking those into your prompt instead even though you know you're not actually switching between mislabeled data and correctly labeled data necessarily having data that's just like super unambiguous and the clearest depiction of each Concept in your prompt can really boost the performance of these sort of in context learning or F shot prompting um when it comes to data with multiple annotators like one natural way to deal with you know data where I know there's going to be label errors is just to have multiple folks look at it right and for such data the three things we're interested in estimating is like what's the best consensus label How likely how confident are we that this consensus label is actually correct or should we go have another annotator look at it and what annotators are not doing such a good job and so here I'm going to skip through some math but the key idea is there's like a huge amount research in the field and you know all these complicated generative statistical models that have been published in uh data science research and really what you can do instead is just use a machine learning model a good machine learning model like a modern one take its predictions and what we do is we essentially do a Ensemble of those predictions with treating each of the annotators as if they were another machine learning model making their own predictions and just do standard kaggle style Ensemble that you know wins all the kaggle competitions of this good machine learning model with all these annotators and we use that to pull out the best consensus labels and the confidence scores via a method called crowd laab and we just see that the resulting results are much better than all these traditional generative models which once upon a time we're really you know some of the best methods out there for doing this but machine learning technology again has just kept advancing and the predictions you're getting are so the probabilistic predictions in particular are so well calibrated and so accurate that you're just really uh doing a much better job by leveraging it um and this can also help you do active learning by just taking these the confidence scores I previously mentioned to decide which consensus label seems Incorrect and having another annotator go annotate that data and often it might actually be better to have an annotator go relabel a data point that's incorrect than to use that same budget to go label new unlabeled data it's goes back to that analogy I was talking about of a teacher who sometimes lies to you it's actually probably better to have a teacher who teaches you you know like slightly less facts but does not lie to you than tries to teach you a bunch of facts and randomly lies and we find that you know holds for machine learning as well um by doing this uh relabeling in this systematic way where needed where these uh algorithmic methods are detecting the data as likely mislabeled we're just getting much faster uh learning improve machine learning improvements at a given data annotation budget shown on the x-axis um I think that's probably all I'll have time for so I just want to emphasize this can also be applied not just to you know classification data sets where you have one label but also you know uh sequence to sequence data sets where we still see as with any human annotated data there's just really bad responses in these sort of input output data sets for customer service for chat Bots for any other application just human data is noisy and full of issues and algorithms can help you detect those once you've trained a baseline machine learning model and really we think that is the big gap today to bridge between you know messy raw data and reliably deployed machine learning model not just a demo but something that actually handles all the edge cases and works in production it often just comes down to finding these informational problems in the Raw data and fixing them and automation is almost required to do this on a large scale data set so yeah with that I will uh leave it for questions thank you [Applause] yeah so one of yeah that's a really thorny problem I'm not going to claim this will solve that problem but we do people use this library to analyze synthetic data sets and compare them against Real data sets to understand um shortcomings like synthetic data that looks really unrealistic as well as real data scenarios that are under represented amongst the synthetic data but I'm not going to comp claim that this is a solution to that very very thorny problem thank you [Applause] guys