Basic Prompting Techniques

Master essential prompting techniques: zero-shot, few-shot, chain-of-thought, multimodal, function calling, and RAG. Learn when and how to use each technique.

Level 101basicprompt engineeringbasic techniqueszero-shotone-shotfew-shotchain-of-thoughtmultimodal aifunction callingragai promptingllm techniquesprompt optimizationai communication
12 mins

Now that you understand the fundamentals of prompt engineering, let's dive into the core prompting techniques that will form the foundation of your prompt engineering skills.

What You'll Learn

By the end of this lesson, you'll be able to:

  • ✅ Master zero-shot, one-shot, and few-shot prompting techniques
  • ✅ Apply chain-of-thought prompting for complex reasoning
  • ✅ Use multimodal prompting with images and text
  • ✅ Implement function calling and RAG techniques
  • ✅ Choose the right technique for different scenarios

Zero-Shot Prompting

Zero-shot prompting is when you ask an AI to perform a task without providing any examples. The model relies entirely on its pre-trained knowledge.

When to Use Zero-Shot

  • Simple, straightforward tasks
  • Common knowledge questions
  • Basic text generation
  • When you want quick results

Examples

Text Classification
Classify this text as positive, negative, or neutral: 'I absolutely love this new restaurant!'

Direct instruction for sentiment analysis

Translation
Translate this sentence to French: 'The weather is beautiful today.'

Simple translation request

Summarization
Summarize this article in 2-3 sentences: [article text]

Concise summary request

One-Shot Prompting

One-shot prompting provides a single example to guide the AI's response. This helps the model understand the expected format and style.

When to Use One-Shot

  • When you need specific formatting
  • For tasks that benefit from examples
  • When zero-shot isn't giving desired results
  • To establish a particular style or tone

Examples

Email Writing
Write a professional email declining a meeting invitation. Example: Subject: Re: Meeting Request - March 15th Hi Sarah, Thank you for reaching out about the meeting on March 15th. Unfortunately, I have a prior commitment that day and won't be able to attend. I'd be happy to reschedule for another time that works for both of us. Please let me know your availability for the following week. Best regards, [Your name] Now write a professional email accepting a job offer:

One example to establish email format and tone

Code Generation
Write a Python function to calculate the factorial of a number. Example: def calculate_factorial(n): if n == 0 or n == 1: return 1 return n * calculate_factorial(n - 1) Now write a Python function to calculate the Fibonacci sequence:

One example to establish code structure and style

Few-Shot Prompting

Few-shot prompting provides multiple examples to establish a clear pattern. This is especially effective for complex tasks or when you need consistent formatting.

When to Use Few-Shot

  • Complex tasks requiring multiple examples
  • When you need consistent output format
  • For tasks with multiple possible approaches
  • When one-shot isn't sufficient

Examples

Sentiment Analysis
Analyze the sentiment of these reviews: Review: 'This product exceeded my expectations!' Sentiment: Positive Reason: Expresses satisfaction and enthusiasm Review: 'The quality is terrible and it broke after one week.' Sentiment: Negative Reason: Expresses disappointment and product failure Review: 'It's okay, nothing special but gets the job done.' Sentiment: Neutral Reason: Expresses neither strong positive nor negative feelings Review: 'Absolutely amazing service and fast delivery!' Sentiment:

Multiple examples to establish sentiment analysis pattern

Problem Solving
Solve these math problems step by step: Problem: What is 15% of 200? Solution: 15% = 0.15, so 0.15 × 200 = 30 Problem: If a shirt costs $25 and is on sale for 20% off, what is the final price? Solution: 20% off = 0.20 × $25 = $5 discount, so $25 - $5 = $20 Problem: A recipe calls for 2 cups of flour for 8 servings. How much flour is needed for 12 servings? Solution: This is a proportion problem. 2 cups for 8 servings means 0.25 cups per serving. For 12 servings: 0.25 × 12 = 3 cups

Multiple examples to establish problem-solving pattern

Chain-of-Thought Prompting

Chain-of-thought (CoT) prompting encourages the AI to show its reasoning process step by step. This is particularly useful for complex problem-solving tasks.

When to Use Chain-of-Thought

  • Complex reasoning problems
  • Mathematical calculations
  • Logical puzzles
  • When you want to understand the AI's thinking process
  • Debugging and troubleshooting

