Back
beginner

AI Fundamentals

What is a large language model actually doing?

Trace next-token prediction and separate fluent text generation from knowledge, retrieval, and application behavior.

Lesson 7 of 31About 20 min with practice

Complete this sentence: “Before leaving the house, I checked that the door was ...” Several endings fit. “Locked” is plausible. “Purple” is possible in a different story. A language model produces a numerical preference over possible continuations, conditioned on the context it receives.

Before you begin: Understand tokens as numbered text units and neural networks as learned transformations.

A prediction becomes a sequence

A language model assigns probabilities to text. Many chat models generate a response one token at a time: process the available context, calculate scores for possible next tokens, select a token, add it to the sequence, and repeat until a stopping condition is reached.

The parameters are the learned numerical values used in that computation. They are distinct from the words in the current conversation. A large language model, or LLM, has a large learned representation and is typically trained on substantial text data. There is no universally decisive parameter threshold that turns every language model into an LLM.

Consider a fictional next-token distribution after “The library closes at”: “five” has probability 0.5, “six” 0.3, and other tokens together 0.2. Choosing “five” says something about the model's prediction. It does not establish the actual library closing time. The correct answer requires evidence about that library.

How does prediction support useful work?

Learning to predict text can encourage a model to represent spelling, syntax, relationships, and many patterns found in its training data. A request such as “Summarize this paragraph” also forms a text context. Training and later adaptation can make a useful summary a likely continuation of that context.

The model is not limited to selecting complete sentences it has previously seen. It composes new sequences. But novel text can still contain copied phrases, memorized material, incorrect combinations, or fabricated details. Neither “it only copies” nor “it understands everything it says” is a sound general description.

Pretraining builds broad capabilities from a prediction objective. Post-training adapts behavior, for example using demonstrations or preference feedback. An assistant product then adds instructions, conversation handling, tools, and an interface. These stages answer different questions: what patterns can the model represent, how is it encouraged to respond, and what can the application do?

Ask where an answer came from

Give an assistant this invented notice: “The reading room closes at 17:30 on Thursday.” Ask when it closes. The model can use the supplied text. Ask who painted the room, and the notice no longer contains enough information.

A useful response to the second question should identify the gap. A confident artist's name would be an unsupported completion. A generated claim that is false or unsupported in its context is often called a hallucination. The term describes an output problem; it does not imply a human-like perceptual experience inside the model.

When a product searches or retrieves documents, inspect the source supporting the claim. Retrieval can improve access to evidence, but the system may retrieve the wrong page, misread the right page, or omit an exception.

Why can the same question get different answers?

Some generation methods select the highest-scoring next token. Others sample from a distribution, allowing variation. Settings such as temperature may change sampling behavior when the model and API support them. Lowering temperature does not create missing knowledge or guarantee truth.

Outputs can also change because the application supplied different context, the provider updated the model, a tool returned different data, or the runtime behaved differently. Record the relevant conditions when you compare answers. Repeating a prompt alone is not always a controlled experiment.

Try a boundary test

Use the short notice above. Ask for three things: the stated closing time, a one-sentence paraphrase, and the name of the painter. Mark each response as supported, a faithful transformation, or unsupported. If the assistant invents a painter, add: “Use only the notice; say when the answer is missing.” Repeat in a fresh conversation.

Interpret the experiment

The closing time is explicitly supported. A paraphrase can be checked against the original meaning. The painter is not provided, so a name would need another source. If the revised prompt helps, you have improved behavior on this example. You have not proved the model will always respect the evidence boundary. Include other missing-answer examples before relying on it.

The next lesson explains the learning process behind these predictions and why chatting with a model is different from updating its weights.

Further reading

Language Models are Few-Shot Learners studies broad tasks through language-model prompting. The original InstructGPT paper illustrates a later stage of training for instruction-following behavior.

Continue to the next lesson.

Practice for this lesson

Test where an answer came from

Distinguish text produced from learned patterns from text grounded in evidence you supplied.

About 8 min40 points3 checks and one written task
Loading your lesson progress...