Bayesian Networks

Are LLMs Bayesian?

Large language models are probabilistic, but most are not Bayesian in the strict sense. Here is why training and Bayesian ideas differ, and where they overlap.

On this page
  1. What “Bayesian” could mean here
  2. How LLMs are usually trained
  3. Bayesian neural networks
  4. In-context learning
  5. Calibration
  6. Summary

Not in the strict sense. Large language models (LLMs) are probabilistic: they assign probabilities to the next token of text, and they are trained so those probabilities match patterns in data. But the usual training method does not update a probability distribution over the model’s weights, which is what a strictly Bayesian model would do. That gap is where the debate lies.

What “Bayesian” could mean here

The word can mean three different things for an LLM:

  1. Bayesian inference over parameters. Keep a prior over the model’s weights and compute a posterior after seeing data. This is the strict meaning.
  2. Bayes’ rule as a tool. The model can carry out or explain Bayesian calculations in its output.
  3. A Bayesian reading of behavior. Describe what the model does as if it were doing Bayesian inference, even though it is not built that way.

Most of the debate concerns the first and third.

How LLMs are usually trained

LLMs are usually trained by minimizing a loss function, typically cross-entropy on next-token prediction. Minimizing cross-entropy is equivalent to maximizing the likelihood of the training data. That is maximum likelihood estimation, not Bayesian updating. The result is one set of weights, not a distribution over possible weights.

Regularization can add a Bayesian flavor. Weight decay penalizes large weights, and in a Bayesian view a penalty of that form corresponds to a Gaussian prior on the weights. Training with weight decay then gives a maximum a posteriori estimate, which is a single point, not a full posterior. The analogy is useful, but it does not make the model Bayesian.

Bayesian neural networks

A Bayesian neural network places a probability distribution over its weights and gives uncertainty estimates by averaging over that distribution. It is an active research area, but it is expensive to compute at the scale of today’s LLMs, and most LLMs are not trained this way.

In-context learning

When an LLM picks up a task from examples in its prompt, without changing its weights, some researchers describe this as implicit Bayesian inference. The model is said to infer which task it is being asked to do from the examples. This is a theoretical lens that has supporters and critics, not a settled account of the mechanism.

Calibration

Even if an LLM’s internal probabilities have a Bayesian reading, its stated confidence may not match how often it is right. A fluent answer can be wrong without any warning, and the probabilities over words are not reliable probabilities of facts. Checking calibration on questions with known answers is one way to see how far the model’s confidence can be trusted.

Whether training counts as supervised or unsupervised learning depends on how the labels are defined, which is the question behind “Is LLM supervised or unsupervised learning?” For the product-specific version of this question, see “Is ChatGPT Bayesian?”

Summary

  • Most LLMs are probabilistic, but they are usually trained by maximum likelihood, not Bayesian updating.
  • Weight decay has a Bayesian reading as a prior, but the trained model still holds one set of weights.
  • Bayesian neural networks give distributions over weights, but they are costly and not how most LLMs are built.
  • In-context learning is sometimes described as implicit Bayesian inference, which remains a debated theory.

The complete guide to bayesian networks

Bayesian Networks Explained in Detail
Read the guide

Keep exploring

Guides from other topics

All topics →