Examples

Mathematical Reasoning
Let's solve this step by step: A store sells shirts for $30 each. They have a sale where you get 20% off if you buy 3 or more shirts. How much would 5 shirts cost? Let me think through this: 1. First, calculate the total cost without discount: 5 shirts × $30 = $150 2. Since we're buying 5 shirts (more than 3), we get 20% off 3. Calculate the discount: $150 × 0.20 = $30 4. Final cost: $150 - $30 = $120 So 5 shirts would cost $120. Now solve this: A restaurant bill is $85. If you want to leave a 15% tip, what is the total amount?

Step-by-step reasoning for complex calculations

Logical Reasoning
Let's think through this logically: If all roses are flowers, and some flowers are red, can we conclude that some roses are red? Let me analyze this step by step: 1. All roses are flowers (given) 2. Some flowers are red (given) 3. However, this doesn't guarantee that the red flowers include roses 4. The red flowers could be tulips, daisies, or other types 5. Therefore, we cannot conclude that some roses are red The answer is: No, we cannot conclude that some roses are red. Now analyze this: If all students are learners, and some learners are curious, can we conclude that some students are curious?

Step-by-step logical analysis

Advanced Prompting Techniques

Multimodal Prompting

Multimodal prompting involves using multiple types of input (text, images, audio, video) to get more comprehensive responses from AI models.

When to Use Multimodal

  • When you need to analyze visual content
  • For tasks requiring both text and image understanding
  • When working with documents, charts, or diagrams
  • For creative tasks involving multiple media types

Examples

Image Analysis
Analyze this product image and provide: 1. Product description 2. Potential target audience 3. Marketing suggestions 4. Pricing recommendations [Upload product image]

Multimodal prompt combining text and image input

Document Analysis
Review this invoice and extract: - Invoice number - Total amount - Due date - Line items - Any discrepancies [Upload invoice image]

Multimodal prompt for document processing

Function Calling

Function calling allows AI models to execute specific functions or API calls based on your prompts, enabling more interactive and dynamic responses.

When to Use Function Calling

  • When you need real-time data
  • For tasks requiring external API integration
  • When you want the AI to perform actions
  • For dynamic content generation

Examples

Weather Information
Get the current weather in New York and suggest appropriate clothing for today's activities

Function calling for real-time weather data

Real-time Data
Check the current stock price of Apple and provide a brief market analysis

Function calling for live market data

RAG (Retrieval-Augmented Generation)

RAG combines AI generation with external knowledge retrieval, allowing models to access up-to-date information beyond their training data.

When to Use RAG

  • When you need current information
  • For domain-specific knowledge
  • When working with proprietary data
  • For tasks requiring recent events or data

Examples

Research Assistant
Search for the latest research on renewable energy and summarize the key findings from the past year

RAG for accessing current research data

Document Q&A
Based on our company's knowledge base, explain our refund policy for international customers

RAG for accessing company knowledge base

Prompt Templates

Here are some useful templates you can adapt for different tasks:

💡 Pro Tip: For a comprehensive library of ready-to-use templates, check out our Prompt Templates Library lesson.

Analysis Template

Analysis Template
You are an expert [domain]. Analyze the following [content type] and provide: 1. Key insights 2. Potential issues 3. Recommendations 4. Summary [Content to analyze]

Template for analytical tasks

Creative Writing Template

Creative Writing Template
You are a [type of writer] writing for [audience]. Create a [content type] about [topic] with these requirements: - Tone: [specify tone] - Length: [specify length] - Style: [specify style] - Key points to include: [list points] Please structure your response as follows: [Outline structure]

Template for creative content generation

Problem-Solving Template

Problem-Solving Template
Let's solve this step by step: Problem: [describe problem] Given information: - [fact 1] - [fact 2] - [fact 3] Let me think through this: [Show reasoning process] Solution: [provide solution]

Template for structured problem solving

Best Practices for Each Technique

Zero-Shot Best Practices

  • Be very specific about what you want
  • Use clear, unambiguous language
  • Consider the model's knowledge cutoff
  • Test with different phrasings

One-Shot Best Practices

  • Choose a representative example
  • Ensure the example matches your desired output format
  • Keep examples concise but complete
  • Use examples that demonstrate the right level of detail

