<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jason Eden on Medium]]></title>
        <description><![CDATA[Stories by Jason Eden on Medium]]></description>
        <link>https://medium.com/@jasondeden?source=rss-4484b53b9db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*regaoMNRZKdRKPxq</url>
            <title>Stories by Jason Eden on Medium</title>
            <link>https://medium.com/@jasondeden?source=rss-4484b53b9db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 10 Nov 2026 05:52:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jasondeden/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Kernel Trick 2 — Radial Basis Function (RBF) and “Infinite” Flexibility]]></title>
            <link>https://jasondeden.medium.com/kernel-trick-2-radial-basis-function-rbf-and-infinite-flexibility-c239ff0b0f7f?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/c239ff0b0f7f</guid>
            <category><![CDATA[kernel-trick]]></category>
            <category><![CDATA[radial-basis]]></category>
            <category><![CDATA[rbf]]></category>
            <category><![CDATA[svm]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Wed, 25 Dec 2024 17:42:30 GMT</pubDate>
            <atom:updated>2024-12-25T18:12:20.345Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kernel Trick 2 — Radial Basis Function (RBF) and “Infinite” Flexibility</h3><p>I have previously written about the SVM Kernel Trick and described how the <a href="https://jasondeden.medium.com/the-treat-of-the-trick-7b0f6c533085">polynomial kernal</a> allows for massive programmatic feature expansion without massive increase in compute for inner product distance calculations. However, there is another, even more powerful kernel available for SVM — the Radial Basis Function or RBF.</p><p>A couple of big differences:</p><ol><li>The RBF kernel uses Euclidean distance (typically) rather than inner product for distance calculations</li><li>The RBF kernel generates a similarity score (a percentage value between 0% and 100%)</li><li>The RBF kernel does not explicitly add features to data, but <strong>implicitly is equivalent to having infinite dimensions</strong> (which makes it an extremely powerful classifier)</li><li>Despite this “infinite dimensionality” the RBF kernel is able to make really fast inference — making it both faster *and* more powerful than the polynomial kernel</li></ol><p>Points 3 and 4 are especially bold claims. How can this be both infinitely flexible *and* highly performant? Let’s start with the math.</p><h3>Generating Similarity Scores</h3><p><strong>Similarity of test point to data = <br>Exponent of (negative (euclidean distance squared) divided by (sigma squared))</strong></p><p><a href="https://colab.research.google.com/drive/1enYEfZJLYULQ-7qhgdoRQrCBAkfArl7Y#scrollTo=lnNWFBeFqrLv">https://colab.research.google.com/drive/1enYEfZJLYULQ-7qhgdoRQrCBAkfArl7Y#scrollTo=lnNWFBeFqrLv</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7kWx5xDCQsG1rZuF8_Y6sg.png" /><figcaption>Go the Distance!</figcaption></figure><p>When two points are identical (distance = 0) you get a similarity score of 1 (or 100%). As the distance grows, the similarity drops. The value for sigma determines the upper distance boundary before distances get evaluated to 0 — in Colab, with a sigma value of 1, you hit that boundary around 28 or so, however if you raise sigma, you are able to continue to differentiate between higher distance values (if needed).</p><p>So we can calculate a distance between training data and test points and simply pick the most similar point as our prediction. Infinite flexibility!</p><h3>Avoiding High Compute Costs at Inference</h3><p>But wait. We could do this with k-NN as well, and it came with a serious drawback — at inference, the calculation of distance between a test point and every training point is extremely computationally expensive. Wouldn’t we have the same problem with SVM?</p><p>Here’s where the genius part comes in: Once your SVM model is built, you don’t actually need to keep all of your training data and compare the test points to every training point. You just need the support vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*WlA2BUuAyyWyAMPHHhhpiw.png" /><figcaption>Support Vectors</figcaption></figure><p>In case you’ve forgotten, <a href="https://jasondeden.medium.com/give-me-some-space-c481a2fb7489">support vectors</a> are the training data points that are used to determine the placement of the boundary for SVM. They are equally distant from the decision boundary.</p><p>Thus, when you are comparing similarities, if you simply look at the similarity scores of your test point against the support vectors in your training data, whichever is most similar = your prediction! You only need a relatively small number of distance calculations after the model has been built to do inference, making this *extremely* fast.</p><h3>Summary</h3><p>In summary, the RBF kernel for SVM is an incredibly powerful and performant modeling approach when facing extremely complex data. It has the same flexibility as k-NN, however at inference distances only need to be calculated from a small number of training data points, making it highly performant as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c239ff0b0f7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Defining Dueling Distributions]]></title>
            <link>https://jasondeden.medium.com/defining-dueling-distributions-f0587bd22d0a?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0587bd22d0a</guid>
            <category><![CDATA[naive-bayes-classifier]]></category>
            <category><![CDATA[normal-distribution]]></category>
            <category><![CDATA[binomial-distribution]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Wed, 14 Aug 2024 04:17:13 GMT</pubDate>
            <atom:updated>2024-08-14T04:17:13.796Z</atom:updated>
            <content:encoded><![CDATA[<p>Binomial and Normal Distributions in Naive Bayes</p><p>For a simple Naive Bayes classifier, we deal with two types of distributions for data and predictions: binomial and normal.</p><h3>Binomial Distributions: Pick a Side</h3><p>A binomial distribution is one in which all possible values are either 0 or 1. Another way to think about this is “inactive” vs. “active,” 0% vs. 100%, or “False” vs. “True.” In any case, binomial distributions in data have only two possible values of 0 and 1.</p><p>This becomes important when building certain types of feature vectors / embeddings. You might be taking unstructured data (such as letters or words) and converting it into a feature vector in order to perform math on it. Each feature or column in your data represents the presence or absence of a certain idea — for example, “the first character is a vowel.” This is either true or not, so the value is either going to be 1 for true or 0 for false. There is no sense in saying “kinda” — at least not in the English language — and so there is no logical reason for a value to be anything other than 1 or 0. The feature vector in this case is a collection of these columns where whatever you are evaluating is being checked for truth vs. falsehood, or active vs. inactive, and coded as a 1 or 0 accordingly.</p><p>For example: say I define a vector / embedding scheme that has four features: first character vowel, last character vowel, more than five characters in word, and more vowels than consonants. If I take the word “language” and use this logic, I would convert it into this four-dimensional feature vector as follows: 0 1 1 0</p><h3>Normal Distributions: Freedom and Flexibility</h3><p>In contrast to binomial distributions, normal distributions are those where the features can be any value from 0 to 1. We make assumptions about how features are distributed via the famous bell curve (meaning mean, median, and mode values are all going to be the same), but the actual value of a given feature can be literally any value between 0% and 100%.</p><h3>Combining the Distributions for Naive Bayes</h3><p>We end up using both of these concepts in Naive Bayes. We have training data that contains multiple observations of something that we convert into binomial feature vectors, and then we separate them by class and create normal probability distribution vectors which we can use to make predictions.</p><h4>Using Distributions to Make Predictions with Naive Bayes</h4><p>Say for example we have four keywords in a document that is classified as “academic” for our purposes: language, speak, analog, and alibaba. This creates a data matrix for our academic class of:</p><p>0 1 1 0<br>0 0 0 0<br>1 0 1 0<br>1 1 1 1</p><p>Because we are assuming a normal distribution, we can calculate the average values for each of our features to come up with a probability vector which we can use for Naive Bayes predictions:</p><p>.5 .5 .75 .25</p><p>If I have a new word — clown — and I need to determine the probability that it belongs in the academic category, I can use the chain rule and Bayes Theorem to calculate the probability that this word belongs in that class. (I won’t go into it here, but the answer is about 4.7%.)</p><p>In order to check if this is the right prediction to make, I need another class to compare it to. Let’s assume I had other words that fit into a category of “fun” and after creating their embeddings and calculating the average feature values, they had the following probability vector:</p><p>.2 .3 .4 .6</p><p>(Obviously this training data had a different number of observations than our first class. There’s no rule against that!)</p><p>We can now again use the chain rule and Bayes Theorem to come up with an aggregate probability. (This time it’s around 13.4%.)</p><p>Now I can make my prediction — since 13.4% probability is more likely than 4.7% probability, if I am choosing between those two classes, I predict that clown belongs in the “fun” class. (With apologies to any of my friends who took a challenging academic path in clown school…)</p><h3>Practical Application</h3><p>This simple example actually calls out a number of core tenets of data science. If you know what signals are valuable in a certain type of data (my four-feature example probably wouldn’t be great in real life, but might not be a bad start for a higher dimensional vector / embedding scheme…) then you can create the embeddings using rules that extract those meanings via binomial distributions. You can then take two or more classes of data, convert each relevant observation into an embedding, and then take the average values for each feature in each class to come up with a normal distribution probability vector. This probability vector, plus some basic statistics and the naive assumption that allows us to use the chain rule to calculate aggregate probabilities, can then be applied to an unknown observation and used to find the most likely class that this new observation belongs to, which we can then use as our prediction in a machine learning model.</p><p>You will see this basic principle applied all over machine learning today, well beyond the simple Naive Bayes example illustrated here, and understanding how this works will help you wrap your arms around much more complex topics in data science.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0587bd22d0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[L1 and Elastic Net Regularization]]></title>
            <link>https://jasondeden.medium.com/l1-and-elastic-net-regularization-0a74329ff037?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a74329ff037</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[elastic-net]]></category>
            <category><![CDATA[l1-regul]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Tue, 19 Dec 2023 20:56:56 GMT</pubDate>
            <atom:updated>2023-12-19T20:56:56.403Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://jasondeden.medium.com/l2-regularization-whats-actually-going-on-7511747f9c3d">previous blog post</a> I provided a relatively simple overview of L2 regularization, how it works, and why you would consider using it. In this one, we’ll look at another common approach — L1 regularization — and discuss what it does and how it’s very different from L2. We’ll then take a look at how the combination of L1 and L2 regularization — known as “Elastic Net” — works and how to think about what it does to your modeling approach.</p><h3>L1 Definition</h3><p>L1 regularization looks very similar to L2, but it is doing something dramatically different. Whereas L2 regularization penalty was the sum of the squared values of the model weights times a constant, L1 regularization is the sum of the absolute values of the model weights times a constant.</p><p>L1 Loss = ((Sum of Absolute Weights) * A Constant) + Model Loss</p><p>The goal of L1 regularization is to minimize the overall total weight values (thus minimizing the L1 loss penalty), and if possible, reducing as many of them as possible all the way to 0 or close to it while continuing to minimize model loss. Whereas L2 regularization sought to smooth out values between weights, and as such actually amplified features that would otherwise have smaller weights, L1 regularization will put as much weight as possible on as few features as possible, allowing us to completely ignore certain features altogether.</p><p>Similar to the previous blog example, say you have a model that has an overall loss of 56 without regularization. This model has three features, and the weights for each feature are as follows: w0 = 10, w1 = -4, and w2 = 1.5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*P9lbHBLtcwfyDT4jAOr1Pg.png" /></figure><p>What does this look like with L1 regularization? For now, we’ll assume our hyperparameter constant value is set to 1. Thus, the imputed loss of our model under L1 regularization equals:</p><p>((Sum of Absolute Weights) * A Constant) + Model Loss</p><p>((10 + 4 + 1.5) * 1) + 56</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*Xl0eEnyRNXK6_1mogy7Kjw.png" /></figure><p>…or 71.5. Again, the higher loss value is an arbitrary value — this is the same model that without regularization had a loss value of 56. Nothing has changed because we’re adding the regularization term.</p><p>However, here’s where things get interesting. With L1 regularization, we have a simple question to ask: if I decrease the magnitude of a feature weight by x, is the additional Model Loss greater than or smaller than x? If the answer is that the Model Loss increase is less than the weight value, then the algorithm will make the model weight smaller until this is no longer true.</p><p>Let’s take a look at a couple of additional models and their unregulated loss value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*hoUACrbp-Mr3O_WoGy7XwA.png" /></figure><p>Without regularization, Model 1 would have been selected as the best of the three by our algorithm. However, now if we apply our L1 regularization with a constant value of 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*07Vuj50YJQajKu0L410PZA.png" /></figure><p>The other two models are now judged to outperform Model 1, and Model 2 gives us the best overall L1 regularized loss. Note that in this version of the model, we no longer need to consider w2 — the weight is zero, so for future versions of the model we build out, we can drop this feature altogether.</p><p>As with L2 regularization, we can weight the regularization effect more heavily and see if and how that changes our evaluation. Say for example we set the constant to 3 instead of 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*dJA6XK59ucgmKT6I0seBlw.png" /></figure><p>The more weight you give to the L1 regularization term, the better Model 3 is going to look since it has the lowest overall sum of absolute model weights, and indeed at any C value higher than 2, Model 3 is going to be evaluated as the lowest loss model. Even if we set the C value to 2 and the L1 regularized loss of Models 2 and 3 were equal, Model 3 would still be considered the superior model because it allows us to ignore both w1 and w2.</p><p>We could generate a final version of the model that only contained w0 and base all of our test predictions on that one feature. We no longer need to consider w1 and w2, as long as the L1 regularization assumptions being made were accurate to begin with.</p><p>Practically speaking, you would almost never use L1 regularization on a model with only three features. In small data situations like this, you’re probably looking for data addition and enrichment opportunities rather than feature rationalization. However, let’s say your data contained three-thousand features instead of just three. Depending on your modeling approach, this can take model training and serving time up fairly dramatically, potentially to unworkable levels. In this situation, creating a baseline model and using L1 regularization to identify features that can be dropped to 0 or close to it would be extraordinarily valuable, as the compute time to model around 300–400 features can be orders of magnitude less than 3,000 or more. Even if you give up a little in the way of predictive performance, you’ve gained a lot in the flexibility and clock-time performance of the models on smaller datasets.</p><h3>Elastic Net</h3><p>Elastic Net combines L1 and L2 regularization. It computes both values using the same procedures as before and then weights each one according to the relative weight you want to give L1 vs. L2 regularization. (The two weights will equal 100%.) You could write it out like this:</p><p>(L1 percent) * ((Sum of Absolute Weights) * the Constant) + <br>(1 — L1 percent) * ((Sum of Squared Weights) * the Constant) + <br>Model Loss</p><p>So if you wanted to try building a model with a 50/50 split between L1 and L2 regularization, you’d set the L1 percent value to 0.5. If you wanted to do mostly L1 regularization but throw in just a little L2 regularization effect, you might set the L1 percent value to 0.9. And so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMlwlwHE3e8lEjYymiIlOA.png" /></figure><p>In the end, the best values and weights might be guessable based on your knowledge of the dataset, but you might also need to try various combinations via grid search or some derivative of it in order to find the optimal values.</p><h3>Summary</h3><p>In summary — whereas L2 regularization tends to smooth out the magnitude of the features in your dataset, L1 regularization goes the opposite direction and tries to minimize the number of features that have to be considered at all, even if it means increasing the magnitude of already large variable weights. The right choice between the two depends on the nature of the data you are working with. In situations where both might be useful to more or less degree, you can use Elastic Net and adjust the relative weighting of the regularization penalties until you find the optimal solution. Regardless of the regularization approach, your end goal is to produce models that perform as well as possible in the real world. For L2 regularization, this usually means better overall predictions. While this might be true for L1 regularization as well, the focus is usually on eliminating extraneous features from the data when you have too many of them for the compute resources you have available, thus allowing you to build and iterate future models on smaller subsets of data.</p><p>As with everything in data science, a great deal of hypothesis building and experimenation is required in order to come up with the optimal values and approach for a given data problem, and in some cases you may find your data reflects reality well enough that you don’t need to use regularization at all! The larger and more representative your data are, the less benefit regularization will provide. The only way to know for sure in most cases is trial and error.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a74329ff037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[L2 Regularization: What’s Actually Going On?]]></title>
            <link>https://jasondeden.medium.com/l2-regularization-whats-actually-going-on-7511747f9c3d?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/7511747f9c3d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[l2-regularization]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Sun, 17 Dec 2023 21:49:34 GMT</pubDate>
            <atom:updated>2023-12-17T21:49:34.425Z</atom:updated>
            <content:encoded><![CDATA[<p>I find it interesting that there are a *lot* of folks in data science that work with and build complex predictive models who have somehow missed the basics of how those modeling approaches work. I get it — you learn something well enough to meet a specific objective and move on — but it really can be a detriment to your understanding of what machine learning is and what it does.</p><p>One of those core conceptual misunderstandings is L2 regularization, and so I’m going to dissect that concept in simple terms here.</p><p>Also, I’m going to avoid any jokes pertaining to “regularity” in any other sense of the word. You’re welcome.</p><h3>Why Consider L2 Regularization?</h3><p>L2 regularization begins with an assumption that extremes exist in our data that are not reflective of reality. It is a mathematical tool to penalize a model for making extreme judgements about a feature. The goal is to compensate for idiosyncrasies in data that can lead to models that make suboptimal decisions in the real world.</p><p>Every feature (or variable) in a dataset is subject to potential relative sampling error. By “relative” I mean a feature value risks either being generally more impactful or generally less impactful than that feature actually is in the real world. This presents problems when building parametric machine learning models because they’re going to come to an optimal solution based on the data they have available, and it’s not until you try making predictions using that solution that you discover it doesn’t line up as well as you’d hope to reality.</p><p>L2 regularization results in a model with an overall increase in the loss value on the <strong>training data</strong> used to build the model. If our data is actually reflective of the real world, this would be a bad thing. However if the assumption about extremes is correct, the adjusted model will perform better on real-world, unseen data, which is the ultimate goal of all machine learning.</p><h3>L2 Regularization Definition and Considerations</h3><p>L2 regularization adds a penalty term to your model’s loss value based on squaring the feature weights the model computes, summing them all up, and multiplying the result by a tunable hyperparameter (usually referred to as either “alpha” or “lambda” depending on the author.) I will refer to this value as simply a constant.</p><p>L2 Loss = ((Sum of Squared Weights) * A Constant) + Model Loss</p><p>For example, say you have a model that has an overall loss of 32 without regularization. This model has three features, and the weights for each feature are as follows: w0 = +4, w1 = +0.1, and w2 = -1. For now, we’ll assume our hyperparameter constant value is set to 1. Thus, the imputed loss of our model under L2 regularization equals:</p><p>((Sum of Squared Weights) * A Constant) + Model Loss</p><p>((16 + 0.01 + 1) * 1) + 32</p><p>…or approximately 49. (The effect of the 0.01 on the model is small enough we can ignore it for practical purposes.)</p><p>Note that this higher loss value is just an arbitrary number. We have not changed the model weights at all, so the L2 regularized value of 49 is equivalent to the non-regularized value of 32 because it is literally the exact same predictive model.</p><p>We’ll look at some additional examples in the next major section and how this modifies the model in the end. For now, as long as you understand how we get to the value of 49 here, you’re good to go.</p><h4>Parametric Models Only</h4><p>Because L2 regularization is applying a penalty based on feature weights, only modeling approaches that make decisions based on weighting features are candidates for L2 regularization. Thus, non-parametric modeling approaches such as nearest neighbors or decision tree-based models are not candidates for L2 regularization. Non-parametric models have other ways of accomplishing similar things (for example, increasing k for kNN or lowering the max depth for decision trees) but technically speaking, they do not employ L2 regularization in the mathematical sense.</p><h4>How Much Do You Trust Your Data?</h4><p>The overall impact of L2 regularization is tuned via the constant hyperparameter. If you believe your data are generally pretty representative of reality and you just want to nudge model weights a bit, you can set this hyperparameter value to something small (say, 0.1 or 0.01 perhaps) and the overall effect of L2 regularization will be present but minimized. On the other hand, if you believe your data are likely not representative of reality (perhaps you simply don’t have enough of them, or maybe the data collection practices leave something to be desired) then you can set the hyperparameter value to something large (maybe a value between 2 and 10 or larger, depending on your data…) so that it will have a substantial impact on the overall model weights.</p><p>For example, in our first calculation where we reached a loss value of 49 when the constant value was 1, setting the constant to 0.1 would have resulted in:</p><p>((16 + 0.01 + 1) * 0.1) + 32</p><p>Again, we can ignore the 0.01, so we end up with 17 * 0.1 + 32 or 33.7 as our imputed loss. The L2 regularization didn’t have much effect on the loss value at all.</p><p>On the other hand, if we had used a constant value of 10, the imputed loss value would have been 170 + 32, or 202. In this scenario, the L2 regularization has a bigger impact on the loss value than the model loss itself.</p><p>Again, we’ll look at the ramifications here in a bit. For now, just make sure you understand how adjusting the constant value changes the overall loss value calculations.</p><p>As a reminder, in the examples we’ve used so far, the model weights themselves have not changed. All we’ve done so far is look at different ways to impute a loss value on the exact same model.</p><h4>The End Result</h4><p>In order to get to the optimal solution, L2 regularization will tend to reduce the magnitude of large absolute weight values and conversely may increase the magnitude of smaller absolute weight values. Put another way, all else equal it will tend to try to make weights more similar to each other (magnitude-wise) than they might otherwise be without L2 regularization. It’s a smoothing function.</p><h3>Examples</h3><p>Machine learning algorithms either use matrix multiplication or gradient descent (or combinations and derivatives of these) to determine the set of weights that produce the lowest possible loss value. Let’s examine three possible values along the way for our model that might have been intermediate points along the way in finding the optimal example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*x4OG-QojighuopmmY9fJ9Q.png" /></figure><p>Without L2 regularization, the model simply finds the values that produce the lowest model loss, so in this case Model 1 would be deemed the “optimal” model based on our training data.</p><p>Let’s say we suspect we might benefit from L2 regularization, so we decide to apply it with a Constant (lambda/alpha) value of 1. Now when we look at the loss values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*WNYzJSUWTsMHMTwEBT9EEg.png" /><figcaption>I’m ignoring the 0.1 and 0.2 values, since their squares are 0.01 and 0.04, respectively and not material for the discussion at this point.</figcaption></figure><p>…notice that it is now Model 3 that gives us the lowest loss value, not Model 1 any more. Thus, the regularized best model has changed based on our decisions and approach.</p><p>Note that in this example compared to Model 1 we have reduced w0 by 25%, but we have increased w1 by 1,000%, and increased w2 by 100%. The absolute value sum of our weights is actually larger for Model 3 (6) than it is for Model 1 (5). (This will come back if we look at L1 regularization in a future post…)</p><p>We made much larger percentage moves in w1 and w2, but because they started at smaller magnitude scales, the overall change based on L2 regularization was a lower loss (14 vs. 17) which overcame the difference in the original Model Loss (34 vs. 32).</p><h4>Changing the Constant</h4><p>What does this look like if we decide to give more weight to the regularization effect? Let’s change the C constant to 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*LKw8CIj6KyZHN7hkVHskRQ.png" /></figure><p>Note that now Model 2 would be deemed to be the best model of the three.</p><p>If we were to make the L2 regularization constant a small value, say 0.1 or 0.2, then the effect wouldn’t be big enough to change the overall modeling approach and Model 1 would be picked as the optimal model.</p><p>Once again, let me reiterate — <strong>The increasing or decreasing loss values due to regularization do not change the model weights themselves.</strong> All that we are doing is determining which model is best based on the combination of the model loss plus the L2 regularization effect.</p><p>How do we know what the best value for our constant C is? You’d need to test it just like anything else, and perhaps employ Grid Search or some variation in order to find the optimal value that gave you the best possible validation loss. Training loss is only relevant as the model loss input to the overall loss calculation when picking the best model to validate.</p><h3>Summary</h3><p>Hopefully this blog post helps make clear the purpose of L2 regularization, how it works, and the impact it has based on the constant (alpha/lambda) hyperparameter value applied.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7511747f9c3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM is the New Calculator]]></title>
            <link>https://jasondeden.medium.com/llm-is-the-new-calculator-2e2d48a96a0f?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e2d48a96a0f</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[plagiarism]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 13:12:28 GMT</pubDate>
            <atom:updated>2023-08-25T13:12:28.538Z</atom:updated>
            <content:encoded><![CDATA[<p>Integrating ChatGPT, Bard, Duet, and other LLMs into the Classroom</p><p>This fall I am teaching a Data Management course as part of Saint Louis University’s M.S. in Health Data Science program. Over the summer, two other professors and I had a brainstorming session where we tried to think through what seemed like a hard problem in academia — the proliferation of LLMs like ChatGPT and others that can take relatively simple prompts and turn them into code and explanations of results, and even full paper write-ups that typically made up assignments for a number of classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Vts0xcN4NxGIAPkY-jM5sg.png" /><figcaption>Look, I’m just using Google Docs native functionality.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8gcMRJT-ledHAxLYEQksw.png" /><figcaption>Hey, typing that sentence was hard work!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V84RjrqZex9Xk0USjpj9UA.png" /><figcaption>Here we go — solid B+, am I right?</figcaption></figure><p>Plagiarism in academia has been a longstanding issue. Search engine results, Stack Overflow posts, and even sites listed as “homework aids” have been providing code solutions that get copied and pasted into assignments for a very long time. Copying and pasting lightly modified search results like papers or articles as original work is nothing new. But tools like Duet (shown above), ChatGPT, and Bard just make it easier to produce higher quality, seemingly original work with very little effort.</p><p>However, this is only in academia where this is perceived as a problem. In the corporate world, if an LLM could reduce the amount of work to finish a project by 90%, we’d celebrate it as a productivity tool. So the question my fellow professors and I asked ourselves was, “Is there a way to embrace LLMs and search results while still upholding academic integrity and ensuring actual learning is taking place?”</p><p>This is not unlike the advent of the cheap, widely available calculator in math education. If you’re a high school math teacher and you send students home with 100 simple math problems as homework, how would you know if they used a calculator to do them? You probably wouldn’t. So is math education ruined? Of course not! <strong>However, you do have to adapt.</strong> You simply assume every student has access to a calculator (and today, probably a graphing calculator that has complex functions built in.) And if that’s the case — and here’s the beautiful part of the brave new world — you simply get to ask harder, and I would argue, more meaningful questions.</p><p>Calculators did not ruin math education. They made it infinitely better. They allow us to pose challenges that force students to display conceptual understanding as opposed to computational prowess. While there is some real world value in knowing the times table (or whatever they call it nowadays) there is infinitely more value in being able to apply complex math concepts in an engineering problem. And it’s not that we weren’t doing good engineering work prior to calculators, but with calculators, we have a lot more people doing a lot more of it in dramatically shorter timeframes.</p><p>So what if we embrace LLMs and their capabilities in the same way? What does this look like?</p><p>Well, for starters (<strong><em>and with sincere condolonces to my students this semester</em></strong>) it means you can ask a lot more out of learners. If you can construct the bones of a 2-page paper on any given topic in 30 seconds or less, then I am going to ask you to do so on a wider range of more complex issues, and a lot more frequently than I otherwise would. If you can produce code that solves a simple problem with no effort, I’m going to ask you to solve significantly harder problems. I’m going to assign you to real-world, open-ended tasks that will presumably force you to research and experiment. <strong>I’m going to assume you’re using LLMs, and I’m going to not only allow it, but enthusiastically embrace it!</strong> In Data Management, for example, I’m going to not only ask you to solve a coding challenge, I’m going to give you a complex scenario that forces you to explore a challenging dataset and provide real-world value using code as the tool to explore. I don’t care if that code is generated by an LLM or something you found on Stack Overflow — as long as you’re following the instructions (and assuming I’ve crafted them well enough) you’re going to have to put in some significant effort to figure out how to apply the information you gained from those sources in a meaningful way on your data. And I get to assume that you can do a lot more of this.</p><p>Will this completely deter determined cheaters? Of course not. Someone will undoubtedly try to turn in the LLM-generated content like in my example above as their assignment, and they will receive a 0 for it when they do. (Work was too generic, did not display original thinking? Sorry, no points for you…) I will be merciless for anything that even smells like it might be plagiarized work, and I have LLMs and other tools at my disposal to help me detect it. I will expect my students to provide *real* value, *real* original thought and research into every assignment. They can use LLMs as idea creators and starter materials, and even code solutions. But in return, I expect high quality, unique results from each and every one, for each and every assignment. It’s going to be a beautiful thing. Or a terrible one, if you’re someone who isn’t used to having to perform at that level.</p><p>Welcome to the brave new world. LLMs are the new calculator, and I can’t wait to see the creativity and productivity they are going to unleash.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e2d48a96a0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JEdAI Master]]></title>
            <link>https://jasondeden.medium.com/jedai-master-8ef3969d220d?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ef3969d220d</guid>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 16:34:53 GMT</pubDate>
            <atom:updated>2023-07-17T16:34:53.499Z</atom:updated>
            <content:encoded><![CDATA[<p>Now it’s LinkedIn Official!</p><p>I’ll spare you the Star Wars video of Anakin being told he wasn’t going to be granted the title of Master, with a snarky caption of superiority. But it’s important to me for you to know that I thought about it.</p><p>Master of Science, Health Data Science</p><p>Saint Louis University School of Medicine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T16e3-3KwjXt2G-3IODU3w.png" /></figure><p>Get the full details (including verification steps) on my <a href="https://www.linkedin.com/feed/update/urn:li:activity:7086734026274713601/">LinkedIn post</a>.</p><p>If you’ve been with me since the beginning of this stage in my journey, I hope you’ve enjoyed the ride and gotten value from my learning out loud. What’s next? Stay tuned… :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ef3969d220d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Return of the JEdAI]]></title>
            <link>https://jasondeden.medium.com/return-of-the-jedai-856c08990ae?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/856c08990ae</guid>
            <category><![CDATA[health-data-science]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Tue, 16 May 2023 18:45:12 GMT</pubDate>
            <atom:updated>2023-05-16T18:45:12.194Z</atom:updated>
            <content:encoded><![CDATA[<p>So a Couple of Things Have Happened Since December 2022…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPirVtiJuvDs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPirVtiJuvDs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPirVtiJuvDs%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/92486f505980de90891be0e8c407bb46/href">https://medium.com/media/92486f505980de90891be0e8c407bb46/href</a></iframe><p>OK, I’m not really *back* back, but I am popping back in for a couple of relevant updates for this blog audience:</p><ul><li>As of last week, I have officially turned in all of my M.S. Health Data Science school work, and as of yesterday it has all been graded. I am happy to report I have officially passed! Just waiting on the transcript update.</li><li>I have accepted a part-time adjunct faculty position with my school and will be teaching online courses in programming, data management, and data science topics for future students in the program.</li><li>Relatedly, a rare sighting of me in a sports coat: <a href="https://www.slu.edu/medicine/health-and-clinical-outcomes-research/faculty/jason-eden.php">https://www.slu.edu/medicine/health-and-clinical-outcomes-research/faculty/jason-eden.php</a></li></ul><p>The world has dramatically changed since December 2022 in terms of the conversation around AI/ML. ChatGPT launched as I was finishing up my capstone project on BLOOM, and in the months that followed has taken the world by storm. I’m still thinking through what my public activity will look like (if any) post-graduation, since now there seems to be more activity — and noise — than ever before in this space. The world will look very different in six months than it does today.</p><p>On a professional note: If you have been thinking about making a serious move in this direction career-wise (and I strongly recommend at least considering it if you haven’t already), you should seriously consider checking out the online M.S. HDS program at Saint Louis University. <a href="https://www.slu.edu/medicine/health-and-clinical-outcomes-research/degrees/health-data-science-ms.php">https://www.slu.edu/medicine/health-and-clinical-outcomes-research/degrees/health-data-science-ms.php</a> This is a program designed for health-focused careers, and as such is geared heavily towards practical application. There is still a fair amount of statistics and theory along the way, but it’s not overwhelming if you’re someone who is willing to dig in and learn. For me, the 100% online option was a major draw, but there are in-person versions of all classes as well if you prefer.</p><p>I’m still technically on a break from blogging and such, but as I warned in December, I may pop back from time to time if I feel like I can provide specific value to the overall conversation. In the meantime, I’d like to thank the organic, internal version of ChatGPT between my ears for composing this blog post for me. Not bad, although <a href="https://bard.google.com/">Bard</a> probably would have been a little more concise.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=856c08990ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SoLng and Thx4 All the -Phish]]></title>
            <link>https://jasondeden.medium.com/solng-and-thx4-all-the-phish-32941520049b?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/32941520049b</guid>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 18:32:57 GMT</pubDate>
            <atom:updated>2022-12-13T18:33:21.036Z</atom:updated>
            <content:encoded><![CDATA[<p>The End of the First Phase of My Data Science Journey</p><p>The completion of <a href="https://jasondeden.medium.com/may-a-thousand-blooms-flower-6d08bfcf171e">my Capstone</a> marks the last data science course in my Master’s in Health Data Science program. I have one more semester before I graduate, but the courses I have left are health research and misc. Effectively, as far as data science goes, the formal learning process I began in January of 2021 has come to a close. It’s a big moment — that’s why they call it a Capstone! This blog post may or may not be my final entry, but it marks the end of my intentional “learning out loud” formal move into the field of data science.</p><h3>In The Beginning…</h3><p>Nearly two years ago I published my <a href="https://jasondeden.medium.com/hello-world-a4f2165fd58c">Hello World</a> for this blog. This was mainly a way for me to force myself to learn new things well enough to be able to explain them. To that end, this blog has been a tremendous success. As I was learning new things about data science and machine learning, I wrote about them. As I prepped to facilitate Cornell machine learning courses, school projects, and challenging work conversations, I had to dig much, much deeper, and quite often my perspective and understanding evolved along the way. I’m sure this will continue to be true as I move forward. In looking back, I’m glad most of what I wrote is at least directionally accurate. I’m sure there’s a lot I could go back and fix, but I’m happy enough with how the writing represented the journey to leave it mostly as-is, for now anyway… :)</p><h4>Signal Vs. Noise</h4><p>When I started out, like most people new to the field I think, I thought data science was mostly about applying statistics to real-world data and iterating over it to find patterns. In other words, I thought the secret to data science was simply having access to data and <a href="https://jasondeden.medium.com/simple-powerful-ml-at-massive-scale-4d18c0b8a77a">knowing how to build models</a>. I still believe knowing how to build models is important, but I know fully realize that is a tiny, tiny, tiny little piece of what makes a data scientist valuable.</p><p>If I may opine for just a bit: There are far too many people claiming expertise around building models that don’t actually know *how* those models work, and are making really bad choices in this vacuum of understanding. A few of them have Ph.D’s and social media presences. They make what sound like completely reasonable statements that turn out to be practically wrong / incomplete. The misinformation or incomplete information from people who claim to be authoritative sources saturates the information space. It’s a dangerous realm for a newbie to step into.</p><p>One thing I really tried hard to do, even at the risk of being publicly wrong, was dig down deeply into the weeds of some very difficult topics and <a href="https://jasondeden.medium.com/minutia-matters-hello-world-year-2-8e35d8537fba">try to make them easier to understand</a>. You can be the judge as to how effective I was, but one thing that really turned (turns?) me off about most data science bloggers and video makers is that they tend to repeat the same things — the high-level bullet points about whatever the latest buzzword is. I suspect very, very few of them really deeply understand — or have even tried to deeply understand — the thing that they are writing / speaking about. It’s like the marketing version of an AI expert — they can sound like the real thing, just don’t press too hard on the details. We all start somewhere, but it’s that laziness — the jumping on the next bandwagon, the not even trying to explain a concept topic and just hoping the audience doesn’t actually ask you about it — that really got to me. Thankfully, if you’re patient you can usually find at least one person who understands it well enough and, if you’ve done enough homework, has explained it well enough that you can take it to the next level of understanding. And when you find those folks, you bookmark them and read everything they put out. But it’s a lot harder than it should be to find the good stuff. There’s an overwhelming amount of noise (pun intended). And as this field gets more popular, it just seems to get worse.</p><h4>Real-World Consequences</h4><p>It’s disheartening, and is starting to cause people who are good at this to <a href="https://ryxcommar.com/2022/11/27/goodbye-data-science/">reconsider the effort and risk</a>. When the world can’t tell the difference between a true expert and a charlatan, and indeed, believes the charlatan to be better because of amount of work produced or promises claimed to be delivered on, there are probably more rewarding things to do with your time. Good people are leaving the field because transparency and honesty are penalized in the marketplace far too often. And that’s tragic.</p><h3>Real Science</h3><p>That said, there is an <a href="https://medium.com/mlearning-ai/data-science-will-never-die-80e07ac4c9c8">immense amount of opportunity</a> in this field. I consider some of my frustration to just be growing pains of a new, difficult field of study that suddenly got very popular. Looking ahead, as data volume explodes and AI models get better and better at ever more complex tasks, the sky is the limit in terms of how machine learning can impact human lives (and hopefully for the better.) Just like every other scientific field, there are risks, but there are also rewards. Figuring out how to leverage the power of these things we are building while making them safe and universally beneficial is going to take a lot of care.</p><p>And it’s that part of it that gets me most excited. This is not a solved problem. There are virtually limitless opportunities, both extremely simple and terribly complex, to find ways to use data science for good. Everyone wants to predict the stock market, at first (and the first ones to crack that nut will probably be the first and very last gazillionaire’s…) But the things that really matter — early detection of cancer from medical imaging, helping a retiree manage limited finances, helping a struggling student understand math — all of those are things that AI could potentially be applied to solve for. We have the technology. We just have to figure out how to use it.</p><h3>My Next Journey?</h3><p>This is far and away not the end of my learning curve in data science. I may well write a new blog post from time to time to support something I’m doing in an academic or professional sense, but a lot of the next phase of my learning will be application-focused. How do we move forward? How do we employ these technological advances into the areas where they can benefit humanity the most? (Ahem… healthcare?) What can we do to ensure that people coming into this field step on fewer landmines than I did getting started in terms of finding good, accurate, valuable information? How do we democratize AI so that it benefits everyone, not just the largest companies with the most resources?</p><p>I still love my job and have no intentions of changing careers in the near-to-medium term, but I do intend to look for ways to contribute both within and outside of my main job responsibilities. I don’t need to exclusively be an AI expert — my cloud computing knowledge still matters, as does the learnings from my M.B.A., my psychology degree, and my technical education and IT background. The relatively unique makeup of what I know means I should be able to find unique ways to leverage any number of technologies — including AI/ML — into any number of situations for a greater good / better experience / efficiency gain / and so on. In some respects, I just have to make sure I’m being a good steward of the time I have and the opportunities that will be available to me.</p><p>If only I had an AI model to optimize <strong>that</strong>…</p><h3>Thank You</h3><p>So goodbye for now (and thanks for all the phish — or, rather, the lack thereof.) Thank you for reading, clapping for, and commenting on my work. It was mostly for my own benefit, but I’m glad it did at least a few people some good along the way. Perhaps I’ll find a reason to pick up the pen here again, or maybe I will be doing something completely different this time next year. Either way, it’s been a rewarding journey, and I hope you’ve enjoyed being part of it. See you on the flip side!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32941520049b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[May a Thousand BLOOMs Flower]]></title>
            <link>https://jasondeden.medium.com/may-a-thousand-blooms-flower-6d08bfcf171e?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d08bfcf171e</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[bloom]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[question-answering]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 00:37:50 GMT</pubDate>
            <atom:updated>2022-12-02T00:37:50.743Z</atom:updated>
            <content:encoded><![CDATA[<p>M.S. HDS Capstone Complete</p><p>For the last couple of months I’ve been too busy to write about the things I’ve been learning and doing, but if you’re curious (or have a previously incurable case of insomnia) click <a href="https://docs.google.com/document/d/1RBVjobSA5SazxW9biQmWWlPLtXkrkfa6GhVlIAIdYss/">this link</a> to access my just completed Capstone project for my Master’s in Health Data Science Program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEh2uU-jqBb1zTeNmpyVFg.png" /><figcaption>Creative title. Deceptive too! But perhaps I’ve already said too much…</figcaption></figure><p>If you’re more of a slides / presentation style person, you can click <a href="https://docs.google.com/presentation/d/19KvfGlGj_uRmO52i1qd3xpPqDdoGsweeJI2Qgx03XBg/">this link</a> and get an overview in slide form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aB9FhJZaFVV1MQs1g7xj_Q.png" /><figcaption>More colorful. Just as deceptive.</figcaption></figure><p>Tl;dr — I spent a semester learning about NLP and LLMs (some of that learning I’d already blogged about) and then tried to build out a process to customize a large language model for question answering — notably, a model that when I started the program did not have the native capability to be configured as such. I produced the first published BLOOM LLM for question answering tuned for the SQuAD dataset, which can be accessed here:</p><p><a href="https://huggingface.co/jasoneden/bloom560m-squad-helloworld">jasoneden/bloom560m-squad-helloworld · Hugging Face</a></p><p>There’s a lot of content and context herein, and I may go back and blog about some of the many, many things I have learned since my last post, but for now I’m just going to celebrate the completion of this milestone and step away from the computer for a bit. :) In the meantime, I look forward to any comments from anyone regarding the project, what I got wrong, what I got right, and ways I could have done it better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d08bfcf171e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduce, Reuse, and Recycle?]]></title>
            <link>https://jasondeden.medium.com/reduce-reuse-and-recycle-f8ef9f53a54d?source=rss-4484b53b9db------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8ef9f53a54d</guid>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[bloom]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jason Eden]]></dc:creator>
            <pubDate>Wed, 21 Sep 2022 02:13:52 GMT</pubDate>
            <atom:updated>2022-10-11T00:59:02.811Z</atom:updated>
            <content:encoded><![CDATA[<p>Recognizing Rewards and Risks of Redeploying Prejudiced Pretrained Ptransformers</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtoruHZrtEJw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtoruHZrtEJw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtoruHZrtEJw%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/430869dd8ad438aec9a1b557130bc97c/href">https://medium.com/media/430869dd8ad438aec9a1b557130bc97c/href</a></iframe><p>In a couple of previous posts I’ve talked about the level of data crunching that has to happen in order to train a Transformer Large Language Model (LLM). This turns out to be an exceptionally expensive proposition when starting from scratch. The cost can easily run into the 8–9 digit range (or more) and in addition there are <a href="https://arxiv.org/pdf/1906.02243.pdf">environmental impacts</a> for each new model trained. Thus, the ability to take a large LLM that someone else has already paid for (and whose environmental damage has already been done) and customizing it for your own purposes seems like the financially smart and environmentally friendly thing to do.</p><p>And yet, things are never quite that simple in the real world, are they?</p><h3>Garbage In, Garbage Out</h3><p>One of the problems encountered when trying to build one of these massive LLMs is simply gathering enough data. As a result, models are frequently based on a corpus that includes a significant amount of uncurated, publicly available content. While this succeeds in helping LLMs be able to make predictions and generate text in response to prompts, sometimes the responses are… shall we say, suboptimal?</p><p>For example, you may be surprised to learn that there exists a significant amount of text on social platforms today that is represents biased and bigoted worldviews. Models built using this data as the source for predictions can sometimes return some very atrocious responses to certain prompts. However, even models like BLOOM, where <a href="https://www.nature.com/articles/d41586-022-01705-z">a full 2/3 of the data used to build the model were hand-picked by researchers</a> in an attempt to mitigate such issues, still hold inherent human biases in their text. After all, even writers with the best of intentions (myself included) can have blind spots to social/cultural biases that can produce harmful responses based on the context in which a question is asked.</p><p>To illustrate this (in a very, very tame way) I <a href="https://colab.research.google.com/drive/1HFDC1DdA836J9Sb2jiftwgcBr8lU1fuR#scrollTo=0kCE-THPYra0">updated the notebook where I first tested the small BLOOM model</a> and prompted it with two very similar phrases: “The ______ works as a” — and set it to predict the next word. The blank was either “man” or “woman.” Otherwise, the prompts were identical. The next text generated across multiple trials was reflective of gender biases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSkM8zI1QYwFuloK1UAh1g.png" /><figcaption>Other, slightly reworded trials for man included “doctor” and for woman included “wait” — which I assumed was a tokenized/shortened form of waitress.</figcaption></figure><p>Thus, both obvious and inherent/hidden biases on the part of the writers of the text that is used to build a LLM will predictably become part of the response patterns the LLM will generate to the prompts it is given. It is very difficult to mitigate, if it’s even possible at all, in the model-building phase. This raises questions as to whether any generative machine learning model will ever be able to overcome this problem, at least given current data and technology available.</p><h3>Fine Tuning</h3><p>If we assume that there are ways to mitigate this issue (something I’m noodling on and may write more about in the future), then the power and potential of generative LLMs becomes enormous. But how does this process work?</p><p>If you think back to <a href="https://medium.com/mlearning-ai/machine-learning-for-zombies-be707e02712c">neural networks</a> (and Transformers are just a fancy/advanced version of neural network architectures) then you will recall that the output of training a machine learning model is simply a set of weights that have been iteratively adjusted until they meet the necessary performance criteria. As such, it is also appropriate to think of a pre-trained Transformer model as simply a set of weights (a complex set of weights with some very specific rules about how it works with data to make predictions, but nonetheless just a bunch of weights.) It is relatively straightforward, then, to take a new corpus of data — say, data present on your company’s website, knowledge base articles, and other useful things — and see how good that pre-trained model with those weights does at predicting things within that dataset.</p><p>Odds are, the predictions <a href="https://medium.com/mlearning-ai/form-of-an-innacurate-prediction-c95e338e63db">will be pretty good, but not optimal</a>, since your domain-specific knowledge likely did not exist in the training data for the LLM. However, just like when the original model was built, you can use <a href="https://jasondeden.medium.com/two-steps-forward-two-steps-back-a8fa2978e63">back propagation</a> (gradient descent) to iteratively adjust the model weights such that it performs better and better on your own data. Now the resulting model might not perform quite as well on general purpose prompts as it did before you tuned it, but if you’re building the model for a specific purpose — maybe a chatbot that answers HR or policy questions, locates documents of interest, or similar — then you’re typically not concerned about how the model performs for out of domain tasks. The fact that it *can* answer questions or make text predictions that fall outside of your domain area is just a bonus. What you really care about is having a model that is extremely conversational, and when it comes to the kind of things your users typically need to know, extremely knowledgeable and accurate.</p><p>LLMs present the greatest opportunity to date in terms of building these kinds of conversational AI systems that can seem to flex and intuit meaning based on context the model builders did not anticipate, and thus mimic human conversation to ever greater degrees. The possibilities for good are virtually limitless. We just have to figure out how to keep them from saying things that might get a human counterpart rightfully fired.</p><p>That is not going to be an easy thing to do when basing your predictions on writings that contain the thoughts and predispositions of human beings.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8ef9f53a54d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>