Skip to main content
A token-level MDP of a language model, models StS_t as the prompt plus every token generated so far, and the action ata_t is the generation of the next token. The transition appends the token to the context, St+1=st⊕atS_{t+1} = s_t \oplus a_t. In this application dynamics are deterministic and known. The policy is the model itself, πθ(at∣st)\pi_\theta(a_t \mid s_t). Each token may depend on everything before it, and the process is still Markov, because the state holds the whole history. The reward is known as well, in the sense that a reward model can be a separate network we can query or even a more concrete verifier or even a unit test that verifies a coding agent output and this can easily provide a pass or fail reward signal. In fact multistep MDP is not even needed when the reward scores the whole response. In this case we treat the full response as a single action, given the prompt. As it turns out despite the fact that we have knowledge of MDP dynamics in autoregressive language models, there is a major computational issue in the application of DP algorithms.Dynamic programming keeps a value for every state and updates all of them in every sweep. The states of a language model are all token sequences up to the length limit. With a vocabulary of about 10510^5 tokens there are about 105T10^{5T} sequences of length TT, so not even one sweep is possible. Instead we have to use Reinforcement Learning algorithms to optimize the agent responses and Language models are therefore trained with sampling methods, such as policy gradient on sampled responses, which visit only the states the policy actually reaches.
Partial obvervation of the state however is more of a norm than the exception. In dialogue or tool use, the environment also adds observations to the context such as the user’s reply or the tool use outputs. So the assumption that the agent generates the whole next state is not true anymore. When the history of a multi-turn or agentic task no longer fits in the LLM agent’s context window, the problem is partially observable. Long term memory and summarization then play the role of the agent’s own estimate of the state.The part of the reward that is unknown is the true objective, human preference. The reward model is a learned estimate of it, and a policy that maximizes the reward model can exploit the model’s error (reward hacking). It limits how far we can optimize against the reward model.Some planning does happen at decoding time, because the model is known. Beam search, best-of-NN sampling with a verifier and Monte Carlo tree search all use the model to look ahead from the current state. They search a tiny part of the tree and never sweep the state space.

Found an error on this page? Report an issue.