Concepts / Evaluating Large Language Models

Evaluating Large Language Models

The chapter's plan has three parts: stage 1 covers data preprocessing and the attention mechanism, stage 2 covers coding and pretraining a GPT-like LLM, and evaluation of LLMs follows.

  • Programming

Guessing the Next Word

Many people have used a phone keyboard that suggests the next word as they type. You begin a message, and the keyboard offers a few words that are likely to come next. That habit of guessing what follows a given stretch of text is the same habit at the heart of a large language model. This article uses that habit as the starting point for understanding what an LLM is, what the word large means, and how training turns simple guesses into a capable system.

The article also places this idea inside a larger plan. Building a large language model from scratch is not one task but a sequence of connected tasks, and a good way to begin is to ask what must be ready before anything else can happen. Keep that question in mind as you read.

The Three-Stage Roadmap

The chapter's plan can be divided into three parts, each with a clear purpose. Stage 1 covers the fundamental data preprocessing steps and the attention mechanism. Stage 2 moves from understanding to construction: it teaches how to code a GPT-like LLM and pretrain it so that it is capable of generating new texts. The third part concerns evaluation of LLMs, which is described as essential for developing capable NLP systems.

Stage 1:Preprocessing andattentionPrepare the materialStage 2: Coding andpretrainingBuild a GPT-like LLMStage 3: EvaluatingLLMsJudge the systemCapable NLP systemThe overall goalprepares the ground forleads intosupports
How data preprocessing and attention, coding and pretraining a GPT-like model, and evaluation connect in sequence toward the overall goal.

The diagram is a simplified reading of the plan rather than a technical design. Its purpose is to show the direction of travel: preparation and the attention mechanism lead into building and pretraining, and building leads into evaluation. Read this way, the roadmap is less a list of unrelated topics and more a path in which each stage prepares the ground for the next.

What do you think happens?

Before reading further, predict the order in which the big topics appear in the roadmap.

  • Evaluation first, then building the model, then preprocessing

  • Preprocessing and attention first, then coding and pretraining, then evaluation

  • Coding and pretraining first, then preprocessing, then evaluation

Reveal answer
Answer:

Preprocessing and attention first, then coding and pretraining a GPT-like LLM, then evaluation of LLMs.

The plan moves from getting the material ready, to building and pretraining the model, to evaluating it. Each stage depends on the one before it.

Why Data Preprocessing Comes First

Data preprocessing is the first topic the plan names, and it is marked as core material. The plan describes it as learning the fundamental steps of preprocessing data for LLMs. The word fundamental matters here: the plan is teaching the basic steps that every such effort relies on, not a specialized trick for one model.

The attention mechanism is introduced in the same first stage as preprocessing and is described as being at the heart of every LLM. Because the later stages build a model and then pretrain it, the prepared data and the attention mechanism are what those later stages depend on. Preprocessing therefore sits at the start of the roadmap because nothing downstream can happen until the material is ready.

What a Large Language Model Is

Definition

A large language model is a deep neural network designed to understand, generate, and respond to humanlike text.

Three parts of that definition do most of the work. The first is that an LLM is a neural network, which means it is a learned mathematical system made of many connected adjustable pieces, not a hand-written list of rules about grammar. The second is that it handles text, so its inputs and outputs are language. The third is that it is designed to do this in a humanlike way, meaning its output is meant to read naturally and respond to what was written.

The phrase deep neural network signals that the network has many layers of processing. That depth is what allows the model to pick up subtle patterns across a long passage instead of just adjacent words.

An LLM is trained on massive amounts of text. In some cases that training text can cover large portions of the entire publicly available text on the internet. A model that only saw a few thousand sentences could not learn the wide variety of patterns that the largest models pick up.

Two Meanings of Large

The word large in the name carries two separate meanings. Both are about scale, but they measure different things. Once you can tell them apart, it becomes easier to reason about what makes a model powerful and what goes into building one.

Largein Large Language ModelNumber of parametersthe size of the modelTraining datasetan immense body of textfirst meaningsecond meaning
How the size of the model (parameter count) and the size of the training data each contribute to what large means.

Parameters as Adjustable Weights

Parameters are the adjustable weights inside the network. Imagine a large mixing board in a recording studio with thousands of sliders. Each slider sets how much one signal contributes to the final sound. Training is the process of moving the sliders until the output matches what you want. In an LLM, the sliders are the parameters, and the thing you want the output to match is the next word in a sequence.

The mixing board is an analogy, not a technical description. What the source establishes is that parameters are optimized during training so the model can predict the next word in a sequence. Starting from that, the next question is why next-word prediction is the task used to set them.

