Three Steps to Prompt Engineering

amber roberts arize
Amber Roberts,  Machine Learning Engineer  | Published April 04, 2023

What is prompt engineering and why is it growing so fast?

The term prompt engineering has taken off since the release of ChatGPT, a large language model (LLM) developed by OpenAI, as a method for refining prompts to efficiently utilize LLMs for a diverse range of applications (see Figure 1). Trained on massive text corpuses, these models can generate coherent and relevant text-based responses to various prompts and questions.

Prompt engineering is used to comprehend the extent of LLM capabilities, requiring the LLM querier to be strategic and intentional when interfacing with LLMs like ChatGPT.

Prompt Engineering 2023 google trend
According to Google Trends, search interest in “prompt engineering” this year peaked on March 29th, two weeks after the formal launch of GPT-4

There are dozens of applications of prompt engineering for LLMs across a wide variety of industries – including education, ecommerce, marketing, customer service and many more – but how should we be interfacing with LLMs and their plug-ins?

Whether you are planning a trip or organizing a workflow there are several best practices to consider when creating a prompt for ChatGPT or other LLMs. This piece is designed to give you quick insights into how to level up your prompt game.

Once you understand the basics, you can start incorporating domain knowledge and external tools to research new capabilities with LLMs. After all, how many job postings have you seen where a requirement is “strong communication skills”? The ability to efficiently verbalize or write down your ideas has always been a valuable and marketable skill. The truth is that even if this is a requirement, the communication assessment is subjective and open to human interpretation. As intelligent as ChatGPT may seem, this is not the case with LLMs.

Creating Effective Prompts: a Step-By-Step Guide

Prompt engineering involves the methods and techniques employed to accurately convey in writing what you are looking for. Without the safety net of human intuition, the model is prone to confidently making wild deviations from the user’s intended direction. Best-practice prompt engineering can help you get the most out of this transformative technology.

Step 1: Instructions

  • 👉 “I want you to act as…” 
  • This should be your first sentence as you are establishing the role and responsibilities ChatGPT will adhere to in this setting.
  • Example: “I want you to act as a travel guide…” for when you are using ChatGPT to generate a response.

Step 2: Context

  • 👉 “I will…”
  • Just like with coworkers and friends, ChatGPT needs context in order to give you the most relevant advice or information. Have you ever received a text message that you misinterpreted due to its lack of context? ChatGPT demonstrates the need to articulate our thoughts and goals effectively in order to not inadvertently mislead LLMs.
  • Example:  “I want you to act as a travel guide. I will give you the destination, time of year, date of travel and information on the traveler who you should tailor your response to.”

Step 3: Inputs / Outputs

  • 👉 “You will…”
  • Quality in; quality out. After setting the scene and defining roles, you want to verbally communicate the purpose of your prompt for ChatGPT. The more clear, concise details you provide, the better ChatGPT’s response will be.
  • Example: “I want you to act as a travel guide. I will give you the destination, time of year, and information on the travel who you should tailor your response to. You will create a travel itinerary starting with the date of arrival and ending on the date of departure. You will include tourist destinations, transportation methods, needed restaurant reservations and hotel recommendations. You will also include the approximate cost of each hotel and restaurant along with timestamps for each activity.”


Let’s see how ChatGPT does for a trip to Greece…

I want you to act as a travel guide. I will give you the destination, time of year, and information on the travel who you should tailor your response to. You will create a travel itinerary starting with the date of arrival and ending on the date of departure. You will include tourist destinations, transportation methods, needed restaurant reservations and hotel recommendations. You will also include the approximate cost of each hotel and restaurant along with timestamps for each activity.
chatgpt logo………… Sure, I’d be happy to help! Please let me know your destination, time of year, and any other relevant information that will help me tailor your itinerary to your preferences.
Trip 1: I will be arriving in Athens, Greece on May 1st 2023 and leaving May 4th 2023, I am traveling with one companion, we are both ages 18-35 and it is our first time visiting Greece. Plan our trip to Greece.
chatgpt logo………… Absolutely, I’d love to help you plan your trip to Greece! Here’s a recommended itinerary for your trip to Athens:

