Definitionintro
Language model
Also called statistical language model.
A probability distribution over finite sequences of tokens, written by the chain rule as a product of the probabilities of each token given those before it, with an end marker.
A language model gives a probability to every finite sequence of tokens, such as the words of a sentence, the characters of a text or the bases of a DNA read, so that more likely sequences get larger values and all the values sum to 1. Almost every language model is written as a sequence of predictions: the probability of the next token given the tokens before it, with a special end token that ends the sequence. In speech recognition, spelling correction and machine translation it supplies the prior on outputs in a noisy-channel system (see source-channel speech recognition), and it is the object that n-gram models, neural networks and large pretrained models all estimate.
Definition
Fix a finite vocabulary of tokens that contains an end marker </s>, and let . A sentence is a sequence with , and . Let be the set of all sentences; it is countably infinite.
A language model on is a probability distribution on : for every and .
For a history in , the conditional probability of the next token is
where a sentence begins with only if it equals it. By the chain rule, for every sentence,
In the other direction, choose for every history a distribution on , and set . This is how models are built in practice. Then , where is the probability that the process of drawing token after token never draws </s>. So the products define a language model exactly when ; such a model is called tight. A sufficient condition is that for some and every , since then the chance of steps without </s> is at most .
Many systems also pad each sentence with a start marker <s>, which is part of every history and never predicted, and a token <unk> in that stands for every word outside the vocabulary.
Examples and non-examples
A one-word vocabulary. Let and for every . The sentence of copies of a, then </s>, gets , and . The length of a sentence is geometric.
An n-gram model. An n-gram language model sets from the last tokens of only. It has finitely many distinct conditionals, so if each of them gives </s> a positive probability, the condition above holds and the model is tight.
A neural model. A recurrent network or a transformer computes by a softmax over from a vector that depends on all of . This is the setting of causal language modeling and of generative pretrained transformers.
A DNA model. With , a model of reads gives each read a probability. Models of DNA, protein and music are language models in this sense, though the field often calls them sequence models.
Not: no end marker. If has no </s> and , then for each length the values sum to 1 over the sequences of that length. The sum over all lengths is infinite, so this is a family of distributions, one per length, and not a language model on finite sequences. Without the end marker, a model also cannot compare a sentence with a longer one that begins with it.
Not: a stop probability that falls too fast. Let for every history of length . The probability that the process never stops is
so the sentences get total probability . Each is a distribution, but the model is not tight.
Not: a masked language model. A model trained by masked language modeling gives for a position in a fixed sequence. It does not by itself give a probability to each sentence, so it is not a language model in this sense.
Not: a score without normalization. A grammar that accepts or rejects a sentence, or a score that ranks sentences, is not a language model unless its values are nonnegative and sum to 1.
Related definitions
- Causal language modeling. Causal language modeling is the training task of predicting each token from the ones before it, with the cross-entropy loss; a model trained this way is a language model in the sense above, if it is tight. The language model is the distribution; causal language modeling is a way to estimate it.
- Generative pretrained transformer. A generative pretrained transformer is one architecture for , a decoder-only transformer, together with its pretraining. It is a language model; most language models are not transformers.
- Autoregressive model. An autoregressive model is any model that writes a joint distribution as a product of conditionals in a fixed order. A language model is the autoregressive model of discrete sequences of variable length.
- Markov chain. A model whose next-token distribution depends only on a bounded part of the history is a Markov chain on the states made of that part. The n-gram model is the classic case.
- Perplexity. Perplexity measures how well a language model predicts a held-out text.
- Conditional language model. A distribution over output sentences for each input , as in translation or speech recognition, is a family of language models, one for each .
References
- C. E. Shannon, A mathematical theory of communication, Bell System Technical Journal 27(3), 1948, Part I, the approximations to English by sources that choose each letter or word from the ones before it
- Daniel Jurafsky and James H. Martin, Speech and Language Processing, third edition draft, chapter N-gram Language Models (draft of January 2026), the chain rule of probability and the end-of-sentence token
Where this leads
- Automatic speech recognition
- Autoregressive decoding
- Causal language modeling
- Contextual word embedding
- Exposure bias
- Greedy coordinate gradient attack
- Greedy decoding
- In-context learning
- Green list watermark for language models
- Length normalization
- Machine translation
- Masked language modeling
- N-gram language model
- Natural language inference
- Neural scaling law
- Noisy channel model of translation
- Nucleus sampling
- Perplexity
- Prompt injection
- Repetition penalty
- Source-channel model of speech recognition
- Temperature sampling
- Top-k sampling
- Training data extraction from language models
- WordPiece
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 5C6W3K Edit this page History Report an error Markdown