Are LLMs Chaotic?
LLMs are inherently deterministic. While you may hit regenerate on ChatGPT and see a new response, that's more an artifact of the harness they are running in. If you run a local model, set temperature to zero, and disable sampling and batching, you can hit generate over and over on the same prompt and get the same response. But what happens if you add a comma or an extra space somewhere? Or paraphrase the question? That's what I spent time exploring: how sensitive is the output of an LLM call to its inputs? I always had an interest in dynamical systems (chaos), and this seemed to overlap with the same ideas. Could two questions that to a human appear semantically the same generate completely divergent outputs when passed to an LLM?
When an LLM is generating output, it's inference. It is a sequential system where the activations flow through the layers and the final output is a branched process. The final layer produces a set of logits, one for each possible token, and under greedy decoding the highest score wins. At first it seems like yes, that could be brittle. If you have two logits that represent two opposite words (let's just say True and False to keep it simple), imagine if the value of False was 4.21 and True was 4.23. True is the answer the LLM gives. But notice those values are quite close! Some shifts in earlier layers could flip those and it gets False. I wanted to try and quantify this. Though this example is simplistic, you could see how more inconsequential wording at the start of a response could compound over time. Start with "Usually" vs. "Typically," and while semantically close, they may be the initial shift that leads to a completely different sentence.
Chaos isn't randomness
It can be helpful to get the technicals right at the start, as vibes-wise chaos and randomness seem related. But chaos is just the amplification of small differences. Since systems operate over sequences (think time), each point in the sequence could be only 2% different, but over a hundred steps that compounds!
You can characterize a system using the Lyapunov exponent (λ). With two trajectories starting a distance δ(0) apart, their separation at time t grows roughly like |δ(t)| ≈ |δ(0)| · e^(λt). If the number is positive, the gap grows exponentially. If it is negative, the gap collapses and the trajectories converge. It can also be zero, meaning the separation stays at roughly the same scale.
So the Lyapunov exponent quantifies what you would call "the butterfly effect." It's a time-averaged local stretching rate that makes it hard to predict weather more than a few weeks out or where all the balls will end up after the break in a game of pool.
What I found while learning about the Lyapunov exponent for LLMs is that trained neural networks sit near the chaos boundary. They balance on that edge because it is where training works best.
Langton, 1990, "Computation at the Edge of Chaos." Cellular automata. Langton showed that the ability to propagate signals over long distances and remember things happens in a small band between ordered (everything freezes) and chaotic (signals decorrelate to noise).
Poole et al. 2016, Schoenholz et al. 2017. Deep feedforward networks. They show that at random initialization, signals propagating through a deep network either shrink to zero (vanishing gradients) or blow up (exploding gradients). So you want initialization somewhere in the middle to have a good training run. You see the practical consequences of this in residual streams, normalization, and better optimizers. The core goal remains reliable signal and gradient propagation.
So is an LLM a dynamical system?
Let's think.
A dynamical system has state. LLMs have state: per-layer residual activations, logits, the KV cache, and the generated tokens so far.
A dynamical system has iteration. LLMs iterate: each forward pass produces a token, which gets appended to the prefix and then conditions the next forward pass. So you have autoregression through a repeated function.
A dynamical system is typically deterministic. LLMs are typically deterministic if you aren't specifically using techniques to make them otherwise, such as sampling or temperature. Yes, you can get byte-identical output up to GPU kernel nondeterminism. You can nit this a bit because bf16 arithmetic is non-associative: changing the batch size can change the reduction order of a sum enough to flip the resulting top logit.
When we think about amplifying small differences, here is one example I encountered. With OLMo-3 7B, I submitted write a concise Python palindrome function. and write a concise Python palindrome function. , the exact same string with a single trailing space at the end.
Prompt A returned a utility function with a docstring. Prompt B returned a conversational preamble followed by a one-line implementation. So we know that not every edit makes much of a difference, but also that the results are not always the same.
Confirmed: LLMs have state, iterate, are deterministic, and amplify small input changes.
A bit of a nit: in classical chaos, you start with the points being very close together, taking their separation toward zero because the real world is continuous. But LLMs use tokens! It's discrete! So the smallest change we can make is one token. We can't take that limit, but we will ignore this.
An interactive detour
Here you can see a heatmap of the divergences in a few different scenarios as they go through the layers.
Other work
While my work is on the outer token space, I found a rigorous version of this dynamics-as-LLMs framing in a paper by Li et al. 2025, wherein they look deeper into the activation space. They call it quasi-Lyapunov because classical Lyapunov needs infinite iteration of a fixed map, and LLMs have finite depth. The finite-depth analog is a per-layer hidden-state growth ratio: take the residual stream at layer n and ask how much bigger it is by layer n+1. Average that over layers for the per-layer stretching rate. So that is the time-averaged local stretching rate from earlier, but with "time" replaced by "depth."
The number they get is about 1.32x per layer in the first ten layers, falling to roughly 1.08x in later layers, which ends up around two orders of magnitude once compounded over the model depth. That magnitude growth is not itself a measure of perturbation growth, but their separate quasi-Lyapunov analysis does show small perturbations converging in shallow layers and diverging in deeper ones.
They also decompose the final residual norm by source:
- MLP contributions account for 55.8%
- Attention contributions account for 44.2%
- The initial input embedding accounts for 0.0009%
Ok, that feels pretty chaotic: we perturb the 0.0009% and watch the rest of the stream move. Almost everything that ends up in the output is transformations done inside the network. The input is the tiny seed getting amplified through the network.
Another finding is that the shallow layers mostly converge while the deep layers diverge, and strongly. So the chaotic behavior concentrates in the later layers.
Here's a demo I built while trying to internalize this. It's a toy visualization of a perturbation propagating through a stack of "layers," with a stretching rate you can adjust.
Where this post converges
The stability of a generation depends on two things:
- How much the input perturbation gets amplified through the continuous stretching.
- How many thin boundaries the generation passes through, where a small logit perturbation is enough to flip the top-1.
The first comes from the weights and the input (Li et al.'s per-layer growth ratio), while the second is also a combination of those weights and the prompt: whether you end up near boundaries with margins low enough to flip based on the residuals.
So you can't really say "how chaotic is this LLM?" with a single number. It has a stretching rate, and it has a boundary-density pattern over generation.