What Is AI Prompt Engineering? How Can It Make Me Money? (Part 2)
In the previous part 1 of this article, we got started exploring what AI prompt engineering is and its importance for communicating with generative AI models (make sure to check the article out if you haven´t done it yet).
We have also explained what prompt engineering is and why it is one of the high valuable skills for leveraging the power and potential of generative AI for various purposes.
If you stayed with us for a while, you know that we at wannabethebest.me do our best to facilitate up-to-date but also practical information…
That´s why in this part 2 of the article we will explore some of the practical techniques and tools for prompt engineering to get you started right now!
And, of course, we will also provide some examples of prompts for different tasks and models.
Enough for an introduction…let´s dive right in!!
Key Takeaways
Prompt engineering techniques include providing context, specifying instructions, choosing tone and format, adding examples, and using keywords and symbols. |
Prompt engineering tools include prompt generators, prompt libraries, prompt validators, and prompt analyzers. |
Prompt engineering examples include prompts for text summarization, text generation, image generation, question answering, and sentiment analysis. |
Prompt engineering best practices include testing and refining prompts, avoiding errors and biases, and respecting users and models. |
Techniques for Prompt Engineering
Prompt engineering is a creative and flexible art that depends on various factors, such as the model, the task, the data, the user, and the context.
To tell the truth, it is closer to an art than a science…however, there are some general techniques that can be referred to as a checklist for creating effective and accurate prompts that elicit the desired output from any generative AI models.
Here are some of them:
Context
Providing context | Context is the information that helps the model understand the task and the input better. “Context” can include background knowledge, domain-specific terms, relevant facts, or previous outputs. Context can help the model generate more relevant and accurate outputs that match the user’s intention and goal. For example, if you want to generate a summary of a news article, you can provide the title, the author, the date, and the source of the article as context. |
Instructions
Specifying instructions | Instructions are the commands or requests that tell the model what to do and how to do it. Instructions can include the type of output, the length of output, the format of output, or any other constraints or preferences. Instructions can help the model generate more specific and precise outputs that meet the user’s expectations and needs. For example, if you want to generate a poem about leaves falling, you can specify the number of lines, the rhyme scheme, or the mood of the poem as instructions. |
Tone and Format
Choosing tone and format | Tone and format are the style and appearance of the output. Tone can include the level of formality, politeness, humor, or emotion. Format can include the use of punctuation, capitalization, spacing, or markdown elements. Tone and format can help the model generate more coherent and fluent outputs that suit the user’s purpose and audience. For example, if you want to generate an email to your boss, you could choose a formal tone and a standard format… |
References and Examples
Adding examples | Examples are the samples or templates of outputs that show the model specifically what kind of output you want. Examples can be real or even hypothetical outputs that illustrate the desired quality and diversity of outputs. Examples can help the model generate more consistent and varied outputs that, following your example, meet your needs more precisely. For example, if you want to generate a joke about AI prompting, you could provide one or more example jokes about AI prompting. |
Keywords and Symbols
Using keywords and symbols | Keywords and symbols are the words or characters that trigger or influence the model’s behavior or output. Keywords can include words that indicate topics, categories, genres, or sentiments. Symbols can include characters that indicate boundaries, separators, placeholders, or modifiers. Keywords and symbols can help the model generate more focused and customized outputs that reflect your keywords or symbols. For example, if you want to generate an image of a cat wearing glasses, you can use keywords like “cat” and “glasses” or symbols like “:” or “+” to give the AI model a more precise input prompt. |
Ok, you get the picture. Keep in mind anyway that these techniques are not mutually exclusive or exhaustive. And of course feel free to use one or more techniques in combination to create more effective prompts!
In fact, as you go ahead, You will get to know even more different techniques to experiment with to find out what works best for your task and model.
Remember the basic funcion of practicing : “To let your body or your brain repeat a task to develop the best or more effective method to accomplish the desired result”.
Read more : Let´s talk money, is Prompt Engineering a remunerative endeavor? Follow the link and find more.
Tools for Prompt Engineering
Prompt engineering can be a complex endeviour, and often not only about writing prompts. To get your work done more effectively, I would suggest you to take advantage of various tools to fast-track your process, and even automating some aspects of the entire procedure.
Here are some of them:
Prompt Generators
Prompt generators are tools that can automatically generate prompts for you based on your input or task. As a novice, prompt generators can save you time and effort by providing you with ready-made prompts that you can use. Then, as you gain more knowledge and expertise, you will be able to to modify them to fit all the finer nuances you need! For example,
- This free AI Prompt Generator is a tool that can generate prompts for various NLP tasks using OpenAI’s GPT-3 for text, and Midjourney and Stable Diffusion for images.
- GPT Prompter is a chrome extention that allows you to use extensively the full potential of GPT-3, GPT-4 and ChatGPT API withoud havong to rely on the Open AI website or incurring in additional costs.
- This ChatGPT Prompt Generator is also free tool that can generate basic prompts for ChatGPT.
Prompt Libraries
Prompt libraries are collections of prompts that have been created and curated by other prompt engineers or users. Prompt libraries can provide you with inspiration and guidance by showing you examples of prompts that have been proven to work well for different tasks and models. For example,
- GitHub is a code hosting platform where you can find and share prompts for various AI models, such as ChatGPT, Midjourney, and Bard, among others.
- Hugging Face Spaces is also an incredible resource, full of tools and collection of prompts for various NLP tasks using Hugging Face’s Transformers models.
- Prompt Source is a collection of prompts for various NLP tasks using Hugging Face’s Datasets library.
…look what I came up with just 30 seconds af fooling around in Hugging Face Spaces…:O!
Prompt Validators
Prompt validators are tools that can check and evaluate the quality and validity of your prompts. Prompt validators are useful to identify and avoid potential errors and biases in your prompts by providing you with feedback and even suggestions. For instance :
- Promptfoo is a very interesting tool that can check and evaluate the quality and validity of your prompts using different LLM´s platforms.
- PromptValidatorContext from Microsoft (this is not really for the bare beginner…but anyway.. :))
You get the idea here. As an assignment feel free to check out different online evaluators suitable Google’s BERT model or facebook´s Bart for example… |
These tools are not mutually exclusive or exhaustive. You can use one or more tools in combination to create more effective prompts. You can also experiment with different tools to find out what works best for your task and model.
Examples of Prompt Engineering
Now we start getting really practical : as said, Prompt Engineering is just partially about techniques and tools. It mostly involves applying them to real-world tasks and models.
Here see some examples of prompt engineering for different tasks and models:
Text Summerizzation
- Text summarization: is the task of creating a short and concise summary of a longer text.
Let´s see for example, how OpenAI’s GPT-3 model would summarize the following article :
(you can simply use the following input prompt) :
Summarize the following article : Title: SpaceX launches 60 Starlink satellites, lands rocket at sea Author: John Smith Date: April 23, 2023 Source: Space.com |
SpaceX launched 60 more Starlink internet satellites into orbit Wednesday (April 22), continuing its rapid-fire launch cadence. A two-stage Falcon 9 rocket topped with the 60 broadband spacecraft lifted off from Pad 39A at NASA’s Kennedy Space Center in Florida at 12:25 p.m. EDT (1625 GMT). About nine minutes later, the rocket’s first stage came back to Earth for a pinpoint landing on one of SpaceX’s drone ships in the Atlantic Ocean. The launch was originally scheduled for Monday (April 20), but bad weather forced a delay. The mission, known as Starlink 24, marked SpaceX’s ninth launch of 2023, all but one of which have lofted Starlink satellites. SpaceX now has about 1,440 Starlink satellites in orbit, more than any other company or agency operates. The California-based company plans to continue launching Starlink craft at a rapid clip, with the goal of providing high-speed internet service to customers around the world. |
Output from Chat.GPT3 : |
– SpaceX adds 60 Starlink satellites to its internet constellation, lands rocket at sea- Another successful launch and landing for SpaceX as it sends 60 more Starlink satellites into orbit- SpaceX boosts its global internet service with 60 new Starlink satellites, recovers rocket booster |
Text generation
- Text generation: is the task of creating new and original text based on a given input or topic. For example, let´s say you want to generate a story about a dragon using Google’s BERT model. You could use the following input prompt:
Prompt: | Write a story about a dragon in less than 300 words. |
In this instance Google’s BERT goes even further providing not one but three (!!) possible stories suitable to our input!!…
Output 1 From Bert
– Zara was a young dragon who loved to explore the world. She flew over mountains, forests, and oceans, marveling at the beauty and diversity of life. One day, she stumbled upon a human village and decided to take a closer look. She landed on a nearby hill and watched the people go about their daily activities. She was fascinated by their clothes, tools, and language. She wondered what they were like and if they would be friendly. She decided to approach them and introduce herself. She hoped they would not be afraid of her and maybe even become her friends. |
Output 2
– Drake was a fierce dragon who ruled over a vast territory. He hoarded gold, jewels, and treasures in his cave and guarded them jealously. He did not tolerate any intruders or challengers and fought them with his fire breath and claws. He was feared and respected by all creatures, except for one: a brave knight named Sir Leo. Sir Leo had sworn to slay the dragon and free the land from his tyranny. He had tried many times to enter the dragon’s lair, but each time he was repelled by the dragon’s fire. He did not give up, however, and vowed to try again until he succeeded. |
Output 3
– Luna was a lonely dragon who lived in a hidden valley. She had no family or friends and spent her days wandering around the valley, looking for something to do. She wished she could meet someone who would understand her and keep her company. One night, she saw a bright star falling from the sky and landing in the valley. She followed the trail of light and found a small metal object with strange symbols on it. She touched it and felt a warm sensation in her chest. She heard a voice in her head saying: “Hello, I am Star, an artificial intelligence from another planet. I came here to learn about your world. Will you be my friend?” |
Image Generation
- Image generation: is the task of creating new and original images based on a given input or topic. For example, I tried to generate an image of a cat wearing glasses using a “Fast Stable Diffusion” app on the Hugging Face Spaces platform, just using the following prompt:
Prompt : | cat wearing glasses, beautiful, comic style, ultrarealistic, soft lighting, 8k |
…and here is the output after less than 30 sec!!! Quite incredible, isn´t it??
Now I will experiment removing only the words “comic style” from this basic prompt, let´s see the result :
…there you go!…impressive! And the possibilities of tweaking are really endless. Give it a try right now!
Question Answering
- Question answering: this is probalbly the most popular use of LLM´s, that is the task of providing a short and accurate answer to a given question. let´s say you want to answer a question about AI prompting using the everyone´s favourite ChatGPT:
Prompt : | What are some of the benefits of AI prompting? |
(Something interesting to note here : Open AI itself suggests that “ChatGPT CAN make mistakes”. So it always a smart idea to check out the output…)
Output : | AI prompts benefit creativity, aiding idea generation and overcoming blocks. In machine learning, they guide data collection and model training. For users, prompts ensure smooth interactions and customization. In education, they act as personalized learning aids. However, ethical considerations demand human oversight, especially in content generation and decision-making. |
– Notice that you can ask the model to regenerate the output if you are not happy with the result.
– Notice that I asked at the second try to also reduce and summarize the answer to a maximum of 50 words.
Sentiment Analisys
- Sentiment analysis : this interesting application is the task of identifying and extracting the emotion or opinion expressed in a given text. For example, you want to analyze the sentiment of a tweet using again Bing Chat. Try the following prompt:
Prompt : | I love AI prompting! It’s so fun and easy to use. #aiprompting #bestthingever |
Output : | “The sentiment of this tweet is positive, as it expresses a strong liking and enthusiasm for AI prompting.” |
Wanna some more advanced prompting concept?…well, let´s ask Microsoft itself!!
Conclusion
In this article, we have explored extensively some of the techniques and tools for prompt engineering. We have also provided some real-world examples of prompts for different tasks and models.
We hope that this article has helped you understand what AI prompting is and how you can start things out as a beginner…
let´s recap the highlights :
1. AI prompting is a technique to communicate with generative AI models using natural language text. Prompt engineering is the skill of crafting effective and precise prompts that elicit the desired output from the model. 2. Prompt engineering involves understanding the capabilities and limitations of the model, providing enough context and instructions, and choosing the appropriate tone and format for the output. |
3. Prompt engineering can help you leverage the power and potential of generative AI for various purposes, such as creativity, productivity, education, and entertainment. |
4. Prompt engineering is not a one-time process. It is an iterative and experimental process that requires trial and error, testing and refining, and constant learning and improvement. 5. Prompt engineering is not a fixed set of rules or formulas. It is a flexible and creative art that depends on various factors, such as the model, the task, the data, the user, and the context. 6. Prompt engineering is not a solo activity. It is a collaborative and interdisciplinary endeavor that involves communication and interaction with other prompt engineers, AI researchers, domain experts, and end users. |
More Resources
If you are interested in learning more about AI prompting and prompt engineering, you can also check out:
- Promptingguide.ai is a resource that provides a comprehensive introduction to AI prompting and prompt engineering for beginners nad advanced
- Learnprompting.org is also a website that teaches you how to use AI prompting and prompt engineering for various tasks and models. They also provide a community on Discord and GitHub for example…
There you have it! We hope that this article has at least inspired you to try out AI prompting for yourself and, why not , make a spectacular living out of as your career of choice!
Again, we encourage you to experiment with different tasks, models, techniques, tools, and prompts. We also invite you to share your prompts and outputs with us and others in the community.
Thank you for reading this article. We hope you enjoyed it.
Happy prompting Buddy! 😀