{
  "video_id": "q-BiW5srMFQ",
  "channel_slug": "statquest",
  "channel_handle": "statquest",
  "title": "How AI works in Super Simple Terms!!!",
  "duration_seconds": 1371.0,
  "url": "https://www.youtube.com/watch?v=q-BiW5srMFQ",
  "upload_date": "",
  "transcript": "An AI might seem [music] like magic, but\nwe're going to learn how it works using\nsimple language. [music] Hooray! Stack\nQuest.\nHello, I'm Josh Starmer and welcome to\nStat Quest. Today we're going to talk\nabout how AI works in super simple\nterms. This Stat Quest is brought to you\nby the letters A, B, and C. A always B\nCurious. Always be curious. I also want\nto give a shout out to my big brother\nMike who inspired this stat quest by\nasking a few great questions.\nThese days, pretty much everyone is\nusing AI to do all kinds of cool things.\nFor example, Squatch might enter the\nprompt, write a poem about Squatch.\nSquatch is cool. Squatch is great. When\nit's time for stat quest, Squatch is\nnever late. Josh, this AI just wrote a\ncool poem about me, and it's totally\nawesome.\nHowever, I'm wondering how it works. Can\nyou explain it in such a way that even a\nbig fluffy monster like me can\nunderstand?\nI'll do my best, Squatch. We'll start\nwith a super simple example and build\nfrom there. Bam.\nImagine we had two companies and we\ncounted the number of stores they had.\nThe company on the left had five stores\nand the company on the right had 15\nstores. Then we counted up how much\nrevenue each company made. Next, imagine\nwe connected those two dots with a\nstraight line.\nNow, if someone came along and said, \"I\nheard of a new company that has 10\nstores.\"\nThen by drawing an arrow from the new\ncompany up to the straight line, and\nthen drawing another arrow from the\nstraight line over to the yaxis,\nwe could predict that the new company\nmakes 7.5 stat bucks in revenue. Using\nthe straight line and drawing arrows\nisn't a terrible way to make a\nprediction. But drawing the arrows and\nmeasuring things by hand is a little\ntedious.\nAlternatively, we could use the equation\nfor the line to do the same thing. The\nequation is a little easier to use\nbecause all we have to do is plug in the\nnumber of stores, get a computer to do\nthe math, and the output is the\npredicted revenue.\nSo in this example, we could plug in the\nnumber of stores for the new company,\n10, and then a computer does the math,\nand we get 7.5 as the predicted revenue.\nSo here we have an example of using an\nequation for a line to make a\nprediction.\nNote, before we move on, I want to point\nout that we don't need the original data\nto make new predictions.\nIn other words, after removing the two\ndata points, poof,\nwe can still use arrows from any point\non the xaxis\nto find the corresponding yaxis value\nand the predicted revenue. Likewise, we\ncan plug any point on the xaxis into the\nequation for the line, do the math, and\nget the corresponding y-axis coordinate\nand the predicted revenue. In other\nwords, the only thing we need to make a\nrevenue prediction are these two\nnumbers. The first number is the slope\nof the line and the second number is the\nyaxis intercept.\nNow, I know it might seem crazy, but the\nstraight line and its corresponding\nequation\nrepresent a very simple AI. But Josh,\nhow can you call a straight line an AI\nwhen all it does is predict revenue? A\nreal AI can write awesome poetry. That's\na great point, Squatch. However, let me\nshow you how this straight line and this\nsuper simple equation are related to the\nAI that we use to write awesome poetry.\nWe'll start by going back to the\noriginal prompt that Squatch wrote for\nthe AI. Write a poem about Squatch.\nWhen we give an AI a prompt like this,\nthen the first thing the AI does is take\nthat prompt and convert it into numbers.\nThis is because fundamentally computers\nonly work with numbers. These numbers\nare then used as an xaxis coordinate for\na graph. And the corresponding y-axis\ncoordinate corresponds to the first word\nin a poem about squatch.\nNote, if we changed the prompt from\nwrite a poem about squatch to write a\ngood poem about squatch, then we would\nend up with different numbers and a\ndifferent xaxis coordinate and thus a\ndifferent yaxis coordinate and that\ncorresponds to a different first word in\nthe poem. In other words, slightly\ndifferent prompts can give us different\npoems. Also, to be clear, the output\nisn't exactly the word once. Instead,\nit's just a high probability that it\nwill select the word once over other\nwords. In this case, there's a high\nprobability that the AI will output the\nword once, but it might output something\nelse instead. By having a little\nvariation in the output, the AI can seem\na little more human since we don't\nalways say the same things either.\nAnyway, going back to the original\nprompt and the original output, we can\nthen add the first word in the poem to\nthe original prompt, convert the words\ninto numbers, use the numbers as an\nx-axis coordinate, and then find the\ncorresponding y-axis coordinate, and\nthat ends up being the second word in a\npoem about squatch.\nTo predict the next word in the poem, we\nadd the predicted words to the original\nprompt. Convert the words into numbers.\nUse the numbers as an x-axis coordinate.\nFind the corresponding yaxis coordinate.\nAnd that ends up being the third word in\nthe poem.\nLikewise, the remaining words in the\npoem are predicted by finding their\ncorresponding y-axis coordinates.\nJosh, I find it hard to believe that's\nall there is to it. If all AI needed was\na straight line, then why do we have\nhuge data centers to run it? That's a\ngreat question, Squatch.\nNow that we know the main idea that an\nAI converts your prompt into an x-axis\ncoordinate and then uses the\ncorresponding y-axis coordinate to\ngenerate the output. We can talk about\nthe differences between this straight\nline and the AI you use to write poetry.\nFirst, our straight line started out as\njust two data points. In contrast, the\nAI that writes awesome poetry starts out\nwith trillions of data points. Josh,\nthat's not even 50 points. Squatch,\nthere's no way I'm drawing trillions of\npoints, so you'll just have to use your\nimagination.\nOkay. Anyway, when we only have two\npoints, the best we can do is fit a\nstraight line to them. In contrast, when\nwe have trillions of data points, we can\nfit a much more complicated shape to the\ndata. In other words, instead of a super\nsimple equation for a straight line like\nwe had before,\nthe AI uses a much more complicated\nequation.\nOh no, it's the dreaded terminology\nalert. When we fit a straight line to\ndata, we have to find a good value for\nthe slope, which in this example ended\nup being 0.5.\nAnd we have to find a good value for the\ny-axis intercept, which in this example\nended up being 2.5.\nThese two values that define the line,\nthe slope and the y-axis intercept are\ncalled parameters.\nSo we would say that the straight line\nhas two parameters.\nIn contrast, our fancy poetry writing AI\ncan have trillions of values that we\nmultiply and add to the input. And\nbecause each value that we multiply and\nadd to the input is called a parameter,\nour big fancy poetry writing AI can have\ntrillions of parameters.\nSo the next time ChatGpt or DeepSeek or\nGrock or whatever releases their next\nbig AI and they say our new AI has 2.3\ntrillion parameters, what they're\nbasically telling you is how big their\nfancy equation is for writing poetry.\nNow let's summarize the first main idea\nof how AI works. We start out with\ntrillions of data points. Then we fit a\nbig fancy shape to the data which we can\nwrite out as a big fancy equation. And\nonce we have the equation, we can get\nrid of all of the original data. Poof.\nThen when someone gives the AI a prompt\nlike write a poem about squatch, the AI\nstarts by converting the prompt into\nnumbers which are used as an x-axis\ncoordinate or input value to the big\nfancy equation. Then we do the math to\nget the y-axis coordinate or output\nvalue and the output corresponds to the\nfirst word in our poem. Bam.\nOkay, I think I'm starting to understand\nhow AI works. But where does all the\ndata come from? And how do we fit a\nshape to it? Great question, Squatch.\nAnd to answer that, we need to learn how\nto build an AI.\nIf we want to build an AI, then we're\ngoing to need some data. And at the\nstart, we don't have any. So, the first\nthing we need to do is give the AI some\ndata. Most of the data used to build an\nAI comes from really large bodies of\ntext like the entire Wikipedia and all\nof GitHub and pretty much everything\nelse on the internet you can get your\nhands on without being sued. And then we\nuse that data to build an AI that can\npredict individual words.\nFor example, we could start with the\nvery first Wikipedia article which is\nabout something called ah and use the\nfirst four words ah was a Japanese as an\nxaxis coordinate\nand pair those words with the y-axis\ncoordinate for the next word girl.\nCombined the xaxis coordinate and the\ny-axis coordinate give us a specific\ndata point on our graph. The idea is\nthat we want to get the AI to take ah\nwas a Japanese as a prompt then do some\nmath\nand ultimately predict the next word\ngirl.\nLikewise, we might use was a Japanese\ngirl as an x-axis coordinate and pair\nthose words with the y-axis coordinate\nfor the next word group.\ncombined the x and yaxis coordinates\ngive us another data point on our graph.\nAnd the idea is that we want to get the\nAI to take was a Japanese girl as a\nprompt, then do some math and predict\nthe next word group.\nAha. Ah, was a Japanese girl group. You\ngot it, Squatch. Anyway, we would just\nkeep on using fragments from Wikipedia\narticles to create a data set until we\ngot to the end of the very last article\non Z Grillil. And we would use of\nhorizontal points has been as the xaxis\ncoordinate and changed the final word in\nthe Wikipedia as the yaxis coordinate.\nAnd those two coordinates would give us\nthis point on our graph. Ultimately,\nwe'd end up with trillions of data\npoints.\nNow that we have lots of data, we need\nto fit a shape to the data. In other\nwords, we want to create a big fancy\nequation that ultimately can write\npoetry. The bad news is that the shape\nand the equation don't just magically\nappear. Instead, figuring out the shape\nand the equation takes a ton of\ncomputing time, which takes a ton of\nelectricity,\nwhich costs a ton of money. So, let's\ntalk about how this process works. Oh\nno, it's another terminology alert.\nFiguring out the shape and the\ncorresponding equation is called\ntraining. Now, let's learn how training\nworks. So, we start out with our data\nand then believe it or not, we just fit\na random shape to it. I guess you have\nto start somewhere. That's right,\nSquatch. So, in this case, we start with\na random shape. And that random shape\ncorresponds to a big fancy equation that\nhas random parameters. In other words,\nat the very start, we just pick some\nrandom numbers and use those as the\nparameters for our big fancy equation.\nNext, we measure the distance between\nthe data and the random shape. For\nexample, we would measure the distances\nbetween this point and the random shape\nand this point and the random shape and\nultimately measure the distances between\nall of the trillions of points and the\nrandom shape. Based on those distances,\nwe then adjust the trillions of\nparameters in the big fancy equation\njust a little bit. And as a result of\nthose small changes in the parameters,\nwe get a shape that fits the data a\nlittle better than before. Then we\nrepeat that process. We measure the\ndistances from the trillions of data\npoints to the line and then adjust the\ntrillions of parameters a little bit.\nAnd as a result of those small changes,\nthe shape fits the data a little better\nthan before. Then we just keep repeating\nthe process until we get a shape that\nminimizes its distance from the data.\nNote the reason we fit the shape to the\ndata a little bit at a time instead of\nall at once is that the big fancy\nequation is just too big and fancy to\nsolve easily. Thus, the second main idea\nof how AI works is that we use a\nstepbystep method to fit a shape to a\nhuge data set. Double bam.\nNow, just to be clear, this big fancy\nequation is all we need to draw the\nshape that we fit to the data. And that\nmeans we can toss out the original data.\nPoof.\nAs a result, we end up with just a big\nfancy equation that represents the\nshape. Note, because we have trillions\nof data points and trillions of\nparameters to adjust, this initial\ntraining needs a ton of computing power\nand is very expensive. The good news is\nthat so far we've done the hard and\nexpensive part. The bad news is that our\nAI still isn't ready to write poetry.\nEven though we have fit a shape to the\ndata and we have the corresponding big\nfancy equation,\nright now our AI is only good at taking\nbits of Wikipedia articles and\npredicting the next word.\nFor example, right now our AI can take\nof horizontal points has been and after\ndoing the math correctly predict the\nnext word changed.\nHowever, of horizontal points has been\nis way different from the prompt write a\npoem about squatch and the output word\nchanged might just be the worst poem\never written. So even though we have\ndone a lot of work, used a lot of\nelectricity, and spent a lot of money on\ntraining our AI, there's still some work\nto do. And this work is called\nalignment.\nAlignment consists of training the model\nto generate reasonable responses to\nnormal prompts like what's a good\nYouTube channel for learning about AI?\nIn other words, even though we have\ntrained our AI to correctly predict\nwords in Wikipedia articles, that's\ndifferent from getting the AI to\nproperly respond to the types of prompts\nthat most people give it, like what's a\ngood YouTube channel for learning about\nAI.\nSo, we need to align our model from\nwhere it is right now, predicting words\nin Wikipedia articles, to where we want\nit to be, responding to prompts like\nthis.\nThe good news, however, is that we don't\nneed a lot of data for alignment. And\nthat means relatively speaking,\nalignment is fast and cheap to do. The\nother good bit of news is that the\nprocess for aligning the AI is very\nsimilar to what we did before.\nFor example, given the prompt, what's a\ngood YouTube channel for learning about\nAI?\nThe AI converts that to an Xaxis\ncoordinate. Then the AI does the math to\nget the y-axis coordinate, which because\nwe haven't yet aligned the AI,\ncorresponds to a pretty lame response.\nHorizontal.\nIdeally, we would prefer the AI to\nsuggest that Stack Quest is a good\nYouTube channel to learn about AI. And\nthe yaxis coordinate for stack quest is\nhere a little higher than the y-axis\ncoordinate for horizontal.\nSo we adjust the parameters in the big\nfancy equation just a little bit because\nwe don't want to undo all of the\ntraining we did earlier and that changes\nthe shape a little bit and that gets us\na little closer to the ideal output\nstack quest. So we change the parameters\na little bit more.\nAnd that changes the shape a little bit\nmore. And now the AI outputs our desired\nresponse. Stat quest. This is awesome.\nOur AI is now responding correctly to\nour prompt. However, we're not done yet.\nNow we add the output to the original\nprompt and convert all of that the\nprompt plus the output from the AI into\nan Xaxis coordinate.\nThen do the math to get the\ncorresponding y-axis coordinate, which\ngives us Wait, I think I can predict\nwhat will come next. Bam. I knew it.\nBecause we got what we wanted, we're\ndone aligning.\nAnd that means this is the final shape,\nwhich corresponds to this, the final big\nfancy equation.\nNow, when Squatch enters the prompt,\nwrite a poem about Squatch,\nthe AI converts the prompt into an Xaxis\ncoordinate, does the math to determine\nthe y-axis coordinate, and that ends up\nbeing the first word in a poem about\nsquatch.\nLikewise, the rest of the poem about\nsquatch is generated by the AI, which\nfundamentally is just a big fancy\nequation. Bam. So, we've just seen how\nwe can take an AI that starts out only\nbeing able to predict individual words\nin the Wikipedia\nand align it so that it can now answer\nquestions and write poetry.\nHowever, because it's relatively\ninexpensive to align an AI, it's common\nto use alignment for specialized things.\nFor example, starting with the same\npre-trained AI that can only predict\nwords from the Wikipedia,\nwe could align it to help write computer\ncode or be a customer service bot for a\nwebsite or solve complicated math\nproblems. Thus, the third main idea of\nhow AI works is that it is aligned to do\ndifferent tasks. Triple bam.\nNote, this stat quest only focuses on\nthe three main ideas of how AI works.\nHowever, if you'd like to know the\ndetails, check out these quests. Now,\nit's time for some shameless\nself-promotion.\nIf you want to review statistics,\nmachine learning, and AI offline, check\nout the StackQuest PDF study guides, and\nmy best-selling books on machine\nlearning, neural networks, and AI, and\nstatistics at stackquest.org.\nThere's something for everyone. Hooray!\nWe've made it to the end of another\nexciting Stat Quest. If you like this\nStat Quest and want to see more, please\nsubscribe. And if you want to support\nStat Quest, consider contributing to my\nPatreon campaign, becoming a channel\nmember, buying one or two of my original\nsongs or a t-shirt or a hoodie, or just\ndonate. The links are in the description\nbelow. All right, until next time. Quest\non.",
  "transcript_chars": 17094,
  "ingested_at": "2026-05-15T10:52:45.917564+00:00",
  "source": "channel",
  "yt_meta": {
    "view_count": 29212,
    "like_count": 1150,
    "channel_id": "UCtYLUTtgS3k1Fg4y5tAhLbw",
    "categories": [
      "Education"
    ],
    "tags": [
      "Josh Starmer",
      "StatQuest",
      "Machine Learning",
      "Statistics",
      "Data Science"
    ]
  }
}