Home β†’ ChatGPT & Prompt Engineering β†’ Module 3

Module 3: Advanced Prompting Techniques

Power user techniques: few-shot learning, chain-of-thought, and parameter control

πŸ“… Week 1 πŸ“Š Intermediate

You: "Calculate 47 x 23 and explain your reasoning step-by-step."

ChatGPT: "Let me think through this... 47 x 20 = 940, then 47 x 3 = 141, so 940 + 141 = 1,081."

That's chain-of-thought prompting β€” one of several advanced techniques that unlock ChatGPT's full reasoning capabilities. These techniques separate casual users from power users earning $150K+ as prompt engineers.

πŸ’‘ By the end of this module, you'll master:

  • Zero-shot vs few-shot prompting (when to use each)
  • Chain-of-thought reasoning for complex problems
  • Role-based prompting for expert-level outputs
  • System messages and conversation control
  • Temperature, top-p, and other parameters

🎯 Technique 1: Zero-Shot vs Few-Shot Prompting

Zero-Shot Prompting

What it is: Giving ChatGPT a task without examples, relying on its pre-training to understand.

Example:

Classify this product review sentiment: "The laptop is okay but battery life is terrible."
Output: Negative (mentions "terrible" battery life, dampens "okay")

When to use: Simple, well-defined tasks ChatGPT already understands (sentiment analysis, translation, basic Q&A).

Few-Shot Prompting

What it is: Providing 2-5 examples before asking ChatGPT to perform the task. Shows the pattern you want.

Example:

Classify product review sentiment. Examples: Review: "Love this phone! Fast and sleek." Sentiment: Positive Review: "Terrible customer service, never buying again." Sentiment: Negative Review: "It's decent for the price." Sentiment: Neutral Now classify: "The laptop is okay but battery life is terrible."
Output: Negative (recognizes mixed sentiment leans negative due to "terrible")

When to use: Custom formats, nuanced tasks, or when you want specific style/structure. Examples train ChatGPT on your patterns.

βœ… Zero-Shot Wins
  • Standard tasks (translate, summarize)
  • Quick one-off requests
  • When examples are hard to provide
  • General knowledge questions
βœ… Few-Shot Wins
  • Custom output formats
  • Domain-specific jargon
  • Complex classification tasks
  • Matching your brand voice

🧠 Technique 2: Chain-of-Thought (CoT) Prompting

What is Chain-of-Thought?

Concept: Asking ChatGPT to "think step-by-step" or "explain your reasoning" before answering. Forces sequential logic instead of jumping to conclusions.

Why it works: Large language models perform better on complex reasoning when they break problems into steps (just like humans).

πŸ“Š Research finding: Adding "Let's think step-by-step" improved GPT-3 accuracy on math problems from 17% to 78% (Google Research, 2022).

CoT Example 1: Math Problem

❌ Without CoT
A store has 23 apples. They sell 7, then receive 15 more. How many do they have?
Output: 31 apples. (Correct, but no reasoning shown)
βœ… With CoT
A store has 23 apples. They sell 7, then receive 15 more. How many do they have? Let's think step-by-step.
Output:
Step 1: Start with 23 apples
Step 2: Sell 7 β†’ 23 - 7 = 16 apples
Step 3: Receive 15 β†’ 16 + 15 = 31 apples
Final answer: 31 apples

CoT Example 2: Logic Problem

Question: If all roses are flowers, and some flowers fade quickly, can we conclude that some roses fade quickly? Think through this step-by-step using logical reasoning.
ChatGPT's reasoning:

