intermediate~3h
4 LLM Text Generation Strategies + SLED
Greedy, Multinomial Sampling, Beam Search, and Contrastive Search — the 4 core strategies for picking the next token — plus SLED (Self-Logits Evolution Decoding), a bonus technique that improves factuality using every layer's predictions.
4 LLM Text Generation Strategies (+ SLED)
Each strategy trades off speed, quality, and diversity differently when turning next-token probabilities into an actual output sequence.
| Mechanism | Strength | Weakness | |
|---|---|---|---|
| Greedy | Always picks the highest-probability token at each step | Fast, deterministic, cheap | Prone to repetition loops, no diversity |
| Multinomial sampling | Randomly samples from the probability distribution | Produces diverse, less repetitive output | Can wander into low-probability, incoherent territory |
| Beam search | Explores k parallel paths, prunes low-scoring ones, keeps the best complete path | Higher-quality complete sequences than greedy | More compute (k× the paths), can still favor generic output |
| Contrastive search | Actively avoids revisiting previously-generated context | Reduces repetition without pure randomness | More complex scoring, extra compute per step |
| SLED (bonus) | Aggregates predictions from every model layer, not just the final one, toward a consensus | Improves factuality by using the full model's internal signal | Requires access to intermediate layer outputs, added complexity |
4
Subtopics
1
Exercises
1
Projects
5
Quiz Qs
4
Flashcards
▶📚 Prerequisites(1)
🎓 Learning objectives
- •Explain why greedy decoding often produces repetitive output
- •Contrast beam search's global-sequence optimization against greedy/sampling's single-step focus
- •Explain how Contrastive Search balances fluency and diversity using a similarity penalty
- •Explain SLED's layer-wise logit consensus mechanism and why it improves factual accuracy
4 LLM Text Generation Strategies + SLED is a Pro topic
Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.