Duration: 45 minutes
Introduction
Not all prompts are created equal. Understanding the components of effective prompts is like learning the ingredients of a great recipe—once you know what goes where and why, you can create variations for any situation.Prompt Components
Every effective prompt can be broken down into four key elements:1
Instruction
What you want the LLM to doClear, actionable directive that specifies the task
2
Context
Background information or constraintsAdditional details that shape how the task should be performed
3
Input Data
The specific content to processThe actual text, code, or information the model should work with
4
Output Indicator
Hints about desired formatSignals about structure, length, or style of the response
Not every prompt needs all four components! Simple tasks might only need an instruction and input, while complex tasks benefit from all four.
Template Structures
Single Variable Template
The simplest form—one placeholder for dynamic content:Multi-Variable Template
Multiple placeholders for different pieces of information:The “Name:Content” Format
A powerful organizational pattern for complex prompts:- Clear structure reduces ambiguity
- Easy to modify individual components
- Helps LLMs parse different types of information
Role Assignment
Assigning a role or persona can dramatically improve output quality:Basic Role Assignment
Role with Specific Expertise
Role with Behavioral Guidelines
Role assignment works because it activates relevant patterns in the model’s training data. When you say “You are a poet,” you’re essentially saying “generate text that matches patterns associated with poetry.”
Common Prompt Formats
Q&A Format
Simple and effective for factual queries:Conversation Continuation
For dialogue generation:Instruction-Following Format
Clear directive with context:Fill-in-the-Blank (Cloze)
Useful for classification and completion:Formatting Techniques
Using Delimiters
Delimiters clearly separate different parts of your prompt:- Triple quotes:
"""
- Triple backticks:
```
- XML-style tags:
<text>...</text>
- Brackets:
[...]
Code-Style Formatting
Particularly effective for pattern-based tasks:Structured Lists
For multi-step or multi-part tasks:Template Examples by Task Type
- Classification
- Extraction
- Generation
- Transformation
Advanced Template Patterns
Conditional Instructions
Multi-Stage Templates
Template with Examples
Best Practices
Be Explicit
Don’t assume the model knows what you want—state it clearly
Use Structure
Organized prompts are easier for models to parse correctly
Provide Context
Background information helps guide appropriate responses
Specify Format
Tell the model how you want the output structured
Common Pitfalls
Avoid these mistakes:
- Vague instructions: “Tell me about climate change” vs. “Explain three main causes of climate change in 150 words”
- Missing context: Not specifying tone, audience, or purpose
- Ambiguous formatting: Unclear where input ends and instruction begins
- Contradictory elements: Asking for “brief but comprehensive” without clarifying priority
Practice Exercise
Create prompt templates for these scenarios:Exercise 1: Email Response Generator
Exercise 1: Email Response Generator
Requirements:
- Role: Professional assistant
- Input: Original email
- Context: Relationship (colleague/client/manager)
- Output: Appropriate response
Sample Solution
Sample Solution
Exercise 2: Code Documentation Generator
Exercise 2: Code Documentation Generator
Requirements:
- Input: Code snippet
- Output: Documentation with description, parameters, returns, examples
Sample Solution
Sample Solution
Exercise 3: Content Summarizer
Exercise 3: Content Summarizer
Requirements:
- Input: Long article
- Context: Target audience and purpose
- Output: Summary with key points
Sample Solution
Sample Solution
Key Takeaways
1
Four Core Components
Instruction, Context, Input Data, Output Indicator—use as needed
2
Templates Enable Reuse
Create templates with variables for consistent, scalable prompting
3
Format Matters
Structure and delimiters help models parse your intent correctly
4
Role Assignment Works
Personas activate relevant patterns in the model’s training
Next Steps
You now understand how to structure effective prompts. Next, you’ll learn how to teach models new tasks through examples—without any training!Continue to Lesson 1.3: In-Context Learning
Discover zero-shot, one-shot, and few-shot learning techniques