What is a language model?

A language model is a model that learns a probability distribution over sequences of text and predicts the next unit, which lets it score or generate text.

It is often shortened to LM. It differs from a large language model in scale: language model is the general concept and includes small statistical models, while an LLM is the subtype trained with many parameters on broad data. It is not a knowledge base; it produces likely text.

Topic
Core concepts
Also known as
LM, statistical language model
Origin
1948, Shannon (statistical language modelling); neural language model 2003, Bengio et al.

How a language model works

The model reads text as a token sequence and computes a probability distribution over the next token at each position. Autoregressive models do this left to right and generate text; masked language models learn to predict hidden tokens from context on both sides and are used mostly for classification and search.

Early models were n-gram methods based on counting word sequences; today's neural models turn tokens into embedding vectors and process them with the Transformer architecture. During generation, tokens are picked using sampling settings such as temperature.

In more detail

The chain rule and perplexity

An autoregressive language model factorises the probability of a token sequence with the chain rule: the sequence probability is the product of each token's probability given all the tokens before it. Model quality is classically measured by perplexity, the exponentiated average negative log-likelihood per token, where lower perplexity means the model assigns higher probability to real held-out text.

Encoder-decoder and non-Transformer architectures

Alongside autoregressive decoders (GPT-style) and bidirectional encoders (BERT-style), encoder-decoder architectures (such as T5 and BART) excel at sequence-to-sequence tasks like translation and structured summarisation. Recent alternatives also include state-space and hybrid architectures (such as Mamba-Transformer hybrids) as well as discrete diffusion language models that generate tokens in parallel rather than strictly left to right.

Decoding strategies

During autoregressive generation, choosing the next token from the probability distribution involves decoding strategies: greedy decoding picks the single highest-probability token, temperature scales the sharpness of the distribution, top-k and top-p (nucleus) sampling restrict choices to plausible candidates and constrained or structured decoding forces outputs to match a JSON schema or grammar.

Commonly confused terms

TermHow it differs
Embedding modelAn embedding model maps words or passages to fixed vector representations for similarity or retrieval, whereas a language model assigns probabilities over token sequences (though encoder LMs are frequently adapted to produce embeddings).

Why a language model matters for on-premises AI

In-house, documents and records are processed without an outside service. Not every task needs a large model: for classification, entity recognition or short summaries, small language models on modest hardware can be enough. Because the model is probabilistic and can be wrong, critical decisions need source citation and human approval; for Turkish business documents its Turkish accuracy is tested separately.

ON-PREMISES EXAMPLE

A legal department uses an in-house language model to summarise content retrieved from the parts of the contract archive its staff are authorised to see.

Common questions

Are all language models used to generate text?

No. Encoder models trained with masked language modelling are used mainly to produce embeddings for classification, entity recognition and semantic search.

Are language models also used for simple tasks such as spell checking?

Yes. Small models for search ranking, spell checking and document classification are language models too; the term is not limited to large chat systems.

Sources

In the glossary: Glossary, D to L

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.