Skip to content
ImagineWorld

Training-Objective Innovations: Multi-Token Prediction

node_idnode-book_building-frontier-llm-from-scratch_chapter-13-training-objective-innovations-multi-token-prediction
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num13
chapter_titleTraining-Objective Innovations: Multi-Token Prediction
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Chapter 13 — Training-Objective Innovations: Multi-Token Prediction

Section titled “Chapter 13 — Training-Objective Innovations: Multi-Token Prediction”

The GPT of Chapter 10 learns from a single signal per position: predict the next token. That is a thin signal — each forward pass, costly to compute, teaches the model about exactly one step into the future. Multi-token prediction (MTP) asks the model to predict several future tokens at each position, densifying the training signal at little extra cost, and — as a bonus that turns out to matter a great deal — providing a built-in draft model that accelerates inference. DeepSeek-V3 uses MTP, and this short chapter explains how and why.

The intuition is that predicting further ahead forces richer representations. To predict the next token, a model can often lean on local patterns; to predict the token after that, it must form a more global plan of where the text is going. Training on both makes the hidden states more informative. There are two ways to do it. Meta’s multi-token-prediction work attaches several independent output heads that each predict a different future position in parallel. DeepSeek-V3 instead uses sequential MTP modules that preserve the causal chain — each module predicts one more token ahead, conditioned on the previous module’s work — which keeps the predictions coherent rather than independent guesses.

DeepSeek-V3 adds a small number of MTP modules after the main model. The main model predicts token t+1 from its final hidden state, as usual. The first MTP module takes that hidden state together with the embedding of the (known, during training) token t+1, runs a single transformer block, and predicts token t+2. A second module chains from there to predict t+3, and so on. Crucially, the modules share the main model’s embedding table and output head, so they add few parameters. Figure 13.1 shows the chain, and the per-module computation is a short combine-and-block:

flowchart LR
    M["main model<br/>hidden h0"] -- predict --> T1["t + 1"]
    T1 --> P1["MTP 1<br/>h0 + emb(t+1)"]
    P1 --> T2["t + 2"]
    T2 --> P2["MTP 2<br/>... t+3"]

each module chains from the previous hidden state plus the next token’s embedding, predicting one token further ahead while preserving the causal order

Figure 13.1. Sequential multi-token prediction in DeepSeek-V3. The main model predicts the next token; each MTP module reuses the running hidden state and the embedding of the next token to predict one more step ahead. The modules share the embedding and output head, so they cost little.

class MTPModule(nn.Module):
def __init__(self, d_model, n_head, hidden):
super().__init__()
self.norm = RMSNorm(d_model)
self.combine = nn.Linear(2 * d_model, d_model, bias=False)
self.block = Block(d_model, n_head, hidden) # a transformer block
def forward(self, h, next_token_emb):
# h: running hidden state; next_token_emb: embedding of the known next token
x = self.combine(torch.cat([self.norm(h), next_token_emb], dim=-1))
return self.block(x) # hidden state for predicting one token further

Python — mtp.py: one sequential MTP module (conceptual)

During training, each MTP module produces its own next-token loss, and the total objective is the main loss plus the averaged MTP losses, scaled by a small weight. The extra gradient signal improves the main model’s representations even though the MTP modules are lightweight. DeepSeek-V3 reports that MTP improves benchmark performance — the denser objective is a genuine training win, not just an inference trick.

13.3 A Free Draft Model: MTP and Speculative Decoding

Section titled “13.3 A Free Draft Model: MTP and Speculative Decoding”

The second payoff appears at inference. Because the MTP modules already predict future tokens, they can serve as a draft model for speculative decoding: the cheap MTP heads propose several tokens ahead, and the full model verifies them in a single forward pass, accepting the longest correct prefix. When the drafts are usually right, several tokens are produced per expensive step instead of one. DeepSeek reports a high acceptance rate for the next-next token, translating into a roughly 1.8× decoding speed-up. The same modules that made training richer make generation faster — a rare two-for-one.

PhaseBenefitCost
Trainingdenser signal, better representations and benchmarksa few lightweight modules; small extra loss term
Inference (plain)modules can simply be discardednone
Inference (speculative)built-in draft model; ~1.8× faster decodingverification logic; modest memory

