Prompt Engineering 101 Part 2 – Intermediate

42 1

Hey Prompt Entrepreneur,

In the last Part we covered some basic definitions and why exactly prompt engineering is important.

We’re now going to get more into the nitty gritty and tackle some topics like “few-shot prompting” and other buzzwords you may have heard flying around.

Don’t worry – none of this is particularly complex! And I’ll use simple language and examples so that it’s (hopefully) nice and simple.

Prompt Syntax

Let’s start basic.

Prompts at their core are just text strings containing instructions for the AI.

However, how you structure that text matters. Here are some prompt syntax best practices:

  • Use clear, straightforward language – Avoid ambiguity
  • Keep sentences simple and declarative
  • Add line breaks between logical sections
  • Number steps if giving multi-step instructions
  • Use consistent formatting and punctuation
  • Capitalize names and titles properly to avoid confusion

Adhering to basic syntactic conventions will make your prompts clearer and easier for the AI to parse.

Key Prompt Components

Effective prompts generally contain some combination of the following key components:

Context not assuming knowledge

  • Relevant background info to inform the AI
  • Defines terminology, personalities, goals, etc.

Don’t assume the AI knows what you want. Instead treat them like you would an intern – someone who is intelligent but doesn’t know how things work yet. You have to provide context around your prompt to give all the information required to complete the task.

Instructions not Questions

  • Clear directions telling the AI what to generate/do
  • Often written imperatively (e.g. “Write a poem…”)
  • Can include multi-step numbered directions

Don’t use questions with AI in the same way you might on Google. Asking questions leads to more wishy-washy answers. Instead instructions work far better.

Examples

  • Illustrative samples guiding the desired output
  • Provide 1-2 examples minimum

Don’t be annoyed when the AI provides an output that doesn’t match what you are expecting. You need to show the AI what a good output looks like so that it can best match your expectations.

Constraints

  • Boundaries to restrict undesired responses
  • “Do not include…”

Telling an AI what to exclude is just as, if not more, important as telling it what you want. AIs can generate pretty much anything so being precise about what you don’t want in an output helps them to focus.

Formalizing Prompts

There’s a lot to remember here so I’ve coined a nice memory aid.

I use the RISEN method:

  • Role – What persona should the AI adopt?
  • Instructions – What clear directions are you giving?
  • Steps – Are there numbered steps to follow?
  • End goal – What is the desired output?
  • Narrowing – What constraints are you adding?

For example:

Act as a master chef. (Role)
 
Give me a 5 step recipe for baked chicken breast. (Instructions)

1. tell me the ingredients needed
2. the steps to prepare
3. cooking instructions

(steps)

Give me everything in a checklist (End goal)

Keep these constraints in mind:

-Use only common ingredients

-Include approximate cooking times and temperatures

-Keep the recipe under 500 words

-Do not include any complicated techniques

-Focus just on the core recipe steps

(Narrowing)

The RISEN framework provides a structured way to build prompts that guide the AI to high-quality responses tailored to your needs.

Apply it to your tasks to immediately see improvements across the board.

Yes, your prompts will take longer to write but the results will propel you immediately from an amateur to an intermediate user.

Common Prompting Techniques

Now let’s explore some of the most common and effective prompting techniques used in prompt engineering. The RISEN formula above is a good base line.

But sometimes we need to go further – this section will talk about some of the common techniques.

These are situational. Some are good at some tasks, others are not. I suggest you just play around with them, get used to the concept and then when tackling real world prompting problems you’ll have these to fall back on.

1. Instruction Prompting

Instruction prompting involves giving the AI clear step-by-step directions to accomplish a task. This technique enables generative models to complete complex objectives that go far beyond their default capabilities.

Key Tips for Instruction Prompting

  • Use numbered steps
  • Write in imperative voice (e.g. “Summarize the key points”)
  • Be as precise and detailed as needed
  • Add contingency instructions as needed
  • Test and refine instructions iteratively

Instruction Prompting Examples

Data Cleaning

Instructions can automate tedious data processing tasks. For example:

“Parse the following name field into separate first name and last name columns. Handle names with titles like Mr. or Dr. as well as suffixes like Jr. or III.”

Content Generation

Instructions can guide quality content creation. For example:

