Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Why Should You Learn Prompt Engineering?

In today's society, AI is utilized everywhere, from personal travel planning to analyzing sales data.

However, AI can sometimes provide irrelevant answers or respond to a single-sentence question with an overwhelming 30-line answer, leaving users baffled.

Sometimes, you might not even know what question to ask to solve a problem.

Just like people need the right instructions to work properly, generative AI also requires proper instructions.


To manage AI when it occasionally goes off track, "prompt engineering" systematically organizes ways to ask the right questions.

A prompt refers to the sentence used to convey a user's request to AI, and prompt engineering optimizes this prompt to help AI provide the desired answers.


Exploring Prompt Engineering Through Examples

Let's look at specific examples of how prompt engineering is applied.

Consider a scenario where you're asking AI about an exercise schedule and diet for healthy living.

Prompt Providing Unorganized Answers
I'm planning an exercise schedule at the gym.

From June 1st to 10th, 2024, every other day,
tell me which exercises are good on each day along with a diet plan.

This prompt requests an exercise schedule and diet plan, but the AI's response might include excessive information and be difficult to interpret, making it hard for users to extract the desired information.

Now, how about revising the prompt like this?

Prompt Providing Neatly Organized Answers in Table Form
I'm planning an exercise schedule for the gym.

From June 1st to 10th, 2024, on alternate days,
tell me which exercises I should do on each day,
along with morning and evening meals, and organize it in a table.

---Table Format---

### Title

| No. | Date | Day | Exercise | Breakfast | Dinner |

You would now receive an exercise schedule neatly organized in a table along with the diet plan.

By applying this method, you can prevent chatGPT from providing excessively long answers or format responses in .csv, .xlsx suitable for spreadsheets.

The ### used beside the table format acts as a delimiter within the prompt to clearly separate and structure information.

This delimiter helps AI distinctly understand the context of the prompt, indicating that what's below ### is meant to be a table format.

The vertical bars | used to specify the table format serve as delimiters that AI uses to distinguish table columns, which are symbols used in Markdown for writing tables.

Markdown: A document writing method that allows easy formatting of text size, boldness, tables, etc., using simple symbols in text.


Markdown Table Writing Example
| No. | Date       | Day | Exercise | Meal   |
|-----|------------|-----|---------|-------|
| 1 | 2024-06-10 | Mon | Running | Salad |
| 2 | 2024-06-11 | Tue | Swimming | Pasta |

The markdown table above would appear like this in AI responses or markdown documents.

No.DateDayExerciseMeal
12024-06-10MonRunningSalad
22024-06-11TueSwimmingPasta

Prompt engineering not only helps specify the format of answers and improves readability, but also aids in preventing incorrect answers from AI.

Examples of prompt engineering to prevent incorrect answers will be covered in the following lesson :)


Practice

Click on the prompt examples and compare AI's answers.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.