Day 1 – May 1st:

  • Arrival in Athens: Upon your arrival at Athens International Airport, you can take a taxi or the metro to your hotel. I recommend staying in the Plaka district, as it’s centrally located and has a lot of charm. The cost of a mid-range hotel in this area is around 100-150 euros per night. Check-in and relax for a bit.
  • Acropolis Museum: In the afternoon, head to the Acropolis Museum, which is one of the most impressive museums in Greece. You can get a guided tour or explore it on your own. The museum costs around 10 euros per person and is open from 8 AM to 8 PM.
  • Dinner in Plaka: After visiting the museum, head to Plaka for dinner. This area has plenty of traditional Greek restaurants with rooftop terraces and live music. You may want to make a reservation in advance to ensure you get a good spot. Expect to pay around 30-40 euros per person for a nice dinner with drinks.

Day 2 – May 2nd:

  • Acropolis: Start your day early and head to the Acropolis, the most famous landmark in Athens. The best time to visit is in the morning, before it gets too crowded and hot. The entrance fee is around 20 euros per person and includes access to the Parthenon, the Propylaea, the Erechtheion, and the Temple of Athena Nike.
  • Plaka: After visiting the Acropolis, take a stroll around the charming neighborhood of Plaka, which is filled with souvenir shops, cafes, and street performers. You can stop for a coffee or a snack and soak up the atmosphere.
  • National Archaeological Museum: In the afternoon, head to the National Archaeological Museum, which is the largest archaeological museum in Greece and has an impressive collection of ancient Greek art and artifacts. The entrance fee is around 10 euros per person and the museum is open from 9 AM to 4 PM.

Day 3 – May 3rd:

  • Day trip to Cape Sounion: Today, take a day trip to Cape Sounion, which is located about an hour and a half outside of Athens. This is the site of the ancient Temple of Poseidon and offers stunning views of the Aegean Sea. You can take a guided tour or rent a car and explore on your own. The entrance fee to the temple is around 10 euros per person.
  • Sunset at Cape Sounion: Make sure to stay for the sunset, as it’s one of the most beautiful sights in Greece. There’s a small cafe where you can grab a drink and enjoy the view.

Day 4 – May 4th:

  • Departure: On your last day, you can grab breakfast at your hotel and do any last-minute souvenir shopping before departing for the airport. Make sure to leave enough time to get to the airport, as traffic in Athens can be unpredictable.

Overall, this itinerary will give you a great taste of Athens and its surroundings. The approximate cost for this trip would be around 500-600 euros per person, including accommodation, transportation, meals, and activities.

Iterate on steps 1-3 and fine-tune the output until satisfied with the results

Not too bad! However, €500+ for a hotel is a bit more than I’m willing to spend per night. I personally prefer to travel on a budget and would like to include the island of Mykonos on my visit. Let’s see how ChatGPT does with a quick tuning…

Trip 2: I will be arriving in Athens, Greece on May 1st 2023 and leaving May 6th 2023, I am traveling with one companion, we are both ages 18-35 and it is our first time visiting Greece. Plan our trip to Greece on a budget with a day trip to Mykonos.
chatgpt logo………… Sure, I can definitely help you plan a budget-friendly trip to Greece with a day trip to Mykonos! Here’s a recommended itinerary for your trip:

Day 1 – May 1st:

  • Arrival in Athens: Upon your arrival at Athens International Airport, you can take the metro or a bus to your hotel. I recommend staying in the Monastiraki or Psirri districts, which are both centrally located and have plenty of budget-friendly options. The cost of a budget hotel in this area is around 50-80 euros per night. Check-in and relax for a bit.
  • Monastiraki Flea Market: In the afternoon, head to the Monastiraki Flea Market, which is one of the oldest and largest open-air markets in Athens. You can find all sorts of souvenirs, clothes, and antiques here, and it’s a great place to practice your bargaining skills.
  • Dinner in Psirri: After visiting the market, head to Psirri for dinner. This area has plenty of budget-friendly restaurants and tavernas with traditional Greek food. Expect to pay around 10-15 euros per person for a meal.

