A comprehensive guide to LLM prompting fundamentals covering: role assignment, structured input/output with XML tags, response prefilling, n-shot prompting (recommending 12+ examples rather than just a few), Chain-of-Thought with sketchpads, multi-step prompt decomposition, context placement, instruction formatting, hallucination reduction techniques, stop sequences, and temperature tuning. Practical code examples use the Claude Messages API throughout. Key insights include why 'think step by step' alone is insufficient for CoT, how to use sketchpads to reduce hallucinations, and why starting temperature at 0.8 and lowering is preferable to starting low.

17m read timeFrom eugeneyan.com
Post cover image
Table of contents
Mental model: Prompts as conditioningAssign roles and responsibilitiesStructured input and outputPrefill Claude’s responsesn-shot promptingDiving deeper into Chain-of-ThoughtSplit catch-all prompts into multiple smaller onesOptimal placement contextCrafting effective instructionsDealing with hallucinationsUsing the stop sequenceSelecting a temperatureWhat doesn’t seem to matter