Start studying
Module 6 · LLMs Module contents
Module 6  ·  Card 21 / 22intermediate

Sampling Strategies

Greedy decoding always takes the single highest-probability token.

That is repeatable but tends to be bland and can fall into loops.

Sampling draws from the distribution instead, giving variety.

Beam search explores several candidate sequences and keeps the best overall.

In practice most systems use temperature plus top-p together.

Learn in depth ↓
Module 06 · LLMs · 22 concepts
In depth  /  15 lines

Sampling Strategies, in more detail

Once the model has produced its probabilities, something has to choose a token.

That choice is the sampling strategy, and it is not part of the model.

Greedy decoding always takes the single most likely token.

It is repeatable and safe, and it tends to be flat and prone to repeating itself.

Sampling draws from the distribution instead, so a token with 20 per cent probability wins one time in five.

That gives variety and is what makes the same prompt return different answers.

Beam search keeps several candidate continuations alive and expands each of them.

It compares whole sequences rather than committing to one token at a time.

That suits translation, where there is a best answer worth searching for.

It suits open generation badly, producing safe repetitive text, and it costs several times more.

Most systems today use temperature together with top-p and nothing else.

Repetition penalties can be layered on to discourage tokens that have already appeared.

They help with loops and can also damage text that legitimately repeats a term.

Structured output enforcement sits at this layer too, by masking every disallowed token.

The important point is that decoding is a choice you control, separate from the model itself.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What is the drawback of greedy decoding?
LLMs

22 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close