The Power of Context

This lesson builds upon the previous day by introducing basic prompting techniques for Chain-of-Thought (CoT) prompting. You'll learn how to construct prompts that encourage AI models to explain their reasoning step-by-step, unlocking their full potential. This lesson focuses on using example prompts and formatting to achieve the desired output.

Learning Objectives

  • Understand the importance of providing examples in CoT prompting.
  • Learn to structure prompts with clear instructions and examples.
  • Practice using different formatting techniques to guide the AI's response.
  • Recognize the impact of well-crafted prompts on the AI's output.

Text-to-Speech

Listen to the lesson content

Lesson Content

The Power of Examples: Few-Shot Learning

Chain-of-Thought prompting often utilizes a technique called few-shot learning. This means you provide the AI with a few examples of the desired task, including the input, the step-by-step reasoning (the Chain-of-Thought), and the final output. The AI learns from these examples and then applies that knowledge to solve new, similar problems. Think of it like teaching a child a new skill – you show them how to do it a few times, then they try it themselves.

Example:

Task: What is the capital of France?

Prompt:

Q: Roger has 5 tennis balls. He buys 2 more tennis balls. How many tennis balls does he have?
A: Roger started with 5 balls. 2 more balls are added. 5 + 2 = 7. The answer is 7.

Q: The cafeteria has 23 apples. If they used 20 for lunch, and bought 6 more, how many apples do they have?
A: The cafeteria started with 23 apples. They used 20. 23 - 20 = 3. They then bought 6 more. 3 + 6 = 9. The answer is 9.

Q: What is the capital of France?
A:

Structuring Your Prompts: Clear Instructions

A well-structured prompt is key. Start with clear instructions about the task you want the AI to perform. Follow this with the examples, ensuring each example includes the input, the CoT (the reasoning), and the output. Finally, provide the new input that you want the AI to solve.

Prompt Components:

  1. Instruction: Briefly explain the overall task. (e.g., 'Solve the following math problems, showing your work step-by-step.')
  2. Example 1: Input Question: The problem to solve.
  3. Example 1: Chain of Thought: The step-by-step reasoning.
  4. Example 1: Answer: The final answer.
  5. (Repeat steps 2-4 for multiple examples.)
  6. New Input: The question the AI needs to answer.

By including the Chain of Thought in your examples, you guide the model to provide step by step solutions!

Formatting for Clarity: Line Breaks and Separation

Use formatting to make your prompts easy to read and understand. Line breaks are your friend! Separate different parts of your prompt (instructions, examples, new input) with clear visual cues. You can use:
* Blank lines between instructions, examples, and new inputs.
* Numbered lists for steps.
* Consistent use of question (Q) and Answer (A) prefixes to distinguish between the input and the AI's generated response

Example: Better Formatting:

Solve the following math problems, showing your work step-by-step.

Q: John has 3 apples. Mary gives him 2 more. How many apples does John have?
A: John starts with 3 apples. Mary gives him 2 more. 3 + 2 = 5. The answer is 5.

Q: Sarah has 10 cookies and eats 4. How many cookies does she have left?
A: Sarah starts with 10 cookies. She eats 4 cookies. 10 - 4 = 6. The answer is 6.

Q: A shop has 15 red balloons and 10 blue balloons. How many balloons are in total?
A:

Progress
0%