Commanding Your Daily Job Tasks With Prompt Engineering
An aspect of AI (artificial intelligence) for non-tech specialists
Table of contents
Prompt Engineering??? Why Prompt Engineering? I understand, but you need to come to an understanding that the world is evolving every day, and for you to be competent at your job, you need to hone your skill sets. When it comes to evolution, I am talking about 'Artificial Intelligence.' There is so much buzz about 'Artificial Intelligence' that you might start wondering if you would ever catch up with the trend. I have only one job: to bring updates on 'Artificial Intelligence' to your virtual doorstep (your mobile phone or laptop).
What trend am I bringing to your virtual doorstep?
PROMPT ENGINEERING
Should I be sincere with you? Put your fears inside the trash can because this will be the best write-up you have ever read on 'Prompt Engineering'. I am going to divide this into two parts, which are:
Early Years
Age Seven
Early years = non-tech specialists and Age seven = tech specialists. Early years, can I have your attention? Pick up a book, drink some water, have a light snack near you, and keep a pen with you.
**Attention: This particular episode is geared towards Early Years, while a subsequent episode will be focused on Age Seven.
PROMPT ENGINEERING FOR EARLY YEARS
What is prompt engineering?
The principle of "garbage in, garbage out" applies to prompt engineering, meaning that the quality of the outputs or results is determined by the quality of the inputs. For instance, when you search for something on Google, you expect to receive search results that precisely match your query or something closely related.
Prompt engineering is based on the use of an LLM (Large Language Model), which is closely related to NLP (Natural Language Processing). The basics of prompt engineering are done using an LLM application. However, I won't go into further detail on this topic.
The application you will use for writing prompts from now on is called "ChatGPT".
Let me do a quick rundown on the history of 'ChatGPT'
Hey there! So, you've got ChatGPT (Chat Generative Pre-Trained Transformer), a super cool chatbot made by OpenAI. They launched it on November 30, 2022. The best part? You can shape the convo the way you want! Whether you wanna go long or short, be specific or casual, or use any language you prefer, it's all good! This genius bot takes cues from your questions and responses to keep the chat flow smooth. It's like prompt magic, all happening during the convo. How awesome is that? 🚀
Hey, do you know that the little history stated above? I used ChatGPT to personalize this story because I got it from Wikipedia. Check out the initial history below and compare it with the above story I personalized for you.
ChatGPT (**Chat Generative Pre-Trained Transformer*) is a [large language model](en.wikipedia.org/wiki/Large_language_model)-based [chatbot](en.wikipedia.org/wiki/Chatbot) developed by [OpenAI](en.wikipedia.org/wiki/OpenAI) and launched on November 30, 2022, notable for enabling users to refine and steer a conversation towards a desired length, format, style, level of detail, and [language](en.wikipedia.org/wiki/Language) used. Successive prompts and replies, known as [prompt engineering](en.wikipedia.org/wiki/Prompt_engineering), are taken into account at each stage of the conversation as a context.*
When writing prompts using ChatGPT, there are two principles that can assist you:
Principle 1 : Write clear and specific instructions.
Principle 2: : Give the model enough time to "think".
Getting started with ChatGPT
Click on this URL: ChatGPT (openai.com) and it will take you to the homepage of ChatGpt, signup and you are ready to go.
**Let's delve deeper into the principles
PRINCIPLE 1 : Write clear and specific instructions:
Tactic 1: Utilize delimiters to clearly indicate distinct parts of the input, Delimiters can be anything like: ```, """, < >, <tag> </tag>
, :
prompt = Summarize the text delimited by triple backticks into a single sentence. ```text```
text = You should express what you want a model to do by providing instructions that are as clear and specific as you can possibly make them. This will guide the model towards the desired output and reduce the chances of receiving irrelevant or incorrect responses. Don't confuse writing a clear prompt with writing a short prompt. In many cases, longer prompts provide more clarity and context for the model, which can lead to more detailed and relevant outputs.
**Now, you can enjoy your snack and drink some water.
Tactic 2: Ask for a structured output:
- JSON, HTML
prompt = Generate a list of three made-up book titles along with their authors and genres. Provide them in JSON format with the following keys: book_id, title, author, genre.
Tactic 3: Ask the model to check whether conditions are satisfied:
prompt = You will be provided with text delimited by triple quotes. If it contains a sequence of instructions, re-write those instructions in the following format:
Step 1 - ...
Step 2 - … …
Step N - …
If the text does not contain a sequence of instructions, then simply write "No steps provided."
text = Making a cup of tea is easy! First, you need to get some water boiling. While that's happening, grab a cup and put a tea bag in it. Once the water is hot enough, just pour it over the tea bag. Let it sit for a bit so the tea can steep. After a few minutes, take out the tea bag. If you like, you can add some sugar or milk to taste. And that's it! You've got yourself a delicious cup of tea to enjoy.
Tactic 4: "Few-shot" prompting:
prompt = Your task is to answer in a consistent style.
<child> : Teach me about patience.
<grandparent> : The river that carves the deepest valley flows from a modest spring; the grandest symphony originates from a single note; the most intricate tapestry begins with a solitary thread.
<child> : Teach me about resilience.
Principle 2: Give the model time to “think”:
Tactic 1: Specify the steps required to complete a task:
text = In a charming village, siblings Jack and Jill set out on a quest to fetch water from a hilltop well. As they climbed, singing joyfully, misfortune struck Jack tripped on a stone and tumbled down the hill, with Jill following suit. Though slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight.
#example 1
prompt_1 = Perform the following actions:
1 - Summarize the following text delimited by triple
backticks with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the following
keys: french_summary, num_names.
Separate your answers with line breaks.
Text: {text}
prompt_2 = Your task is to perform the following actions:
1 - Summarize the following text delimited by <> with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the following keys: french_summary, num_names.
Use the following format: Text: Summary:
Text: <text to summarize>
Summary: <summary>
Translation: <summary translation>
Names: <list of names in Italian summary>
Output JSON: <json with summary and num_names>
Text: <{text}>
Tactic 2: Instruct the model to work out its own solution before rushing to a conclusion:
prompt = Determine if the student's solution is correct or not.
Question: I'm building a solar power installation and I need
help working out the financials.
Land costs $100 square foot
I can buy solar panels for $250 square foot
I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional $10 square
foot What is the total cost for the first year of operations as a function of the number of square feet.
Student's Solution: Let x be the size of the installation in square feet. Costs:
Land cost: 100x
Solar panel cost: 250x
Maintenance cost: 100,000 + 100x Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
Model Limitations: Hallucinations
- Boie is a real company, the product name is not real.
prompt: Tell me about AeroGlide UltraSlim Smart Toothbrush by Boie
Congratulations on reaching this point! I have some crucial information to share with you. Prompt engineering has made significant advancements, despite the original subtitle being "An aspect of AI (artificial intelligence) for both non-tech and tech specialists." However, I decided against it as it would have been too lengthy and possibly tedious. Rest assured that a version for tech specialists will be released soon. You are now recognized as a prompt engineer, so congratulations!
In the tech specialists episode, we will be using Python and Jupyter Notebook for advanced prompt engineering.
**Most of the prompts used were sourced from the internet.