Prompt Engineering

Layer 4 · Foundations

Prompt Engineering

The formal layer: decoding-time constraints on the output distribution, and the statistics of evaluating prompt changes.

15 min read180 XP

  1. Base logits

    from the forward pass

  2. Apply prompt conditioning

    shifts the distribution

  3. Apply decoding constraints

    temperature, top-p, grammars

  4. Sample token

    final choice

Prompting shapes the distribution; decoding then samples from it.

Formally, the model defines where is the full prompt. Prompt engineering changes ; decoding parameters change how the resulting distribution is turned into a sampled token. Understanding both together explains why the same prompt can look great at temperature 0 and much worse at temperature 1.