Skip to content
Query Feedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  1. Home /
  2. AI Glossaries /
  3. LLMs /
  4. What is Greedy Decoding?
LLMs

What is Greedy Decoding?

Updated September 26, 2026 Read 2 min

Greedy decoding is the simplest way to generate text from a language model: at every step it picks the single most likely next token, without any randomness.

Contents 11
  1. 01Key takeaways
  2. 02Greedy decoding explained in simple terms
  3. 03How it works
  4. 04Why locally best is not globally best
  5. 05When to use greedy decoding
  6. 06The repetition problem
  7. 07Greedy vs other strategies
  8. 08Limitations
  9. 09Common Use Cases
  10. 10Frequently Asked Questions
  11. 11Related Terms

Greedy decoding is the simplest generation strategy: at each step, the model picks the token with the highest probability. There is no randomness and no lookahead. It is fast, reproducible and often the right choice for factual or structured tasks, but it can produce repetitive or bland text in open-ended writing.

Key takeaways

  • Greedy decoding takes the top token every step, equivalent to temperature 0.
  • It is deterministic in principle, though small hardware variations can still occur.
  • It can get stuck in repetition loops.
  • It does not guarantee the most likely overall sentence, only the most likely next token.
  • Beam search and sampling methods address different weaknesses.

Greedy decoding explained in simple terms

Imagine walking through a maze and always taking the path that looks best right now, without considering where it leads. Often you reach the exit. Sometimes you walk confidently into a dead end that a little foresight would have avoided. Greedy decoding makes each choice locally optimal, not globally.

How it works

  1. The model produces a probability distribution over the vocabulary.
  2. Select the token with the highest probability.
  3. Append it and repeat until an end token or length limit.

Worked example: after “The capital of Karnataka is”, probabilities might be: ” Bengaluru” 0.88, ” Bangalore” 0.09, ” a” 0.01. Greedy decoding always chooses ” Bengaluru”. Run it a hundred times and you get the same answer every time, which is exactly what you want for factual questions.

Why locally best is not globally best

Suppose the model gives “The” 0.5 and “A” 0.45 as the first word. Greedy takes “The”. But the best continuation after “A” might have far higher combined probability than anything after “The”. Greedy decoding never discovers this, because it never looks ahead. Beam search exists to address this.

When to use greedy decoding

SituationSuitable?
Data extraction and structured outputYes
Classification with an LLMYes
Factual question answeringUsually
Code generationOften
Evaluations needing reproducibilityYes
Creative writing and brainstormingNo, output becomes bland
Generating multiple varied optionsNo

The repetition problem

Greedy decoding is prone to loops: “I think that I think that I think…”. Once a phrase becomes locally most likely, it reinforces itself. Remedies include a repetition penalty, a frequency penalty, or switching to sampling with top-p.

Greedy vs other strategies

StrategyChoosesBest for
GreedyTop tokenDeterministic, factual output
Beam searchBest overall sequence among k candidatesTranslation, summarisation
Top-k samplingRandom from the k most likelyVaried text
Top-p samplingRandom from the smallest set reaching probability pBalanced, natural text

Limitations

  • Can produce repetitive or generic text.
  • No variety across runs, so it cannot generate alternatives.
  • Ignores better sequences that begin with a slightly less likely token.
  • Not fully deterministic in practice across different hardware or batch settings.

Common Use Cases

01

Structured extraction

Produce consistent JSON fields from documents.

02

Classification

Return a single stable label per input.

03

Factual answers

Give the same answer to the same question every time.

04

Code generation

Favour the most probable, syntactically valid continuation.

05

Evaluation runs

Keep benchmark results reproducible.

06

Regression testing

Detect model changes by comparing fixed outputs.

Frequently Asked Questions

A generation method that always selects the highest-probability next token.

Effectively yes. Temperature 0 makes the model pick the top token every step.

Once a phrase becomes locally most likely, it reinforces itself, creating loops.

In principle yes, though hardware, batching and floating-point differences can cause small variations.

For creative writing, brainstorming or whenever you want varied alternatives.

Related Terms

  • Beam Search
  • Top-k Sampling
  • Top-p Sampling
  • Temperature in LLMs
  • Repetition Penalty
  • Autoregressive Generation

Related AI Terms

What is Multi-Head Attention?Multi-head attention runs several attention operations in parallel, each with its own learned projections, so a model can…What is Prefix Tuning?Prefix tuning is a parameter-efficient fine-tuning method that learns trainable vectors inserted into the attention keys and values…What is an Encoder-Decoder Model?An encoder-decoder model, also called a sequence-to-sequence model, uses one component to read and understand the input and…What is an Attention Mechanism?An attention mechanism is a technique that lets a neural network focus on the most relevant parts of…What is Self-Attention?Self-attention is a mechanism where each position in a sequence attends to every other position in the same…What is Positional Encoding?Positional encoding is the method transformers use to represent the order of tokens in a sequence, because the…

Contents

  1. 01Key takeaways
  2. 02Greedy decoding explained in simple terms
  3. 03How it works
  4. 04Why locally best is not globally best
  5. 05When to use greedy decoding
  6. 06The repetition problem
  7. 07Greedy vs other strategies
  8. 08Limitations
  9. 09Common Use Cases
  10. 10Frequently Asked Questions
  11. 11Related Terms

AI Topic

  • LLMs

Related Terms

  • What is Multi-Head Attention?
  • What is Prefix Tuning?
  • What is an Encoder-Decoder Model?
  • What is an Attention Mechanism?
  • What is Self-Attention?
  • What is Positional Encoding?

Quick Navigation

  • Common Use Cases
  • Frequently Asked Questions
  • Related Terms
  • Back to top

Details

Updated
September 26, 2026
Read
2 min
  • Forum
  • Submit a tool
  • Submit Guest Post
  • List Your Startup
  • Privacy Policy
  • Editorial Policy
  • Account
  • Contact
  • AI Productivity
  • AI Video
  • AI Coding
  • AI Chatbots
  • Sales
  • AI Business
  • View All Tools

Subscribe our Newsletter

Get weekly exclusive content - No spam.

Copyright © 2026 -  Query Feedz

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}