“Write a 300 word blog post about prompt engineering. Focus on clearly explaining key concepts and provide actionable examples. Use subheadings to improve scannability.”

Content Moderation

Instructions enable automatic content filtering. For example:

“Review the following text. Remove any profanity, hate speech or offensive language. Replace it with [REMOVED].”

Feedback and Analysis

Instructions can produce detailed evaluations. For example:

“Analyze this essay on a scale of 1-10 for grammatical correctness, logical coherence, strength of arguments, and overall quality. For each criterion, explain your rating.”

The key with instruction prompting is starting with simple, straightforward directions and iteratively building on them to tackle more complex tasks.

2. Role Prompting

Role prompting involves assigning the AI a specific persona, character, or identity to shape its responses. This technique allows prompt engineers to control the style, tone, and depth of generated content.

When to Use Role Prompting

Role prompting is useful when you want the AI to:

  • Adopt a particular writing style or voice
  • Display expertise on a topic by acting as a domain expert
  • Provide responses tailored to a specific audience
  • Generate content that aligns with a fictional character

How to Role Prompt Effectively

Follow these tips for effective role prompting:

  • Choose a relevant persona tied to the goal
  • Specify 1-3 key traits that define the persona
  • Provide 1-2 examples that demonstrate the persona’s voice
  • Use clear role assignment language: “You are a _____”
  • Add in a word like “expert” or “master”

Examples

Writing Style

“You are a travel writer for a lifestyle magazine. Describe the nightlife in Paris in a lively and engaging tone.”

Domain Expertise

“You are an experienced java programmer. Explain polymorphism in Java for a coding tutorial.”

Audience Tailoring

“You are a kindergarten teacher. Briefly explain photosynthesis in simple terms a 5 year old could understand.”

Fictional Roleplay

“You are detective Sherlock Holmes. Deduce how the crime was committed based on these clues.”

Pitfalls to Avoid

  • Don’t assign too many conflicting traits to the persona. Split personality will water them all down.
  • Keep the persona description brief
  • Ensure the AI has enough context to successfully adopt the role

3. Few-Shot Prompting

Few-shot prompting sounds fancy.

All it involves is providing the AI with 2 or more example inputs and outputs to demonstrate the desired format. This technique is useful for structuring outputs in a specific way.

How Few-Shot Prompting Works

  • Show 2+ input-output exemplar pairs
  • AI recognizes the pattern and can replicate it
  • Allows AI to learn from just a few examples
  • More examples usually lead to better results

When to Use Few-Shot Prompting

Use few-shot prompting when:

  • You need a highly structured output format
  • It’s hard to describe the output format with verbal instructions alone
  • You have representative examples readily available

Examples

This is much easier to understand via examples.

Structured Data Extraction

Article: John Smith is a doctor in New York. 
Output: John Smith [DOCTOR] 

Article: Jane Doe is a lawyer in Washington. 
Output: Jane Doe [LAWYER] 

Article: Chris Lee is an architect in Chicago. 
Output:

Will output “[Architect]”

Translation

English: The book is on the table. 
Spanish: El libro está sobre la mesa. 

English: Where is the bathroom? 
Spanish: ¿Dónde está el baño? 

English: I would like water. 
Spanish:

Will output “Me gustaría agua.”

As you can see from the examples the AI will look for the pattern and seek to “fill in the gaps”.

Variants

You may have also heard of these alternatives so I’m dropping them for clarity.

  • Zero-shot: No examples
  • One-shot: 1 example
  • Few-shot: 2+ examples

In summary, few-shot prompting is a simple yet powerful technique for structuring AI outputs in a customized format.

Summing up

OK phew we’ve covered a lot! Good job.

In the next part we’ll start looking at how to actually apply all of this new knowledge in real world projects!

See you tomorrow Prompt Entrepreneur!

Until then, keep PROMPTING!

Kyle, Harms and 🤖

Follow us on Twitter.

Share the Post:

Join the AI revolution with the popular (free) 'Prompt Entrepreneur' Email Newsletter

“Prompt Entrepreneur” offers readers a daily roadmap to AI entrepreneurship. With over 3,000 subscribers, it provides accessible guides and reader-chosen deep dives into AI business models, even for those with low or no technical skills. Give it a try. It’s free.