Leaf decoration

Prompt Engineering Fundamentals

Unit: 3
Book Icon

Generative AI & Prompt Engineering

This module introduces the essential art of Prompt Engineering, the key skill for unlocking the full potential of Generative AI. Learners will explore...

AI-Powered
TL;DR — Quick Summary
Click Generate Summary to get a quick AI-powered overview of this chapter.
Gemini is reading the chapter...
    Could not generate summary. Please try again.
    Explain This
    AI Explanation
    Explaining...

    Could not explain. Try again.
    MCQ Practice

    Lesson 3.1: What is Prompt Engineering?

    What is Prompt Engineering?

    Prompt Engineering is the process of designing and refining text instructions (prompts) given to large language models (LLMs) to elicit desired responses. It bridges human intent and AI capability. Unlike traditional programming where you write code, here you “program” the AI through natural language.

    Good prompt engineering can dramatically improve output quality, reduce hallucinations (made-up information), save time, and unlock creative or complex problem-solving abilities of AI.

    Why Prompts Matter

    • AI is not truly intelligent — it predicts the most likely next words based on patterns in its training data. A vague prompt leads to vague or irrelevant outputs.
    • Efficiency: Well-crafted prompts reduce the need for multiple iterations and editing.
    • Consistency: Structured prompts help generate reliable results across sessions and different models.
    • Control: You can control tone, depth, style, length, and format.
    • Real-world impact: From writing professional emails to coding, data analysis, lesson planning, or creative storytelling — prompt quality determines success.

    Prompt Anatomy (Structure)

    A strong prompt typically follows this structure:

    Role + Task + Context + Constraints + Output Format

    • Role: Assign a persona or expertise level to the AI (e.g., “You are an experienced science teacher”).
    • Task: Clearly state what you want the AI to do (e.g., “Explain the concept of…”).
    • Context: Provide necessary background information (e.g., target audience, prior knowledge).
    • Constraints: Set boundaries (word limit, avoid certain topics, tone, etc.).
    • Output Format: Specify how the response should be structured (bullet points, table, JSON, essay, etc.).

    Example:

    Bad Prompt:

    Write about climate change.
    

    Problems with this prompt:

    • No role → generic response.
    • Vague task → too broad.
    • No context, constraints, or format → unpredictable length, depth, and style.

    Good Prompt:

    Act as a science teacher with 10 years of experience teaching middle school.
    
    Explain climate change to Grade 8 students.
    
    Use simple language, avoid jargon, and include real-life Nepali examples where possible.
    
    Give exactly 3 clear examples of its effects in Nepal or the Himalayas.
    
    Limit the entire response to 300 words.
    
    Output format: Start with a short definition, followed by causes, effects (with examples), and end with one actionable step students can take.
    

    Why the good prompt works:

    • Sets clear expectations.
    • Guides depth and style.
    • Reduces ambiguity.
    • Makes output immediately usable.

    Practice Exercise (30 minutes):

    1. Take 3 weak prompts from daily use (e.g., “Help me write an email”).
    2. Rewrite them using the Role + Task + Context + Constraints + Output Format structure.
    3. Test on Grok or any AI tool and compare results.

    Lesson 3.2: Prompting Techniques

    1. Zero-Shot Prompting

    The model performs the task without any examples.

    Example:

    Summarize this article in 5 bullet points: [paste article text]
    

    When to use: Simple, straightforward tasks where the model already knows how to do it.

    2. Few-Shot Prompting

    Provide 1–5 examples (shots) before asking for the new task. This teaches the model the pattern through demonstration.

    Example:

    Classify the sentiment of the following reviews as Positive, Negative, or Neutral.
    
    Review 1: "The food was delicious and service was fast." → Positive
    Review 2: "Wait time was too long and taste was average." → Negative
    
    Review 3: "The new phone has great battery life but the camera is disappointing."
    

    When to use: Tasks needing specific style, format, or reasoning patterns.

    3. Chain-of-Thought (CoT) Prompting

    Encourage the model to think step by step. This significantly improves performance on reasoning, math, logic, and complex problem-solving tasks.

    Example:

    Solve this problem step by step.
    
    A shopkeeper buys pens at Rs. 10 each and sells them at Rs. 15 each. If he makes a profit of Rs. 500, how many pens did he sell?
    
    Think step by step before giving the final answer.
    

    Variant: “Let’s think step by step.”

    4. Step-by-Step Prompting

    Break complex tasks into sequential steps explicitly.

    Example:

    Create a business plan for a small cafe in Kathmandu.
    
    Follow these steps:
    1. Market research summary
    2. Target customers
    3. Menu ideas
    4. Pricing strategy
    5. Marketing plan
    6. Financial projections (first 6 months)
    

    5. Iterative Prompting

    Refine outputs progressively through follow-up prompts.

    Process:

    1. First prompt → Generate initial output.
    2. Second prompt → “Improve this by adding more Nepali cultural references.”
    3. Third prompt → “Make it shorter and more engaging for social media.”

    Best Practice: Always refer to previous output: “Based on your previous response, now...”

    Hands-on Lab (1.5 hours):

    • Experiment with the same task using Zero-shot, Few-shot, and Chain-of-Thought.
    • Document which technique gave the best result and why.
    • Try iterative refinement on a creative writing or coding task.

    Lesson 3.3: Prompt Frameworks

    1. RTF Framework

    Role – Task – Format

    Simple and effective for quick prompts.

    Example:

    • Role: You are a professional career counselor.
    • Task: Help me prepare for a job interview for a software engineering position.
    • Format: Provide 10 most common questions with sample strong answers tailored to a fresh graduate from Nepal.

    2. CREATE Framework

    Context – Role – Examples – Action – Tone – Expected Output

    Comprehensive framework for complex tasks.

    Breakdown:

    • Context: Background information.
    • Role: Persona.
    • Examples: Few-shot examples.
    • Action: Specific task.
    • Tone: Desired style (professional, friendly, motivational, etc.).
    • Expected Output: Exact format and criteria.

    3. SMART Prompting

    Adapted from SMART goals:

    • Specific
    • Measurable
    • Actionable
    • Relevant
    • Time-bound (or Token/Length-bound)

    Example:

    Specific: Create a 7-day lesson plan for Grade 9 Science on "Human Body Systems".
    Measurable: Include learning objectives, activities, and assessment for each day.
    Actionable: Provide ready-to-use classroom activities.
    Relevant: Align with Nepal's national curriculum.
    Time-bound: Each lesson 45 minutes.
    

    Comparison Table:

    FrameworkBest ForComplexityUse Case Example
    RTFQuick tasksLowEmail writing, summaries
    CREATEComplex, creative workMediumContent creation, reports
    SMARTGoal-oriented, educationMediumLesson plans, project planning

    Practice Exercise (1.5 hours):

    1. Convert the climate change example into RTF, CREATE, and SMART versions.
    2. Create 5 original prompts using different frameworks.
    3. Test them and evaluate output quality.

    Module Assessment

    • Quiz: 10 multiple-choice + 5 prompt improvement questions.
    • Assignment: Design a complete prompt library for your profession/studies (minimum 10 prompts using different techniques and frameworks).
    • Project: Build a “Prompt Cookbook” document covering common tasks in your field.

    Key Takeaways:

    • Always structure your prompts.
    • Match technique to task complexity.
    • Iterate and experiment — prompt engineering is iterative.
    • Great prompts turn good AI into exceptional AI.

    Recommended Resources (for further reading):

    • Prompt examples gallery
    • Common pitfalls and how to avoid them
    • Model-specific tips (Grok, GPT, Claude)

    Share Now

    Share to help more learners!

    Resources
    Lesson Contents