Essential Guide to Prompt Engineering

Saurabh PandeySaurabh Pandey
4 min read

The Basics of Prompt Engineering

If you're here, you've likely heard of ChatGPT and GPT-4, and might be familiar with the term prompt engineering. In today’s issue, I'll introduce you to the basics of talking to AI, focusing on good prompt engineering practices.

I’ll cover the following:

· Understanding How Generative AI Works

· What is a Prompt?

· Basic Prompt Examples

· Prompting Tips and Tricks

Understanding How Generative AI Works

Before we dive into the exciting world of prompt engineering, let's take a moment to understand the bigger picture of generative AI. You've probably heard AI mentioned here and there, maybe even seen it in action with movie recommendations on Netflix. But recently, AI has exploded in popularity, gracing the covers of major magazines. What's the big deal?

Well, a few groundbreaking innovations have emerged, and we now call them "generative AI."

Unlike traditional AI that simply categorizes information, generative AI can actually create new things. This is where prompt engineering comes in – it's the key to guiding these powerful AI models to produce exactly what you're looking for.

  • Language Models Like GPT-4: Imagine these AI as incredibly sophisticated storytellers. They can predict the next word in a sentence, allowing them to hold remarkably human-like conversations.

  • Text-to-Image Models: These are like magic wands that transform your words into stunning images. You describe what you want, and they create it! This technology also extends to music and even actions, opening up a world of creative possibilities.

  • The Power of Transformers: These AI models are built on a special architecture called "transformers," which allows them to understand and process information in a much more human-like way. They also learn from human feedback and use cutting-edge techniques like "diffusion models" to generate incredibly realistic outputs.

So, there you have it – a glimpse into the fascinating world of generative AI. Now, let's learn how to harness its power with the art of prompt engineering!

Key changes:

  • More engaging and conversational tone: Used phrases like "Diving Deep," "exploded in popularity," "Imagine these AI," "like magic wands," "harness its power" to create a more exciting and relatable experience.

  • Simplified language: Replaced technical terms like "large language models" and "transformer architecture" with easier-to-understand explanations.

  • Removed bullet points: Made the flow of information smoother and more natural.

  • Added a touch of excitement and wonder: Highlighted the creative potential of generative AI with phrases like "opening up a world of creative possibilities" and "harness its power."

What is a Prompt?

  • Generative AI Interaction: Users communicate with these AI models by providing them with textual instructions in plain English.

  • The Prompt: This is the core of the interaction. It's the user's specific request or instruction given to the AI model as text.

  • Example: Image Generation:

    • The prompt for an image generation AI is essentially a detailed description of the desired image.

    • For instance: "A fat crocodile with a gold crown on his head, wearing a three-piece suit, 4K, professional photography, studio lighting, LinkedIn profile picture, photorealistic." This prompt provides specific details about the desired image, including style, quality, and intended use.

In essence: Users interact with generative AI models through textual prompts. These prompts guide the AI to generate the desired output, such as text, images, music, or code. The effectiveness of the AI's response heavily relies on the clarity and specificity of the prompt.

Basic Prompt Examples

A prompt can include instructions, questions, input data, and examples as a reminder. To obtain a result, either instructions or questions must be present. Let's look at a few examples using GPT-4:

  1. Question + Instructions:

· "How should I write my college admission essay? Give me suggestions about the different sections I should include, what tone I should use, and what expressions I should avoid."

  1. Instructions + Input Data:

· "Given the following information about me, write a four-paragraph college essay. I'm originally from Barcelona, Spain. While my childhood had different traumatic events such as the death of my father when I was only six, I still think I had a quite happy childhood."

  1. Question + Examples:

· "Here are some examples of music I really like: Radiohead, Lana del Rey, Rosalia, Bon Iver, and Andrew Bird. I do not like Coldplay, Taylor Swift, or Bruno Mars. What other music would you recommend?"

These examples illustrate how a general-purpose large language model can be tailored for specific tasks by providing detailed and structured prompts.

Prompt Engineering Tips and Tricks

Here are a few tips and tricks for creating effective prompts:

  1. Order of Examples: Large language models read forward, completing texts. It helps to provide instructions before the examples and experiment with different orders of prompts and examples.

  2. Affordances: Define functions in the prompt that the model is explicitly instructed to use when responding. For example, instruct the model to use a "calc" function for mathematical expressions.

  3. Different Languages: LLMs can understand and speak multiple languages. You can interact with the model in your native language or use it for programming tasks.

  4. Use of Caps and Exclamation Marks: Models sometimes respond better to forceful language. Using all caps and exclamation marks can ensure the model follows instructions more strictly.

0
Subscribe to my newsletter

Read articles from Saurabh Pandey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Saurabh Pandey
Saurabh Pandey