Next-Word Prediction as a Training Task

The task used to train these models is next-word prediction. The model is shown a sequence of words and asked to guess the word that comes next. Language is naturally sequential: each word arrives after the ones before it, and meaning builds up as the sequence unfolds. Next-word prediction takes advantage of that order, so that learning to guess well forces the model to pick up context, grammatical structure, and the relationships between words.

The model does not need a teacher to label each sentence with its meaning. The next word in the text itself serves as the answer. This is why the text can be so plentiful: every position in a passage becomes a small prediction exercise.

A natural reaction is suspicion. Guessing the next word sounds far too modest to produce a system that can understand and respond to text. Yet this is one of the more surprising facts in the field: a task this simple has produced models that are remarkably capable. The source notes that this surprised many researchers.

Tracing One Prediction into a Training Signal

Read the training loop from left to right. The text supplies context, the model makes a guess, and the guess is compared with the word that actually follows in the text. The result feeds back into the parameters, nudging them so that future guesses improve. Repeat this across an enormous amount of text and the parameters gradually settle into values that capture a great deal about language.

Text contextwords before the gapModel's guesspredicted next wordActual next wordtaken from the text itselfCompare guess andactualhow far off?Error valuethe training signalAdjust parametersnudge the weightsBetter future guessesrepeat over more textfed into modelcompared withcompared withmismatch becomesfeeds backimproves
What happens step by step from the model's predicted next word to the error value that updates the parameters.
Worked example

Tracing one next-word prediction

The text fragment 'The sun rises in the' is shown to the model, and the word that actually follows in the text is 'east'. Trace how this one prediction becomes a training signal.

  1. 1
    Read the context

    The model receives the words before the gap: 'The sun rises in the'. This is the input for this one prediction.

  2. 2
    Make a guess

    The model, using its current parameters, produces a predicted next word. Suppose it guesses 'west'.

  3. 3
    Check against the text

    The word that actually follows in the text is 'east'. No teacher is needed; the text itself provides the answer.

  4. 4
    Measure the mismatch

    The guess and the actual word differ, so an error value is produced that records how far off the guess was.

  5. 5
    Adjust the parameters

    The error feeds back into the parameters, nudging them so that a similar context is more likely to yield 'east' next time.

Result

One prediction produced one error value, and that value moved the parameters. Repeating this over a very large body of text is how the parameters settle into values that capture language.

This article only defines the concept and the task. The source notes that the step-by-step training procedure is covered in later chapters, so treat the loop above as a map of the idea rather than a full implementation.

Mistakes Beginners Make

  • Common mistake

    Treating the training text and the trained network as the same thing

    Why it fails

    The text is the material the model learns from during training. The network is the structure that ends up holding what it learned.

    Do this instead

    Keep the two separate: the text is the input to training, and the parameters are where the learning is stored.

  • Common mistake

    Assuming that large refers only to the size of the model

    Why it fails

    The word large has two meanings: the number of parameters and the immense dataset used for training.

    Do this instead

    When you describe an LLM, name both kinds of scale.

  • Common mistake

    Dismissing next-word prediction as too simple to matter

    Why it fails

    Learning to guess the next word well forces the model to pick up context, grammatical structure, and relationships between words.

    Do this instead

    Judge the task by what it forces the model to learn, not by how simple its description sounds.

  • Common mistake

    Thinking evaluation is an optional extra added after the real work

    Why it fails

    The plan treats evaluation of LLMs as essential for developing capable NLP systems and as a core piece of the roadmap.

    Do this instead

    Treat evaluation as part of the path toward a useful system, not as an afterthought.

Checking Your Understanding

EASY

Using the phone keyboard analogy from the start of this article, explain in your own words what the model is doing when it predicts the next word, and identify what the actual next word in the text contributes to training.

Hints
  • Think about what the keyboard offers after a stretch of text, and what the model does with that same kind of guess.
  • Consider where the answer comes from: does the model need a human label, or does the text itself supply it?
  • Connect the comparison between guess and actual word to the error value and the parameter update.

Key Takeaways

  • The roadmap for building an LLM from scratch has three stages: data preprocessing with the attention mechanism, coding and pretraining a GPT-like LLM, and evaluating LLMs as essential for capable NLP systems.
  • A large language model is a deep neural network designed to understand, generate, and respond to humanlike text, and it is trained on massive amounts of text.
  • The word large refers both to the number of parameters in the model and to the immense dataset used to train it.
  • Next-word prediction is the training task: the text supplies the answer, and each prediction's error value adjusts the parameters so that future guesses improve.

Related concepts

More concepts starting with E