AllRounder.ai

Enrol to start learning

Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.

Enrol free

8.2.2. Multistep Instruction

Interactive Audio Lesson

Session 1: Understanding Multistep Instructions

Unlock the classroom podcast

The transcript is above and free to read. A free account plays the conversation back.

Create a free account
Sarah
SarahInstructor

Today we are going to learn about multistep instructions in programming prompts. Can anyone tell me what they think a multistep instruction is?

Noah
Noah

I think it's when we need to do more than one thing at a time in code.

Sarah
SarahInstructor

Exactly! Multistep instructions allow us to ask the AI to perform a series of tasks. Can someone give me an example?

Isabella
Isabella

Like reading a file and then filtering its contents?

Sarah
SarahInstructor

Perfect! So, let’s say we want to write a Python script that reads a CSV file, filters the rows, and saves the output. This requires multiple steps.

Session 2: Constructing Prompts

Unlock the classroom podcast

The transcript is above and free to read. A free account plays the conversation back.

Create a free account
Robert
RobertInstructor

Now, let’s learn how to construct a multistep prompt. What do we need to include in our prompt?

Akash
Akash

We should specify the file format and what to filter on.

Robert
RobertInstructor

Correct! Here’s an example prompt: 'Write a Python script that reads a CSV file, filters rows where age > 30, and saves the output.' Can anyone explain why it's structured this way?

Ananya
Ananya

It clearly states each step the AI needs to perform.

Robert
RobertInstructor

Exactly! Clarity leads to better code outputs. Remember that specifics matter, like mentioning 'Python' to avoid ambiguity.

Session 3: Execution and Output

Unlock the classroom podcast

The transcript is above and free to read. A free account plays the conversation back.

Create a free account
Sarah
SarahInstructor

Now let’s execute the prompt we created. How do you think the output should look?

Noah
Noah

It should show the filtered data saved in a new CSV file.

Sarah
SarahInstructor

Correct! The expected output will be a filtered data set. Let's analyze a sample output together to see if it meets our expectations.

Isabella
Isabella

Can we also check if it handles errors, like if the file isn't found?

Sarah
SarahInstructor

Great point! Always consider edge cases as part of your instructions. Let's add that to our review.

Overview

Short Summary

This section covers how to use multistep instructions in prompt engineering to develop detailed code tasks.

Medium Summary

In this section, learners will explore the significance of crafting prompts that require multiple steps to effectively write, filter, and handle data in coding tasks. Key instructions for structuring these prompts and examples of Python-based implementations are discussed.

Detailed Summary

Multistep Instruction

Multistep instructions in prompt engineering are essential for carrying out complex coding tasks that require sequential problem-solving. This section highlights how to construct prompts that generate straightforward and clear code, particularly using Python as an example. The process starts by providing the AI with a specific instruction that interprets multiple actions. For instance, a prompt can instruct a model to read a CSV file, filter out specific data, and save the output, demonstrating the AI's ability to interpret and execute each step in sequence. Through structured prompts, learners can ensure that outputs are accurate and fulfill specified requirements. This concept not only facilitates coding tasks but also enhances the overall efficacy of prompt engineering in technical applications.

Audio Book

Voice:
Understanding the Prompt

Unlock the audio lesson

The script is above and free to read. A free account plays it back, in the voice you pick.

Create a free account

Prompt: “Write a Python script that reads a CSV file, filters rows where age > 30, and saves the output.”

Detailed Explanation

This prompt invites the user to create a Python script. The essential task is to read a CSV (Comma-Separated Values) file, which is a common format for storing tabular data. The script needs to filter this data so that only the rows where a person's age is greater than 30 are considered. Finally, the filtered results must be saved, which means writing the output to a new file or format. The statement outlines clear steps: reading, filtering, and saving.

Examples & Analogies

Think of this process like going through a stack of paper files to only keep those with details of clients over a certain age. You read each file (the CSV), check if they meet the age criteria (filtering), and then store those relevant files in a new folder (saving the output).

Using Delimiters for Long Code

Unlock the audio lesson

The script is above and free to read. A free account plays it back, in the voice you pick.

Create a free account

Use delimiters for long code:

# script goes here

Detailed Explanation

Delimiters are markers that help organize code, making it easier to read and modify. In this case, the triple backticks (```) are used to signify the start and end of a code block in Markdown format. By using these delimiters, long code can be separated from the rest of the text, improving clarity and reducing the chance of mixing explanations with code. This practice is especially important in technical documentation, where understanding is critical.

Examples & Analogies

Imagine reading a recipe that includes a critical step for a complicated dish. You might want to use bold or italic text to highlight that step, making it stand out from the rest of the instructions. Similarly, by using delimiters, you can make sure that important code sections catch the reader's attention.

--

Key Concepts

Core takeaways and short definitions to help you quickly recall the key ideas from this section.

Prompt Engineering: The practice of crafting prompts that effectively instruct AI to perform tasks.

Step-by-Step Execution: Breaking down tasks into individual, manageable pieces in coding.

Code Readability: Ensuring that code is clear and understandable to avoid errors.

Examples

Step-by-step examples to apply the section's ideas and test your understanding.

1

A prompt to write a Python script that reads a CSV file and filters rows based on criteria.

2

The expected output of a well-structured code snippet demonstrating filtered data from a CSV file.

Memory Aids

Interactive tools to help you remember key concepts

🎵

Rhymes

Read, Filter, Save, in that order we behave.
📖

Stories

Imagine a librarian (AI) tasked with reading a whole pile of books (CSV), finding only those with interesting characters (filtering), and writing down their names in a list (saving).
🧠

Memory Tools

Remember RFS for Read, Filter, Save.
🎯

Acronyms

M.I.P. - Multistep Instruction Prompt.

Flash Cards

Glossary

Multistep Instruction

An instruction that requires multiple sequential tasks to be executed in a programming context.

CSV File

A Comma-Separated Values file that is used to store tabular data in plain text.

Filtering

The process of selecting a subset of data based on certain criteria.