Step 1: Analyze premise 1 β†’ "All roses are flowers" (roses βŠ‚ flowers)
Step 2: Analyze premise 2 β†’ "Some flowers fade quickly" (doesn't specify which flowers)
Step 3: Check logical connection β†’ Premise 2 doesn't guarantee roses are in the "some flowers" subset
Step 4: Conclusion β†’ No, we cannot conclude this. The roses might not be the flowers that fade quickly.

🎯 CoT Trigger Phrases

  • "Let's think step-by-step."
  • "Explain your reasoning before answering."
  • "Break this down into steps."
  • "Walk me through your thought process."
  • "First, analyze... Then, conclude..."

🎭 Technique 3: Role-Based Prompting

What is Role-Based Prompting?

Concept: Telling ChatGPT to act as a specific expert (lawyer, doctor, data scientist, comedian, etc.). This shapes vocabulary, depth, and perspective.

Why it works: Pre-training data includes countless examples of how different experts write/speak. Role assignment activates relevant patterns.

Example: Same Question, Different Roles

Question: "How do I reduce stress?"

πŸ§‘β€βš•οΈ As a Clinical Psychologist:

Act as a clinical psychologist with 15 years of experience. How do I reduce stress?
Response: "From a clinical perspective, chronic stress activates your HPA axis, releasing cortisol. Evidence-based interventions include: 1) Cognitive Behavioral Therapy (CBT) to reframe negative thought patterns, 2) Progressive Muscle Relaxation (PMR) to reduce physiological arousal, 3) Mindfulness-Based Stress Reduction (MBSR) β€” 8-week programs show 30% cortisol reduction..."

πŸ‹οΈ As a Fitness Coach:

Act as a certified fitness coach. How do I reduce stress?
Response: "Exercise is your secret weapon! Here's what works: 1) 30 minutes cardio 3x/week releases endorphins (natural mood boosters), 2) Strength training builds resilience, 3) Yoga combines movement + breathwork, 4) Even a 10-minute walk outdoors reduces cortisol 15%. Start small: commit to one 20-minute workout tomorrow..."

🧘 As a Buddhist Monk:

Act as a Buddhist monk who teaches mindfulness. How do I reduce stress?
Response: "Stress arises from attachment and resistance to what is. Practice: 1) Observe thoughts without judgment β€” they are clouds passing through sky of awareness, 2) Return to breath β€” the anchor to present moment, 3) Accept impermanence β€” this too shall pass. Daily sitting meditation: start with 5 minutes. Not to eliminate stress, but to change relationship with it..."

πŸ’‘ Pro tip: Combine role + expertise level + context for maximum precision:

"Act as a senior data scientist at Netflix with 10 years of experience in recommendation systems. Explain collaborative filtering to a product manager..."

βš™οΈ Technique 4: System Messages & Conversation Control

What are System Messages?

Concept: In API/advanced interfaces, system messages set persistent behavior for entire conversation. Think of it as ChatGPT's "operating instructions."

In ChatGPT web: Use "Custom Instructions" (Settings β†’ Personalization) to set default behavior.

Example Custom Instructions:

What would you like ChatGPT to know about you? I'm a product manager at a B2B SaaS startup. I work with engineers, designers, and executives. I value data-driven decisions. How would you like ChatGPT to respond? - Be concise (max 3 paragraphs unless I ask for detail) - Use bullet points for lists - Include relevant metrics/data when discussing strategy - Avoid jargon without explanation - End responses with 1-2 follow-up questions

Result: Every response is now tailored to your role and preferences automatically.

Powerful System Message Templates

1. The Socratic Teacher

You are a Socratic tutor. Never give direct answers. Instead, ask questions that guide me to discover the answer myself. If I'm stuck, provide hints.

2. The Ruthless Editor

You are a ruthless editor. Prioritize clarity and concision. Cut unnecessary words. Point out weak arguments. Be direct but constructive.

3. The Expert Consultant

You are a senior consultant at McKinsey. Structure all responses using: 1) Key insight upfront, 2) Supporting evidence, 3) Actionable recommendation. Use frameworks (SWOT, Porter's 5 Forces) when relevant.

πŸŽ›οΈ Technique 5: Controlling Parameters (Temperature, Top-P)

Advanced Controls (API/Pro Users)

Temperature (0.0 - 2.0)

What it controls: Randomness/creativity of outputs.

0.0 (Deterministic)
2.0 (Chaotic)
  • Low (0.0-0.3): Factual, consistent, predictable. Use for: data extraction, code, technical writing
  • Medium (0.7-1.0): Balanced. Default for most tasks
  • High (1.5-2.0): Creative, surprising, risky. Use for: brainstorming, creative writing, unconventional ideas

Example: "Write a tagline for eco-friendly shoes"

Temperature 0.1: "Sustainable footwear for a better planet."

Temperature 1.5: "Walk softly, leave only footprints of change."

Top-P / Nucleus Sampling (0.0 - 1.0)

What it controls: Diversity of word choices. Limits AI to top X% probability words.

  • Low (0.1-0.5): Focused, safe word choices
  • High (0.9-1.0): Allows rare, unexpected words

Pro tip: Use high temperature OR high top-p, not both. Combining amplifies chaos.

Max Tokens

What it controls: Maximum response length (1 token β‰ˆ 0.75 words).

Use case: Force concise responses (max 100 tokens) or allow long-form content (max 4000 tokens).

⚠️ Note: ChatGPT web interface doesn't expose these controls (except via Custom Instructions). API users and ChatGPT Plus with Advanced Data Analysis can adjust parameters.

πŸ“Š Technique 6: Structured Outputs & JSON Mode

The Problem with Unstructured Responses

You ask ChatGPT for product data, and it responds: "Sure! Here's the information you requested: The product is called..." β€” mixing explanatory text with data, making parsing impossible.

The solution: Request structured outputs (especially JSON) with clear schemas. ChatGPT will return clean, parseable data you can use in code, databases, or APIs.

Why JSON Mode Matters

  • βœ… Parse data reliably: No extra text to strip away
  • βœ… Integrate with code: Direct API/database insertion
  • βœ… Validate structure: Ensure required fields are present
  • βœ… Scale workflows: Batch process hundreds of responses
  • βœ… Professional AI apps: Table stakes for production systems

Basic JSON Request

Extract product information and return as valid JSON with this schema: { "product_name": string, "price": number, "features": array of strings, "rating": number (1-5), "in_stock": boolean } Source text: "The UltraBook Pro laptop costs $1,299. Key features include 16GB RAM, 1TB SSD, and 14-hour battery life. Customers rate it 4.7 out of 5 stars. Currently available for immediate shipping." Return ONLY valid JSON, no explanatory text before or after.
{ "product_name": "UltraBook Pro", "price": 1299, "features": ["16GB RAM", "1TB SSD", "14-hour battery life"], "rating": 4.7, "in_stock": true }

Advanced: Multi-Object JSON

Extract all products from this page and return as a JSON array. Schema for each product: { "name": string, "brand": string, "price": number, "discount_percent": number or null, "colors": array of strings } [Paste product listing HTML or text here] Return format: {"products": [...]} No markdown formatting. Pure JSON only.

Schema Design Best Practices

Tips for bulletproof JSON schemas:

  1. Be explicit about types: string, number, boolean, array, object
  2. Specify required vs optional fields: Use "or null" for optional
  3. Give examples: Show 1-2 sample outputs
  4. Request validation: "Ensure all fields are present before returning"
  5. Handle missing data: Specify defaults (null, empty array, etc.)

Error Handling & Validation

Extract customer feedback and return JSON: { "sentiment": "positive" | "negative" | "neutral", "score": number (1-10), "key_themes": array of strings (max 3), "urgency": "low" | "medium" | "high" } Before returning: 1. Validate all fields are present 2. Ensure sentiment is one of the 3 allowed values 3. Ensure score is between 1-10 4. If any field can't be determined, use null Source: [customer review text]

Real-World Use Cases

πŸ“Š Data Extraction

Extract structured data from unstructured text, PDFs, or images (via vision)

πŸ”Œ API Integration

Generate JSON that directly feeds into your application's API endpoints

πŸ“‹ Form Filling

Convert conversational inputs into structured form data

πŸ“ˆ Report Generation

Create consistent, parseable reports for dashboards and analytics

⚠️ Common Mistakes:

  • Forgetting "no extra text": Always emphasize "return ONLY JSON"
  • Vague schemas: Be explicit about every field type and structure
  • No validation: Ask ChatGPT to validate before returning
  • Not handling nulls: Specify what to do when data is missing

🎯 Practice Exercise

Challenge: Design a JSON schema and prompt for extracting job postings

Requirements:

  • Job title, company, location, salary range
  • Required skills (array), experience years (number)
  • Remote/hybrid/onsite (enum)
  • Handle missing data gracefully

Test with: 2-3 real job posting paragraphs

🧠 Technique 7: Advanced Reasoning Patterns

Beyond basic chain-of-thought, these patterns unlock deeper reasoning for complex problems.

ReAct: Reasoning + Acting

What it is: Interleave thinking (reasoning) with actions (tool use, lookups, calculations). Think β†’ Act β†’ Observe β†’ Repeat.

Best for: Multi-step problems requiring external information or calculations

Answer this question using ReAct (Reasoning + Acting) pattern: "What's the current market cap of Apple compared to 5 years ago?" Format: Thought: [Your reasoning] Action: [What information you need] Observation: [What you found/calculated] Thought: [Next reasoning step] ... (repeat until final answer) Answer: [Final conclusion]

Self-Consistency: Multiple Paths to Truth

What it is: Generate multiple independent reasoning paths, then identify the consensus answer. Reduces errors on complex problems.

Best for: Math, logic puzzles, critical decisions

Solve this problem using 3 different approaches, then identify the consensus answer: Problem: "A store offers 20% off, then an additional 10% off the sale price. If an item originally costs $100, what's the final price?" Approach 1: [Calculate step-by-step] Approach 2: [Use a different method] Approach 3: [Verify with alternative logic] Consensus answer: [If all 3 agree, that's the answer. If not, identify the error.]

Reflection: Self-Critique & Improve

What it is: Ask ChatGPT to critique its own response and improve it. Creates iterative refinement loop.

Best for: Writing, strategy, analysisβ€”anything benefiting from revision

Write a cold outreach email for B2B sales. Then: 1. Critique your own email: What's weak? What could be better? 2. Rewrite it addressing those critiques 3. Final version only (no explanations)

Advanced version:

[Your initial task/question] After completing, do a self-review: - Score your answer 1-10 on: accuracy, completeness, clarity - Identify 2-3 specific weaknesses - Provide an improved version addressing those weaknesses - Explain what makes the improved version better

Tree-of-Thought: Explore Multiple Reasoning Branches

What it is: Instead of one linear reasoning chain, explore multiple paths simultaneously, evaluate each, then choose the best.

Best for: Strategic decisions, creative problems, complex tradeoffs

Problem: Should our startup expand to Europe or double down on North America? Use tree-of-thought reasoning: Branch 1: Optimistic expansion scenario - Key assumptions: [...] - Pros: [...] - Cons: [...] - Likely outcome: [...] Branch 2: Conservative consolidation scenario - Key assumptions: [...] - Pros: [...] - Cons: [...] - Likely outcome: [...] Branch 3: Data-driven hybrid approach - Key assumptions: [...] - Pros: [...] - Cons: [...] - Likely outcome: [...] Evaluation: Which branch has the strongest reasoning? Why? Recommendation: [Choose best path with rationale]

When to Use Each Pattern

Use ReAct when...
  • Need external information
  • Multi-step research required
  • Problem needs tool/calculation use
Use Self-Consistency when...
  • High stakes decision
  • Math or logic problems
  • Need error checking
Use Reflection when...
  • Quality matters most
  • Creative/strategic work
  • Time for iteration
Use Tree-of-Thought when...
  • Complex tradeoffs
  • Multiple viable paths
  • Strategic planning

🎯 Practice Challenge

Pick one pattern and apply it:

Problem: "Should I quit my job to start a business?"

  • ReAct: Research β†’ Think β†’ Research more
  • Self-Consistency: 3 different risk analyses
  • Reflection: Initial advice β†’ Critique β†’ Better advice
  • Tree-of-Thought: Quit now vs wait 6mo vs side hustle first

Which pattern gives you the most insight?

πŸš€ Power Move: Combining Techniques

Ultimate Prompt Template (All Techniques)

[ROLE] Act as a senior financial analyst at Goldman Sachs with 15 years of experience. [CONTEXT] I'm evaluating whether to invest $50K in cryptocurrency. [FEW-SHOT EXAMPLES] When analyzing investments, use this format: - Risk level: [High/Medium/Low] - Timeframe: [Short/Medium/Long-term] - Key factors: [3-5 bullets] - Recommendation: [Clear yes/no with reasoning] [CHAIN-OF-THOUGHT] Think through this step-by-step: 1. Assess market conditions 2. Evaluate risk vs potential return 3. Consider my situation 4. Provide recommendation [SPECIFIC ASK] Should I invest in cryptocurrency now? Use the format above.

Result: Highly structured, expert-level analysis that matches your needs exactly.

🎯 Hands-On Exercise: Technique Testing Lab

πŸ“ Test Each Technique

Task: Try the same question with different techniques, compare results.

Question: "How can I improve my website's conversion rate?"

  1. Zero-shot: Ask the question directly.
    Observe: Generic advice?
  2. Few-shot: Provide 2 examples of analysis you like, then ask.
    Observe: Does it match your style?
  3. Chain-of-thought: "Let's think step-by-step. First analyze current state, then identify bottlenecks, then suggest improvements."
    Observe: More structured reasoning?
  4. Role-based: "Act as a conversion rate optimization expert at Amazon..."
    Observe: More specific tactics?
  5. Combined: Use role + CoT + examples.
    Observe: Best quality output?

Reflection: Which technique gave you the most valuable answer? Why?

πŸ“š Summary: Advanced Techniques Arsenal

  • βœ… Zero-shot vs few-shot: No examples vs 2-5 examples to train patterns
  • βœ… Chain-of-thought: "Think step-by-step" β†’ 78% accuracy boost on reasoning tasks
  • βœ… Role-based prompting: "Act as [expert]" β†’ shapes vocabulary, depth, perspective
  • βœ… System messages: Custom Instructions for persistent behavior across conversations
  • βœ… Parameters: Temperature (creativity), top-p (diversity), max tokens (length)
  • βœ… Combining techniques: Role + CoT + few-shot = ultimate precision

🎯 Key Takeaway: These techniques aren't just "tricks" β€” they're how professional prompt engineers earn $150K+. Master them, and you'll extract 10x more value from ChatGPT than 95% of users. Next, we'll package these into reusable frameworks.

πŸ“ Test Your Understanding

Question 1: What's the main difference between zero-shot and few-shot prompting?

Zero-shot is always better
Few-shot provides 2-5 examples to show the pattern you want
They're the same thing
Few-shot only works for coding

Question 2: What does chain-of-thought prompting do?

Forces ChatGPT to show step-by-step reasoning before answering
Makes responses longer
Only works for math problems
Slows down ChatGPT unnecessarily

Question 3: What does low temperature (0.0-0.3) produce?

More creative, random outputs
Slower responses
Deterministic, factual, consistent outputs
Shorter responses

Question 4: Why does role-based prompting work?

It's just a placebo effect
Training data includes examples of how different experts write, roles activate relevant patterns
ChatGPT actually becomes an expert
Only works with medical/legal roles

Question 5: What's the best approach for complex reasoning tasks?

Just ask the question directly
Use high temperature for creativity
Combine role-based + chain-of-thought + specific examples
Keep prompts as short as possible

πŸŽ“ Advanced AI Learning Paths

You've mastered advanced techniques. Take your skills to professional level with specialized courses and certifications:

πŸ†

ChatGPT Prompt Engineering for Developers

Coursera (DeepLearning.AI) | Free Audit / $49 Certificate

Taught by Andrew Ng: Learn directly from the pioneer of modern AI. This course covers prompt engineering best practices, API usage, and building AI applications. Highly recognized certification for your resume.

πŸ’‘ Perfect for: Developers and technical professionals who want university-quality education from AI pioneers. Includes hands-on coding exercises and API integration projects.

  • Expert Instructors: Andrew Ng + Isa Fulford (OpenAI)
  • Hands-On Projects: Build real AI applications
  • Shareable Certificate: Add to LinkedIn
  • Flexible Schedule: Complete at your pace
Enroll on Coursera β†’
πŸš€

Advanced ChatGPT & API Mastery

Udemy | β‚Ή499-899

Practical implementation: 15-25 hour courses covering advanced techniques, API integration, custom GPT building, and real-world business applications. Great for hands-on learners.

  • API Integration: Python scripts with OpenAI API
  • Custom GPTs: Build specialized AI assistants
  • Business Cases: Real-world implementation examples
  • Q&A Support: Direct instructor access
Browse Advanced Courses β†’

πŸš€ Next Step: Master Proven Frameworks

You've learned individual techniques. Now let's package them into battle-tested frameworks β€” RISEN, RTF, CRAFT β€” that prompt engineers use for consistent, high-quality results every time.

Coming up in Module 4: Learn three proven prompt frameworks (RISEN, RTF, CRAFT) that structure your thinking and deliver professional-grade outputs. Plus, build your personal prompt template library.