What Is a Large Language Model?
After this lesson, you will be able to:
- Say what a large language model does in one sentence
- Explain how counting what followed what teaches a program to guess the next word
- Say what large means for a model, using the words parameter and context
- Name three things a language model does not do, and why a smooth answer is not proof
A program that gives a chance to each possible next piece of text, given the text so far.
A language model with a very large number of adjustable numbers inside it, trained on a very large amount of text. People shorten it to LLM.
A small piece of text that the model reads and writes, such as a short word, part of a word, or a mark like a full stop.
The study period in which a program reads a huge pile of text and adjusts itself until its guesses fit that text.
One adjustable number inside the model, like a single dial. Training turns all the dials a little at a time.
All the text the model can see right now: your question plus the pieces it has already written.
#A Very Good Guesser of the Next Word
Type "See you" on your phone and it offers a few next words, perhaps "soon" or "later". It is guessing. It does not know your plans.
Before you read on, make a guess.
A phone has never been told your plans, but it still offers 'soon' after 'See you'. Where do you think the suggestion comes from?
In one sentence: a language model gives a chance to each possible next piece of text, and a large one does it with a very large program trained on a very large amount of text.
#How the Skill Is Learned: Counting What Followed What
How could a program learn which word usually follows another? The simplest way is to count. Here are three short sentences. Pretend this is everything the program has ever read.
- the cat sat on the mat.
- the cat ate the fish.
- the dog sat on the rug.
| Word after "the" | Times seen | Chance (out of 6) |
|---|---|---|
| cat | 2 | 2 of 6, about 33% |
| mat | 1 | 1 of 6, about 17% |
| fish | 1 | 1 of 6, about 17% |
| dog | 1 | 1 of 6, about 17% |
| rug | 1 | 1 of 6, about 17% |
The word "the" appeared 6 times with a word after it, so the 6 counts become 6 equal slices of a whole. "cat" has 2 slices, so its chance is the biggest. Nothing was memorised about cats. A tally was kept of what followed what.
Do the same for "sat". It appeared twice, and both times "on" came next. So after "sat", the chance of "on" is 2 of 2, which is 100%. This tiny table is a complete, working language model. It is a poor one, because it has read only three sentences, but it is the same kind of thing as the big ones.
In one sentence: training can be as simple as counting what followed what, and the counts turn into chances for the next word.
#Run It: A Language Model That Only Counts
The cell below does exactly the counting you just did by hand, then uses the chances to write. Press Run. It uses plain Python, with no extra library, so it runs right here in your browser.
Tests · Run the script. It should print the counts for 'the' (cat 2, mat 1, fish 1, dog 1, rug 1), the counts for 'sat' (on 2), then the chances 33% for cat and 17% for each of the other four, then three short sentences. The three sentences are written by chance, so they can differ if you change the seed. The checks at the end should pass without an error.
Do: Run the cell once. Then change the numbers in the linefor seed in (1, 2, 3):and run it again. Next add the sentencethe dog ate the fish .to the end oftextand run it a third time.Notice: The counts match the table you made by hand: "cat" has 2 and the other four have 1 each. The three written sentences differ from each other, and some are odd. A new sentence intextchanges the chances.Why: The program only keeps counts, and it picks the next word by chance in proportion to them. Different seeds give different picks. A drawn stand-in, not a large model: this one looks at only the one word before.
In one sentence: a counting model learns a table of what followed what, and writes by picking from that table by chance.
#Why Counting One Word Is Not Enough
The counting model looks at only the last word. That fails fast. Read this sentence.
In one sentence: a real model guesses from all of the text so far, because the meaning of a word can depend on words far back.
#Pieces, Not Words: Tokens
#What Large Means: Dials and a Reading Room
Why is it called large? Two things are large.
Most of the skill of a large model comes from two things together: many dials that can hold many patterns, and a very large amount of text to learn those patterns from.
In one sentence: large means many parameters and a lot of training text, and the context is how much the model can see at one time.
#From One Guess to a Whole Reply
One guess is only one piece. A reply is written by repeating the guess. The model guesses the next token, picks one by chance, adds it to the text, and then guesses again with the longer text. It stops when it picks a special stop token.
The top row happens once, long before you arrive, and takes a lot of time and computing power. The bottom row happens every time you ask something. Notice that the reply is built from the dials, and the huge pile of text is not consulted again.
Now watch the guess-and-pick loop in a toy. It has a small hand-written table of next-word chances, like the one you just counted.
Do: Choose the Cat starting phrase. Press Generate next word four times. Then press Reset sentence and Generate again, and press New seed to try another run.Notice: Each press adds one word, and the bars change because the next word depends on the last one. Different seeds give different sentences from the same table.Why: The model picks by chance in proportion to the bars, so likely words win often but not always. Drawn stand-in, not a trained model: the scores are hand-written for a few words.
In one sentence: a reply is made by guessing, picking, adding and repeating, and the dials do all the guessing.
#What a Language Model Does Not Do
Three things are easy to assume and wrong.
In one sentence: a language model builds likely text from its dials, does not check facts, and sees only what is in its context.
#Where This Fits
#Key Takeaways
- A language model gives a chance to each possible next piece of text, and a large one does this with a very large program trained on a very large amount of text
- Training can be as simple as counting what followed what, and the counts become chances
- A real model must read all the text so far, because the meaning of a word can depend on words far back
- Large means many parameters (dials) and a lot of training text, and the context is how much text the model sees at once
- A reply is made by repeating guess, pick, add. The model does not look up answers, does not check facts and does not remember you between chats
#Quick Check
In the three-sentence example, why is the chance of 'cat' after 'the' bigger than the chance of 'dog'?