LLMs & Generative AI
Prompting & Decoding
Prompting defines task, context, constraints, and examples; decoding controls how the model chooses output tokens through settings such as temperature and top-p.
- A prompt is an interface contract
- Examples beat vague style instructions
- Temperature controls randomness
- Top-p limits sampling to a probability mass
- Prompt changes are code changes
Task: Extract invoice fields from the text.
Rules:
- Use only values explicitly present in the document.
- Return JSON only.
- Use null for missing fields.
- Do not guess.
Schema:
{ "invoiceNumber": string|null, "amount": number|null, "currency": string|null }
Document:
<text here>| Setting | Lower value | Higher value |
|---|---|---|
| Temperature | More deterministic | More varied / creative |
| Top-p | Smaller candidate pool | Broader candidate pool |
| Max tokens | Shorter output / cheaper | More complete / costlier |