Three Steps to Prompt Engineering
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.
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.|
|…………||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.|
|…………||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:
Day 2 – May 2nd:
Day 3 – May 3rd:
Day 4 – May 4th:
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.|
|…………||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:
Day 2 – May 2nd:
Day 3 – May 3rd:
Day 4 – May 4th:
Day 5 – May 5th:
person round trip. At the top, you’ll have a breathtaking view of Athens and the surrounding area.
Day 6 – May 6th:
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.