Rúben GalvãoThe Rabbit Hole

The Rabbit Hole / AI and machine learning / Language models / Generating text

Multi-token prediction (MTP): learning to look further ahead

Each column learns to predict one token. Would asking it to look one step further change what it learns, or how fast it writes?

In Why the last column predicts, one run trained on all of “the hare sat on the grass” at once. Every column predicted the token after it.

One answer per column

Training on "the hare sat on the grass": 5 answers from one output headTokenstheharesatonthegrassthe model's layersOutputnext tokenharesatonthegrass5 answers
Each column is trained on one answer: the token after it. Six tokens give five answers.

Each column only ever has to see one step ahead. “hare” learns that “sat” comes next, but nothing asks whether it can see “on the grass” coming.

Good text is limited, and every run through the model costs time. Could the same run teach more?

Ask for the token after next

Keep the model as it is, and give its output a second head. The first still predicts the next token; the second predicts the one after that.

Training on "the hare sat on the grass": 9 answers from two output headsTokenstheharesatonthegrassthe model's layersOutputnext tokenharesatonthegrasstoken after nextsatonthegrass9 answers
A second head trains every column on the token after next too: nine answers from the same run.

The same run now gives nine answers instead of five, and each column has to plan a little further. This is multi-token prediction.

It pays off. A 13-billion-parameter model trained this way solved 12% more of the HumanEval coding problems, and 17% more of MBPP’s, than one trained on the next token alone.

Tell the second guess what came next

A head that predicts two ahead also has to guess the token in between. If “hare” might be followed by “sat” or “ran”, its guess for two ahead must cover both.

DeepSeek-V3 gives that second guess the real next word. A small extra module combines the column’s final vector with the embedding of the token that actually came next, runs one more transformer block, and predicts with the same output head.

A multi-token prediction module next to the main modelFor the column "hare", the main model's final vector goes to the output head and predicts "sat". In the extra module, that final vector and the embedding of the actual next token, "sat", are each normalised and joined into one vector twice as long. A learned projection matrix turns it back into a vector of the usual width, which passes through one more transformer block and the same output head to predict "on".Main modelExtra moduleharethe model's layersfinal vectoroutput headsatsatembeddingnormalise both, joinlearnedprojectionone more blockoutput headsharedon
The column's final vector and the real next word are normalised and joined end to end. A learned matrix turns that long vector back into one of the usual width for the extra block.

In training, the real next word is always there in the text, so the extra module never has to guess it.

Use the guess to write faster

After training, the extra module can be dropped. But it can also help the model write.

When it writes, every pass adds one token: the last column predicts it, we append it, and run again. With the module kept, each pass can also guess the token after that. Append the guess too.

On the next pass, the column before the guess predicts what belongs there anyway. If it agrees, the guess stays.

Writing with a guess for the token after nextAfter the prompt "the hare", pass 1 writes "sat" and guesses "on". Pass 2 checks "on", keeps it, writes "the" and guesses "lawn". Pass 3 rejects "lawn", writes "grass" instead and guesses a full stop. Pass 4 keeps the full stop. Five tokens in four passes.Pass 1theharesaton+1Pass 2theharesaton✓thelawn+2Pass 3theharesatonthelawn✗grass.+1Pass 4theharesatonthegrass.✓+1writtenguessguess keptguess rejected
Each pass writes one token and guesses the next. A right guess is kept, so that pass adds two: 5 tokens in 4 passes instead of 5.

A right guess gives two tokens for one pass. A wrong one is simply replaced. DeepSeek-V3’s guesses were right 85–90% of the time, so it wrote about 1.8 times as fast.

Guessing ahead and checking is a technique of its own: speculative decoding.

Sources and assumptions
  • Better & Faster Large Language Models via Multi-token Prediction, Gloeckle and colleagues at Meta, 2024: several independent output heads on a shared model, each predicting a further token. Their 13B model solved 12% more HumanEval and 17% more MBPP problems than a comparable next-token model, and 4-token models were up to 3 times faster at inference.
  • DeepSeek-V3 report, §2.2 and §5.4.3: sequential modules that keep the causal chain, each combining the previous depth’s representation with the embedding of the next token through a projection and one transformer block, with the embedding table and output head shared. Depth 1; loss weight 0.3 for the first 10T tokens and 0.1 for the remaining 4.8T. The modules can be discarded at inference; used for speculative decoding, the second token was accepted 85–90% of the time, for 1.8 times the tokens per second.
  • An earlier form of predicting several future tokens appeared in ProphetNet (Qi and colleagues, 2020) for sequence-to-sequence models.

The module figure follows DeepSeek-V3’s equations: RMSNorm on both inputs, concatenation, then a learned projection back to the model’s width; its cell colours are illustrative. The answers figures count training targets for one sentence; the last column has no next token, and the last two none for two ahead. The writing figure follows the scheme above with illustrative guesses, one of them wrong: every pass writes one token and guesses the next, and a guess the next pass agrees with is kept. With guesses right a share p of the time, that averages 1 + p tokens per pass; real speed-ups are a little lower because checking and guessing add work.

← Browse all subjectsBack to the beginning ↑