Prompt Engineering Fundamentals / Prompt Optimization

Context Setting

Beginner [2/5]
Background provision Contextual framing

Definition

Context setting involves including relevant background information in a prompt to help the LLM understand the situation, domain, and requirements of the task. Good context helps the model generate more relevant and accurate responses.

Context can include domain information, user background, previous decisions, constraints, or any information that would help a human expert perform the task better.

Key Concepts

  • Domain context: Industry, field, or subject matter expertise needed
  • Situational context: The specific circumstances or scenario
  • User context: Information about who will use the output
  • Historical context: Relevant past decisions or events

Examples

Without Context
Missing Background
Prompt: "Should I use a SQL or NoSQL database?" Response: Generic comparison of SQL vs NoSQL...
Without context, the model can only provide generic advice.
With Context
Rich Background
Prompt: "I'm building a social media app expecting 10M users. We need to store user posts, comments, and likes. Read operations will be 100x more frequent than writes. Our team has experience with PostgreSQL. We're on AWS with a limited budget. Should I use SQL or NoSQL database?" Response: Specific recommendation considering scale, team experience, read patterns, and budget...
Rich context enables tailored, actionable advice.

Interactive Exercise

Add Context

This prompt lacks context. Add relevant background information:

Basic: "Write an email declining a meeting."

Pro Tips
  • Ask yourself: "What would an expert need to know?"
  • Include constraints and limitations upfront
  • Mention relevant past decisions or context
  • Balance context with brevity—too much can dilute focus

Related Terms