The Free Encyclopedia

Prompt Engineering Patterns

Revision as of Jun 27, 2026 23:47 by albert.

Most LLM problems are solved before fine-tuning or RAG — by prompting better. These are the patterns that reliably move quality.

Core patterns

Pattern What it does
Role / system prompt Set persona, rules, format up front
Few-shot examples Show 2–5 input→output pairs; the model mimics
Chain-of-thought "Think step by step" before answering — big gains on reasoning
Structured output Demand JSON/schema for machine-readable results (Tool Calling & Structured Outputs with Local Models)
Delimiters Fence inputs in ``` or tags so the model knows what's data
Decomposition Break a hard task into chained smaller prompts

Example: few-shot + structure

Extract the company and sentiment as JSON.

Text: "Acme's launch flopped." → {"company":"Acme","sentiment":"negative"}
Text: "TitanCorp crushed earnings." → {"company":"TitanCorp","sentiment":"positive"}
Text: "{{input}}" →

Principles

Smaller local models need tighter prompts and more examples than frontier models.

Related: Fine-tuning vs RAG vs Prompting · Tool Calling & Structured Outputs with Local Models · Agentic Tool-Use Loops