Prompt engineering

From llmref.wiki
Prompt engineering — The practice of designing and refining model inputs — instructions, examples, and context — to elicit specific, reliable outputs from a language model.

Overview

Prompt engineering is the discipline of crafting the inputs supplied to a language model to produce desired outputs. A prompt is the complete text sent to the model at inference time: it may include a system instruction, few-shot examples (In-context learning), a Chain-of-thought scaffold, retrieved context (RAG), and the user's query. Prompt engineering shapes all of these components to improve output quality, consistency, safety, or efficiency.

Prompt engineering emerged as a distinct practice as large language models (GPT-3 and successors) demonstrated sensitivity to input phrasing. Small changes to a prompt — the order of examples, the phrasing of an instruction, the presence or absence of a chain-of-thought cue — can produce substantial changes in output quality or format.

The term is sometimes contested: critics characterize it as informal trial-and-error rather than an engineering discipline, while proponents note that systematic prompt design methods (structured templates, ablation testing, retrieval-augmented construction) constitute a reproducible engineering practice.

Core techniques

Technique Description Reference
Zero-shot prompting Instruction only, no examples
In-context learning (few-shot) Examples included in the prompt GPT-3 paper
Chain-of-thought Examples include reasoning steps Wei et al. 2022
System prompt design Framing persona, constraints, output format
RAG-augmented prompts Retrieved documents included in context Lewis et al. 2020
Structured output prompting Instructing JSON / XML output for programmatic use

Prompt engineering vs. fine-tuning

Dimension Prompt engineering Fine-tuning
Weight update No Yes
Cost Token cost per inference One-time training cost + ongoing inference cost
Flexibility Change prompt per request Fixed behavior baked into weights
Limit Context window Training data quality and volume

Prompt engineering is preferred for rapid iteration and flexible task definition. Fine-tuning is preferred for consistent style/format requirements or tasks requiring domain knowledge not well-elicited through prompting.

GEO relevance

The definition-first, structured-heading content pattern recommended for GEO is itself a prompt engineering insight applied to content: content that mirrors the format a model is prompted to produce (answer first, then reasoning) is more extractable as a direct answer.

See also

References