Day 2 – May 2nd:

  • Acropolis and Ancient Agora: Start your day early and head to the Acropolis, the most famous landmark in Athens. The best time to visit is in the morning, before it gets too crowded and hot. The entrance fee is around 20 euros per person and includes access to the Parthenon, the Propylaea, the Erechtheion, and the Temple of Athena Nike. After visiting the Acropolis, head to the nearby Ancient Agora, which was the heart of ancient Athens and has many impressive ruins. The entrance fee is around 8 euros per person.
  • Lunch in Monastiraki: After visiting the sites, head back to Monastiraki for lunch. There are plenty of street food vendors and casual restaurants in the area that offer tasty and affordable Greek food.
  • National Archaeological Museum: In the afternoon, head to the National Archaeological Museum, which is the largest archaeological museum in Greece and has an impressive collection of ancient Greek art and artifacts. The entrance fee is around 10 euros per person and the museum is open from 9 AM to 4 PM.

Day 3 – May 3rd:

  • Day trip to Mykonos: Today, take a ferry or a high-speed boat to Mykonos, one of the most beautiful islands in Greece. You can explore the picturesque town, visit the beaches, and enjoy the nightlife. The cost of the ferry or boat ticket is around 50-80 euros per person round trip, depending on the type of vessel and the time of departure.
  • Dinner in Mykonos: In the evening, enjoy dinner at one of the many tavernas in Mykonos. Expect to pay around 20-30 euros per person for a nice meal.

Day 4 – May 4th:

  • Free day in Athens: Today, take a day to explore Athens on your own. You can visit some of the other ancient sites, such as the Temple of Olympian Zeus or the Roman Agora, or simply wander around the city and soak up the atmosphere.
  • Dinner in Psirri: In the evening, head back to Psirri for dinner at a different restaurant. There are plenty of options to choose from, and you can find great deals on food and drinks.

Day 5 – May 5th:

  • Mount Lycabettus: Start your day early and head to Mount Lycabettus, the highest point in Athens. You can hike up the hill or take the funicular railway, which costs around 10 euros per

person round trip. At the top, you’ll have a breathtaking view of Athens and the surrounding area.

  • Lunch in Kolonaki: After coming down from the mountain, head to the nearby neighborhood of Kolonaki for lunch. This area has plenty of trendy cafes and restaurants that offer great food and drinks at reasonable prices.
  • Shopping in Ermou Street: In the afternoon, head to Ermou Street, which is one of the main shopping streets in Athens. You can find all sorts of stores here, from high-end boutiques to budget-friendly chain stores.

Day 6 – May 6th:

  • Departure: On your last day, you can grab breakfast at your hotel and do any last-minute souvenir shopping before departing for the airport. Make sure to leave enough time to get to the airport, as traffic in Athens can be unpredictable.

Overall, this itinerary will give you a great taste of Athens and its surroundings on a budget, with a day trip to Mykonos. The approximate cost for this trip would be around 500-600 euros per person, including accommodation, transportation, meals, and activities.

Much better, but am I satisfied yet?

Clarity Is Key Before Moving Onto Prompt Engineering for Complex Tasks

The true difficulty with LLMOps production management is understanding what success looks like. Have you ever written a paper for school and knew it wasn’t your best work? You can also likely recall when you have outdone yourself on a talk. That is because you are intimately familiar with your training data, so you are fully aware of your capabilities and limitations. This is not the case with prompt engineering. It is impossible for humans to consume the amount of information used to train a LLM, and therefore we can only determine ChatGPT’s capabilities through research and experimentation. This is why the prompt itself has to be as well constructed as possible.

When humans effectively communicate with one another we are clear, concise and relevant. These are the three most important factors to consider when writing, presenting, and prompting ChatGPT. The more detailed and constructed your thoughts are, the better job humans and LLMs will have at understanding and responding to you. In fact, learning prompt engineering by avoiding jargon and tangents should help you build engaging and constructive conversations in your everyday life.

The three factors of communication (clarity, conciseness, and relevancy) combined with the three steps to prompt engineering that we just went through (instruction, context, inputs/outputs) will help you get the most out of your interactions with LLMs. This was just one example of how to productively construct a ChatGPT prompt; going forward, you can advance these interfaces with prompt engineering for highly complex use cases.