A large language model, or LLM, is a program trained on a huge amount of text. Its job sounds simple: given some tokens, predict the next one. Almost everything it does comes from repeating that one step.

Predicting the next token

Imagine the text “The cup of coffee is”. The model looks at these tokens and gives a score to every token it knows. Words like “hot” or “ready” might get high scores. Words like “bicycle” get low scores. The model then picks one.

One token at a time

Diagram: the prompt goes into the model, one next token comes out, and it is added back to the text

The model adds the chosen token to the text and runs again. This loop goes on until the answer is complete.

flowchart TD
  A["Your prompt as tokens"] --> B["Model scores every possible next token"]
  B --> C["Pick one token"]
  C --> D["Add it to the text"]
  D --> B

Training

During training, the model sees a lot of text and adjusts billions of internal numbers, called weights. Each adjustment makes its guesses a little better. After many rounds, the model has learned patterns of grammar, facts and style.

Why it can still be wrong

The model does not check facts by default. It predicts text that looks likely. Sometimes the most likely next token is wrong, and the model can write a confident answer that is false. Always check important answers from a trusted source.

Key points

  • An LLM predicts the next token, over and over.
  • Training adjusts billions of weights so the guesses improve.
  • Good output and wrong output both come from the same prediction process.