What is a large language model (LLM)?
The engine behind chatbots turns out to run on a single, repeated prediction
What is a large language model?
A large language model, or LLM, is a neural network trained on huge amounts of text. It generates language by predicting one word at a time. GPT-3, described by Brown et al. (2020), is an autoregressive language model with 175 billion parameters, the adjustable numbers that store what it has learned. Llama 2, released by Touvron et al. (2023) in sizes from 7 billion to 70 billion parameters, is built the same way: an auto-regressive transformer trained on a large corpus of text.
Both papers describe the same basic machine. Feed it a stretch of text and it outputs a probability for every possible next word, or token, in its vocabulary. Generation just means doing this repeatedly, each new token added to the input before predicting the next.
How does next-token prediction work?
Next-token prediction is the training task at the centre of an LLM: given everything written so far, guess the next token. GPT-3 is trained this way on a mix of Common Crawl web data, an expanded WebText dataset, two books corpora and Wikipedia, totalling hundreds of billions of tokens (Brown et al., 2020). Llama 2 is trained on 2 trillion tokens of publicly available data. Touvron et al. (2023) say the corpus was deliberately up-sampled toward factual sources to curb hallucination.
Brown et al. (2020) note that performance follows a smooth power-law with the amount of compute used for training. They extend this trend by two further orders of magnitude beyond earlier work, with only slight deviation. Llama 2's training loss kept falling through 2 trillion tokens. Touvron et al. (2023) report no sign of saturation even at that scale.
Pretraining vs post-training: what's the difference?
Pretraining is the stage where a model learns next-token prediction from raw text at scale, with no task-specific labels. Post-training comes after, and reshapes a pretrained model into something useful to talk to. Llama 2-Chat, the dialogue-tuned version of Llama 2, goes through two post-training stages, per Touvron et al. (2023). First comes supervised fine-tuning on roughly 27,540 hand-written prompt-and-answer examples. Then comes reinforcement learning with human feedback (RLHF).
RLHF trains a separate reward model on human comparisons between pairs of model responses. It then uses that reward model to push the chat model toward answers people prefer. Touvron et al. (2023) trained two reward models, one for helpfulness and one for safety, because the two goals can pull in different directions. GPT-3, by contrast, was evaluated only as a pretrained model; the paper leaves fine-tuning it to future work.
What is in-context learning?
In-context learning is a pretrained model's ability to pick up a new task from examples placed directly in its prompt, with no change to its weights. Brown et al. (2020) describe it as the inner loop of a broader meta-learning process. During pretraining the model develops a wide set of skills. At inference it uses them to adapt on the fly. They test GPT-3 under three conditions: zero-shot, with only an instruction; one-shot, with a single example; and few-shot, with as many examples as fit in the model's context window, typically 10 to 100.
Larger models get more out of this. Brown et al. (2020) found that aggregate few-shot performance across 42 accuracy-denominated benchmarks rose more steeply with model size than zero-shot performance. The gap between the settings widened as models grew. On LAMBADA, a benchmark that asks a model to complete a sentence's final word, GPT-3 scored 76.2% zero-shot but 86.4% few-shot, against a prior state of the art of 68.0%.
How good are these models, by the numbers?
GPT-3's few-shot results sometimes matched or beat fine-tuned, task-specific models despite never updating its weights. On TriviaQA it reached 71.2% accuracy few-shot, which Brown et al. (2020) call state of the art among closed-book models at the time. On CoQA it rose from 81.5 F1 zero-shot to 85.0 F1 few-shot, still short of the fine-tuned state of the art on some other benchmarks, such as HellaSwag.
Llama 2 70B, evaluated as a base model rather than in-context, scored 68.9% on the MMLU knowledge benchmark. That is close to GPT-3.5's 70.0% but well behind GPT-4's 86.4%, per Touvron et al. (2023). After post-training, Llama 2-Chat's helpfulness was judged against other chat models by human raters and separately by GPT-4. Meta reports it performs on par with some closed-source systems on those evaluations.
What are the limits of today's LLMs?
Both papers flag real gaps. Brown et al. (2020) found GPT-3's few-shot performance struggled on natural language inference tasks such as ANLI, and on reading comprehension sets like RACE and QuAC, even at 175 billion parameters. They also had to build tools to detect data contamination, since web-scraped training sets can accidentally contain benchmark test questions. A filtering bug meant some overlap slipped through regardless.
Touvron et al. (2023) are candid that Llama 2 70B still trails GPT-4 and PaLM-2-L by a wide margin on most benchmarks, and lags notably on coding tasks. Llama 2's own safety evaluations, they note, were conducted only in English and carry evaluator bias. The models still need application-specific safety testing before deployment.
Key terms
- Large language model (LLM)
- A neural network trained on large amounts of text that generates language by predicting the next token.
- Next-token prediction
- The training objective where a model learns to guess the next word, or token, given everything written before it.
- Pretraining
- The initial stage of training an LLM on a broad corpus of text with no task-specific labels.
- Post-training
- The stages applied after pretraining, such as supervised fine-tuning and reinforcement learning with human feedback, that adapt a model for dialogue or other uses.
- In-context learning
- A pretrained model's ability to perform a new task from instructions or examples given in its prompt, without any gradient updates.
- Few-shot, one-shot, zero-shot
- Settings that vary how many task examples, from several down to none, are given to a model at inference time.
- Reinforcement learning with human feedback (RLHF)
- A fine-tuning procedure that uses a reward model trained on human preference comparisons to align a language model's outputs with what people prefer.
- Parameters
- The adjustable numerical weights of a neural network that are set during training and determine what it has learned.
Latest developments
Written from
Large language models in the news
LLMs infer ethnicity from names more accurately than BISG
A withdrawn paper shows models can profile race without training data
IBM packs chat, decisions and speech into one Granite endpoint
Granite Switch 4.1 adds adapters, not GPUs, to cover three task types
Study: API benchmarks don't match chatbot app performance
Researchers say the gap can equal a full model version downgrade
Written from the documents above by The Neural Net’s automated desk (claude-sonnet-5, theneuralnet/guides@1) without human review, and updated as news on this topic publishes. How this works.