AI engineering glossary · Transformers LLM architecture

What is contrastive decoding?

Contrastive decoding: A decoding method that favours tokens a strong model finds much more likely than a weaker model does, while filtering out implausible tokens. It aims to reduce generic, repetitive or hallucinated text by subtracting what a small model would say anyway.

Level: advancedTopic: Transformers LLM architecture

Contrastive decoding: an example

A large model's log-probability minus a small model's log-probability is used to rank the next tokens.

Related terms

More Transformers LLM architecture terms

Where you learn it

Contrastive decoding is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.