Skip to main content
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:
Please give me some suggestions for {activity}.
Example:
Please give me some suggestions for a fun weekend.

Multi-Variable Template

Multiple placeholders for different pieces of information:
Here is a sentence: {sentence1}
Here is another sentence: {sentence2}

Compute the semantic similarity between the two sentences.
Example:
Here is a sentence: The cat sat on the mat.
Here is another sentence: A feline rested on the rug.

Compute the semantic similarity between the two sentences.

The “Name:Content” Format

A powerful organizational pattern for complex prompts:
Task: Translation
Source language: English
Target language: Chinese
Style: Formal text
Template: Translate the following sentence: {sentence}
Why it works:
  • 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

You are a computer scientist with extensive knowledge in deep learning.

Please explain the following concept to a 10-year-old child, 
using simple examples.

Concept: {concept}

Role with Specific Expertise

You are a professional copywriter specializing in e-commerce 
product descriptions. You excel at highlighting benefits while 
maintaining authenticity.

Write a product description for: {product}

Role with Behavioral Guidelines

You are a helpful customer service representative. You are:
- Patient and empathetic
- Clear and concise in explanations
- Focused on solving problems
- Professional but friendly

Customer inquiry: {inquiry}
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:
Q: What causes seasons on Earth?
A:

Conversation Continuation

For dialogue generation:
John: How was your day?
David: Pretty good, thanks for asking!
John: Did you finish that project?
David:

Instruction-Following Format

Clear directive with context:
Instruction: Summarize the following article in 3 bullet points.

Article: {article_text}

Summary:

Fill-in-the-Blank (Cloze)

Useful for classification and completion:
The sentiment of the review "This product exceeded my expectations!" 
is ___.

Options: positive, negative, neutral

Formatting Techniques

Using Delimiters

Delimiters clearly separate different parts of your prompt:
Translate the following text (delimited by triple quotes) to German.

Text: """I have an orange."""

Translation:
Common delimiters:
  • Triple quotes: """
  • Triple backticks: ```
  • XML-style tags: <text>...</text>
  • Brackets: [...]

Code-Style Formatting

Particularly effective for pattern-based tasks:
[English] = [I have an apple.]
[German] = [Ich habe einen Apfel.]
[English] = [I have an orange.]
[German] =

Structured Lists

For multi-step or multi-part tasks:
Analyze the following text and provide:

1. Main topic
2. Key arguments (list 3)
3. Tone (formal/informal/neutral)
4. Target audience

Text: {text}

Template Examples by Task Type

  • Classification
  • Extraction
  • Generation
  • Transformation
Task: Sentiment Classification
Categories: Positive, Negative, Neutral

Text: "{text}"

Classification:

Advanced Template Patterns

Conditional Instructions

You are a writing assistant. Analyze the following text and:

IF the text is less than 100 words:
  - Expand it to at least 200 words
  - Add more descriptive details
  
IF the text is more than 500 words:
  - Summarize to under 300 words
  - Keep key points

Text: {text}

Multi-Stage Templates

Stage 1: Read and understand the following code
Stage 2: Identify any bugs or issues
Stage 3: Suggest improvements
Stage 4: Provide corrected version

Code:
{code}

Analysis:

Template with Examples

Task: Convert casual text to professional tone

Example 1:
Input: "Hey, can u send me that file?"
Output: "Could you please send me that file?"

Example 2:
Input: "Thx for ur help!"
Output: "Thank you for your assistance."

Now convert:
Input: "{casual_text}"
Output:

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:
  1. Vague instructions: “Tell me about climate change” vs. “Explain three main causes of climate change in 150 words”
  2. Missing context: Not specifying tone, audience, or purpose
  3. Ambiguous formatting: Unclear where input ends and instruction begins
  4. Contradictory elements: Asking for “brief but comprehensive” without clarifying priority

Practice Exercise

Create prompt templates for these scenarios:
Requirements:
  • Role: Professional assistant
  • Input: Original email
  • Context: Relationship (colleague/client/manager)
  • Output: Appropriate response
You are a professional email assistant.

Relationship: {relationship}
Tone: {formal/friendly/neutral}

Original email:
"""
{original_email}
"""

Write an appropriate response that:
- Addresses all points raised
- Maintains professional tone
- Is concise (under 200 words)

Response:
Requirements:
  • Input: Code snippet
  • Output: Documentation with description, parameters, returns, examples
You are a technical documentation specialist.

Generate comprehensive documentation for the following code:

Code:

Documentation should include:
1. Brief description (1-2 sentences)
2. Parameters (name, type, description)
3. Return value (type, description)
4. Usage example
5. Edge cases or notes

Documentation:
Requirements:
  • Input: Long article
  • Context: Target audience and purpose
  • Output: Summary with key points
Task: Article Summarization
Target audience: {audience}
Purpose: {purpose}
Length: {word_count} words

Article:
"""
{article_text}
"""

Create a summary that:
- Captures main arguments
- Highlights key data/facts
- Maintains original tone
- Is accessible to target audience

Summary:

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
I