# Language model

> Canonical: https://skillalmanac.com/glossary/language-model | Last verified: 2026-11-25 | Index status: index-eligible

A language model estimates probabilities or scores for linguistic units and sequences. Autoregressive models predict a next token from preceding context; masked models estimate hidden tokens using surrounding context. A large language model is a scaled-up member of this category.

Also called: language models, language modeling, language modelling, statistical language model, LM.

## In plain language

One common kind of language model estimates which token could come next. Other models estimate hidden tokens from surrounding text. Given the start of a sentence, such as 'The water of Walden Pond is so beautifully', it scores possible next words: 'blue' or 'clear' rate far higher than 'refrigerator'. Speech recognition (per Wikipedia) and spelling correction (per Stanford's chapter 3) use this idea, and so do chat assistants. The limit is that the score reflects patterns in the text it learned from. A likely-sounding word is not a checked fact, so a fluent answer can still be wrong.

## Technical definition

Language-modeling approaches include count-based n-gram models and neural models. Autoregressive models estimate a token conditional on earlier context, which can define sequence probabilities by chaining conditionals. Masked language models estimate hidden tokens from surrounding input and do not share the same left-to-right objective. NLTK also exposes unnormalized backoff scorers, so check whether a particular implementation returns normalized probabilities or other scores. Architecture, scale and instruction following are separate properties.

## How it shows up when you use agents

Agent sessions run on a language model. The application, not the model, decides what to send and which tools to offer. This page is about the general idea; the [large language model](/glossary/large-language-model) page covers the large neural kind that most agents use.

For an autoregressive model, the scoring task concerns possible next tokens; masked models use surrounding context instead. Stanford's n-gram chapter introduces next-word sequence modeling. A fluent reply has not thereby been checked against your repository or a source. When an agent states that a function exists, run the code or open the file.

Language models also exist at small scale and in older forms. An [n-gram](/glossary/n-gram) model counts word sequences; a neural model learns parameters. Text is split into [tokens](/glossary/token) first, and tokens are what limits and costs are counted in. If you are choosing which model to run, the [local-model-sizing](/skills/skill-almanac/local-model-sizing) skill estimates whether it fits your hardware, but fit says nothing about how well it answers.

## Common confusions

- **Language model versus large language model.** A large language model is one kind of language model. The Stanford chapter introduces the simplest kind, the n-gram model, as a way to teach ideas that carry over to larger ones.
- **Language model versus chatbot.** A chatbot is an application that may use a language model. The model scores words; the application adds the conversation, tools and memory.
- **Next-word prediction versus understanding.** Next-token prediction is an autoregressive training objective, not the only language-modeling objective. Whether the result amounts to understanding is a separate question this entry does not settle.
- **Causal versus masked.** Hugging Face describes both: causal models predict the next token from the left only, and masked models fill in hidden tokens. They are different setups for training.

## Worked examples in this catalogue

### [What Is an LLM? The Facts Agent Users Need](https://skillalmanac.com/learn/what-is-an-llm-for-agent-users)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A guide distinguishing model behavior from the application, with an autoregressive Transformer decoder example, a contrasting BERT masked objective, and runtime context versus learned parameters.

Why it exercises the concept: It covers the large-scale neural version of a language model, as it behaves in an agent session. This entry is the broader term.

### [context-window-packer](https://skillalmanac.com/skills/skill-almanac/context-window-packer)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Chooses which files fit one prompt's token budget and records what was kept, shrunk or dropped.

Why it exercises the concept: A language model reads its input as tokens within a limit. The skill works on that budget; it does not train or evaluate a language model.

### [local-model-sizing](https://skillalmanac.com/skills/skill-almanac/local-model-sizing)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Works out whether an open-weight language model will run on a given GPU, Mac or PC, with a script.

Why it exercises the concept: It is a practical step that involves picking a language model to run yourself. It estimates fit, not quality.

### [llm-eval-test-sets](https://skillalmanac.com/skills/skill-almanac/llm-eval-test-sets)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Builds and validates an eval dataset for any LLM feature, with a checker for duplicates and missing grades.

Why it exercises the concept: Checking a language model's output needs test cases. The skill prepares those; it does not itself measure how well a model predicts words.

## Related terms

- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)
- [N-gram](https://skillalmanac.com/glossary/n-gram.md)
- [Token](https://skillalmanac.com/glossary/token.md)
- [Transformer](https://skillalmanac.com/glossary/transformer.md)
- [Natural language processing (NLP)](https://skillalmanac.com/glossary/natural-language-processing.md)
- [Text generation](https://skillalmanac.com/glossary/text-generation.md)

## Sources

- [Speech and Language Processing, chapter 3: N-gram Language Models (Jurafsky and Martin, draft of August 19, 2026)](https://web.stanford.edu/~jurafsky/slp3/3.pdf), Stanford University (accessed 2026-11-24)
- [Causal language modeling](https://huggingface.co/docs/transformers/tasks/language_modeling), Hugging Face (accessed 2026-11-24)
- [Masked language modeling](https://huggingface.co/docs/transformers/tasks/masked_language_modeling), Hugging Face (accessed 2026-11-24)
- [Language model](https://en.wikipedia.org/wiki/Language_model), Wikipedia (accessed 2026-11-24)
- [nltk.lm: language models and StupidBackoff scores](https://www.nltk.org/api/nltk.lm.html), NLTK (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
