Language model

A language model is a system that estimates how likely a sequence of words or tokens is, usually by predicting what comes next, and it is the core of chatbots and AI text tools.

A language model scores text. Google's machine learning glossary defines it as a model that estimates the probability of a token, or a sequence of tokens, appearing within a longer sequence. Given The cat sat on the, a good language model gives high probability to mat or sofa and very low probability to parliament. To generate text, the model picks a likely next token, adds it to the sequence and repeats.

The idea is older than modern AI. In the 1970s Frederick Jelinek and colleagues at IBM Research built statistical language models from n-grams, counts of how often short runs of words appear together, and introduced perplexity as a way to measure how well a model predicts text. Counting has a basic weakness: most possible word sequences never appear in any training set, so the model has no counts for them.

Neural networks addressed that. In 2003 Yoshua Bengio and co-authors published A Neural Probabilistic Language Model, which learned a vector for each word so that a new sentence made of familiar, similar words could still get a sensible probability. It beat the best n-gram models on two text collections. In 2010 Tomáš Mikolov and colleagues showed recurrent neural networks doing far better than n-grams, and transformer-based models later replaced recurrent ones.

A large language model is a language model with a very large number of parameters. GPT-3, described in May 2020, had 175 billion, ten times more than any earlier non-sparse language model. The chatbots people use are large language models given extra training to follow instructions and hold a conversation. Not every text model is a language model: Google's glossary notes that text classifiers and sentiment models are not.

The practical point is in the definition. A language model is trained to produce likely text, not true text. Fluent, confident output is what it is built for, which is why it can state a falsehood as smoothly as a fact. Anything that matters still needs checking against a reliable source.

Common questions

What is a language model in simple terms?

It is a program that has learned which words tend to follow which, so it can judge how likely a piece of text is and predict what comes next. Repeating that prediction one token at a time lets it write sentences, answer questions and complete code.

What is the difference between a language model and a large language model?

A large language model is a language model with a very large number of parameters, typically billions, trained on very large amounts of text. Older language models, such as n-gram models, were far smaller and simpler. Size and training data give large models much broader abilities.

Is a language model the same as a chatbot?

No. The language model is the engine that predicts text. A chatbot is a product built around it, usually after extra training to follow instructions, plus an interface, safety filters and sometimes tools such as web search.

How are language models evaluated?

A classic measure is perplexity, which shows how well a model predicts held-out text; lower is better. Modern models are mostly compared on benchmarks built by people, such as question sets covering many subjects, and through human judgements of their answers.

Finding more

Search for "n-gram language model", "neural language model" or "next-token prediction" to follow how the idea developed. Reliable sources include the original papers in journals and on arXiv, university course notes on natural language processing, and machine learning glossaries from Google and similar providers. Be wary of descriptions that credit language models with understanding or intent, since the underlying task is statistical prediction.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.