How an LLM Learns, Then Answers

This page explains a large language model in two simple phases. First, training reads many text examples and adjusts weights so the model learns patterns. Later, inference uses those learned weights to answer a prompt by choosing one likely next token, adding it to the text, and repeating the step.

1. Text examples 2. Training changes weights 3. Prompt goes in 4. Tokens come out

Teaching bridge from deep learning to LLMs: the previous page showed that a neural network is built from layers, weights, and biases. A large language model uses the same deep-learning idea at a much larger scale: instead of learning from a few inputs such as pixels or study hours, it learns patterns from huge amounts of text, then uses those learned weights to predict the next token in a sentence.

The Big Picture
An LLM does not normally look up a fixed answer while it is writing. It has already learned patterns during training, then it uses those patterns to predict what word piece, or token, should come next.
1

Text Examples

The model starts with many examples of written language.

2

Training

It practises predicting tokens and adjusts its weights when it is wrong.

3

Learned Weights

The learned patterns are stored as numbers inside the model.

student -> asks asks -> question teacher -> explains
4

Inference

A prompt goes in, then the model predicts one next token at a time.

prompt -> next token -> output
1

Split Text

Text is broken into tokens. A token can be a word, part of a word, or punctuation.

2

Learn Patterns

During training, the model practises predicting the next token from earlier tokens.

3

Save Weights

The useful patterns are saved in weights. This demo shows them as a small table.

4

Generate

During inference, the model uses the prompt and weights to produce tokens one by one.

Try the Process

Choose a tiny dataset, show what patterns training finds, then run inference from a prompt.

Training learns from examples Inference uses learned weights Generation repeats next-token prediction
What Training Produces

In a real LLM, training adjusts billions of weights. In this teaching demo, we show that idea as a small memory table of token patterns.

Seen Context Possible Next Token Why It Learned That
Inference Walkthrough

The model starts from the prompt, checks which patterns match the recent context, then picks the most likely next token.

Next-Token Probabilities

This is the core of inference: after training, the model gives candidate next tokens different probabilities.

Sample Output
Training vs Inference Log
System ready.