Prompt Engineering

Prompt engineering is the practice of crafting and iterating on the instructions, examples, and formatting within a prompt to elicit desired behavior from an LLM.

Details

Techniques include writing clear system instructions, selecting and ordering in-context learning examples (few-shot prompting), specifying output format constraints (structured output), and chain-of-thought elicitation for improved reasoning. Sampling parameters such as temperature are a complementary inference-time lever often tuned alongside prompt iteration, but operate outside the prompt itself.

Prompt engineering focuses on what the developer directly writes in the prompt template. Context engineering is a broader practice that encompasses prompt engineering but extends to managing all context sources - including retrieval, memory management, and context-budget allocation under a given context size. As LLM applications grew from single-turn completions to agent-based systems with dynamic context from tools, documents, and multi-turn history, the term context engineering emerged to describe this expanded scope.

Examples

  • Rewriting a system message to reduce hallucination by adding "only use the provided context" instructions.
  • Adding few-shot examples to standardize the output format of a classification task.
  • Inserting a "think step by step" directive to improve multi-step reasoning accuracy.
  • Iterating on prompt wording guided by evals to improve task performance without changing the model or retrieval pipeline.