Few-Shot Best Practices

  • Provide 2-4 examples for best results
  • Ensure examples are consistent in format and style
  • Vary the examples to show different scenarios
  • Make sure examples are relevant to your task

Chain-of-Thought Best Practices

  • Explicitly ask for step-by-step reasoning
  • Use phrases like "Let's solve this step by step" or "Think through this"
  • Provide enough context for the reasoning process
  • Be patient with longer responses

Practice Exercises

Exercise 1: Zero-Shot

Practice Exercise
Explain how photosynthesis works in simple terms that a 10-year-old could understand

Ask an AI to explain a complex concept in simple terms

Exercise 2: One-Shot

Practice Exercise
Write a product review for a smartphone. Example: Title: Excellent Camera, Great Performance Rating: 4.5/5 stars Pros: Amazing camera quality, fast performance, long battery life Cons: Expensive, no headphone jack Verdict: Highly recommended for photography enthusiasts Now write a review for a coffee maker:

Create a template for writing product reviews

Exercise 3: Few-Shot

Practice Exercise
Generate a catchy headline for these articles: Article about AI in healthcare: 'AI Revolutionizes Medical Diagnosis: 95% Accuracy in Early Disease Detection' Article about climate change: 'New Study Shows Ocean Temperatures Rising Faster Than Predicted' Article about remote work: 'Remote Work Productivity Surges: Companies See 40% Increase in Output' Article about electric vehicles:

Create a pattern for generating headlines

Exercise 4: Chain-of-Thought

Practice Exercise
Let's solve this step by step: A farmer has 17 sheep. All but 9 die. How many sheep does the farmer have left? Let me think through this: 1. The farmer starts with 17 sheep 2. 'All but 9 die' means 9 sheep survive 3. So the farmer has 9 sheep left The answer is 9 sheep. Now solve this: If you have 3 apples and you eat 1, how many do you have left?

Solve a logic puzzle with step-by-step reasoning

Common Pitfalls to Avoid

  1. Inconsistent Examples: Make sure your few-shot examples follow the same pattern
  2. Overly Complex Prompts: Start simple and add complexity as needed
  3. Ignoring Context: Provide enough context for the AI to understand the task
  4. Unrealistic Expectations: Don't expect perfect results from basic techniques alone
  5. Poor Formatting: Use clear formatting to separate examples and instructions

Summary

In this lesson, you've mastered the fundamental prompting techniques:

  • Zero-Shot Prompting: Direct instructions without examples
  • One-Shot Prompting: Single example to establish format and style
  • Few-Shot Prompting: Multiple examples to establish patterns
  • Chain-of-Thought: Step-by-step reasoning for complex problems
  • Multimodal Prompting: Combining text with images and other media
  • Function Calling: Enabling AI to execute specific functions
  • RAG: Retrieval-augmented generation for current information

Self-Check

Test your understanding of basic prompting techniques:

  1. Which technique is best for simple, straightforward tasks?

    • Zero-shot prompting
    • One-shot prompting
    • Few-shot prompting
  2. When should you use chain-of-thought prompting?

    • For simple questions
    • For complex reasoning problems
    • For creative writing tasks
  3. What's the main advantage of few-shot prompting?

    • It's faster than other techniques
    • It establishes clear patterns and consistency
    • It requires less thinking
  4. Which technique combines AI generation with external knowledge?

    • Function calling
    • RAG (Retrieval-Augmented Generation)
    • Multimodal prompting
  5. What should you avoid when using one-shot prompting?

    • Providing clear examples
    • Using examples that don't match your desired output
    • Being specific about requirements

Next Steps

In the next lesson, you'll learn about LLM Configuration and how to optimize your prompts for different AI models like GPT-5, Claude 4, and Gemini 2.5.

📚 Quick Reference: Need a fast reminder of these techniques? Check out our Prompt Engineering Cheat Sheet for a quick reference guide.


Practice Time! Try these techniques with different AI models and see how they respond. Remember, practice makes perfect in prompt engineering!

Complete This Lesson

You've successfully completed the basic prompting techniques lesson! Click the button below to mark this lesson as complete and track your progress.
Loading...

Explore More Learning

Continue your AI learning journey with our comprehensive courses and resources.

Basic Prompting Techniques - AI Course | HowAIWorks.ai