Table 13.1 — What multi-token prediction buys

Code reference — deepseek-ai/DeepSeek-V3 (MTP modules & config) · Gloeckle et al., “Better & Faster LLMs via Multi-token Prediction”

DeepSeek-V3’s report and configuration describe its sequential MTP depth and loss weighting; Meta’s paper introduced the parallel-head formulation and the training benefits. Both illuminate the design space sketched above.

Multi-token prediction completes the trio of efficiencies that separate a modern architecture from the Chapter 10 baseline: capacity without cost (MoE), context without cache bloat (MLA), and richer, faster prediction (MTP). One frontier remains — making attention itself sub-quadratic so that very long contexts are not merely possible but cheap. That is the subject of the next chapter.

13.4 Worked Example: The Multi-Token Prediction Loss

Section titled “13.4 Worked Example: The Multi-Token Prediction Loss”

Standard language modeling predicts one token ahead and computes one loss per position. Multi-token prediction (MTP) adds lightweight auxiliary heads that predict the token after next, and the one after that, turning each position into a source of several supervised signals rather than one:

# main head predicts t+1; aux head k predicts t+k
loss = F.cross_entropy(main_logits, targets[1:])
for k, head in enumerate(mtp_heads, start=2):
aux_logits = head(hidden)
loss = loss + lambda_k * F.cross_entropy(aux_logits, targets[k:])

Python — mtp/loss.py: main head plus auxiliary depth heads

The auxiliary losses are down-weighted by a coefficient lambda_k so the model’s primary job — predicting the very next token — remains dominant, while the extra heads pull it toward representations that anticipate further ahead. The payoff at training time is sample efficiency: the same corpus now yields more gradient signal per token, and the model learns to plan slightly beyond the immediate next word, which empirically improves quality on the main objective itself.

13.5 MTP at Inference: A Built-In Draft Model

Section titled “13.5 MTP at Inference: A Built-In Draft Model”

The dividend of multi-token prediction arrives a second time at inference. The very heads trained to predict tokens t+2 and t+3 are, in effect, a draft model living inside the main network — they propose the next few tokens, which the main forward pass can then verify in one shot through speculative decoding (Section 41.5). A capability added to improve pretraining thus doubles, at no additional parameter cost, as an accelerator for generation.

This reuse is characteristic of the DeepSeek-V3 design philosophy examined in Chapter 45: a single mechanism is made to serve both the training run and the deployed system. MTP densifies the learning signal while training and supplies speculative proposals while serving, so the same modules earn their keep on both sides of the model’s life — one of several places where this book’s architecture refuses to treat training and inference as separate problems.

Predict further, learn faster, decode quicker MTP’s auxiliary heads densify the training signal and then double as a built-in speculative-decoding draft model. One architectural addition, paying off at both training and inference time.

Multi-token prediction adds heads for the token after next, and the one after that (Section 13.4) — which raises the obvious question of how far ahead it is worth predicting. The answer, in practice, is: not very far. Most of the benefit comes from predicting just one or two extra tokens, and the returns diminish quickly with depth.

The reason is uncertainty. Predicting the immediate next token is hard but tractable; predicting the token three positions ahead means predicting through two intervening tokens you have not yet committed to, and the space of possibilities fans out rapidly. The auxiliary heads for distant positions therefore face a much noisier target and contribute progressively less useful signal, while still costing parameters and compute. Both of MTP’s payoffs — the densified training signal and the built-in speculative-decoding draft (Section 13.5) — saturate at shallow depth: a draft model only needs to propose a few tokens for verification to be worthwhile, and the training signal is already enriched by one or two extra targets. This is why production systems like DeepSeek-V3 use a small MTP depth rather than predicting far into the future — the sweet spot is shallow, where the prediction is still reliable enough to help.

Shallow prediction, most of the gain Predicting one or two tokens ahead captures nearly all of MTP’s benefit; further ahead the target grows too uncertain to help. Both the training-signal and draft-model payoffs saturate quickly, so real systems keep the depth small.