Charta is on Google Play: practise on the go. Get the app
Charta

Explain how training works for large language models and the way they produce text

CFA® Level I · Quantitative Methods · Introduction to Financial Data Science · QM.20.b

The idea

A large language model is a deep neural network trained on text. Text is split into tokens, which are words or pieces of words. In pretraining, the model reads a very large body of text and learns to predict the next token; the text itself supplies the answers, so no human labelling is needed. The pretrained model is then usually fine-tuned, including instruction tuning on curated examples of requests and good responses, and often further adjusted using human preference feedback. To answer a prompt, the model repeatedly estimates probabilities for the next token, selects one and appends it. That sampling is why identical prompts can produce different wording, and why fluent output is not the same as verified fact.

A practice question

From the question bank, with the reason each wrong option is wrong.

A large language model produces text by:

  1. retrieving whole stored sentencesWhy not: An LLM does not keep a database of sentences to look up; it generates text from learned patterns.
  2. applying hand-written grammar rulesWhy not: Its behaviour is learned from data, not coded as explicit grammar rules by programmers.
  3. predicting the next token again and again — correct

Given the text so far, the model outputs a probability for each possible next token, one is selected, it is appended, and the process repeats until the response is complete.

A harder one

The main objective during an LLM's pretraining stage is to:

  1. maximise human ratings of its answersWhy not: Tuning to human preferences comes later, after pretraining, on a much smaller data set.
  2. predict the next token in large text corpora — correct
  3. sort documents into labelled categoriesWhy not: Pretraining uses raw text without human labels; the next token itself serves as the target.

Pretraining exposes the model to very large amounts of text and trains it to predict the next token. The text supplies its own targets, so no human labelling is required.

The hardest tier

An analyst asks an LLM the same question twice and receives differently worded answers. The most likely reason is that:

  1. each next token is sampled from probabilities — correct
  2. the model was retrained between the queriesWhy not: A deployed model's weights do not change between two ordinary queries.
  3. it searched different websites each timeWhy not: A plain LLM generates text from its parameters; it does not browse unless given a retrieval tool.

Generation usually samples from the model's probability distribution over next tokens, so identical prompts can yield different wording. Settings such as temperature control how much variation occurs.

In the app: 6 practice questions on this outcome, a narrated walkthrough with diagrams, spaced review that brings it back before you forget it.

Take the free diagnostic →

More in Introduction to Financial Data Science