Dr Marcel Scharth
Generative AI is having a moment. ChatGPT and art generators such as DALL-E 2, Stable Diffusion and Midjourney have proven their potential, and now millions are wracking their brains over how to get their outputs to look something like the vision in their head.
This is the goal of prompt engineering: the skill of crafting an input to deliver a desired result from generative AI.
Despite being trained on more data and computational resources than ever before, generative AI models听. For instance, they鈥檙e not trained to produce content aligned with goals such as truth, insight, reliability and originality.
Image created using Midjourney. Prompt:听oil painting of a child with their grandparent enjoying a moment together and looking at each other. The child鈥檚 face is full of wonder and the grandparent鈥檚 face is lined with years of living, nostalgia, happy and sad memories and the wisdom of their years. Detailed faces. 鈥 鈥 ar 3:2 鈥 鈥 no glasses
They also lack common sense and a fundamental understanding of the world, which means they can generate flawed (and even nonsensical) content.
As such, prompt engineering is essential for unlocking generative AI鈥檚 capabilities. And luckily it isn鈥檛 a technical skill. It鈥檚 mostly about trial and error, and keeping a few things in mind.
First, let鈥檚 use听听to illustrate how prompt engineering can be used for text outputs. If it鈥檚 used effectively, ChatGPT can generate听,听,听,听,听,听, and more.
Since it鈥檚 a chatbot, you may be inclined to engage with it conversationally. But this isn鈥檛 the best approach if you want tailored results. Instead,听听that you鈥檙e programming the machine to perform a writing task for you.
Create a content brief similar to what you might give a hired professional writer. The key is to provide as much context as possible and use specific and detailed language. You can include information about:
Dr Scharth used prompt engineering to get ChatGPT to write this news article, which provides inaccurate information.
听
If you want a longer piece, you can generate it in steps. Start with the first few paragraphs and ask ChatGPT to continue in the next prompt. If you鈥檙e unsatisfied with a specific portion, you can ask for it to be rewritten according to new instructions.
But remember: no matter how much you tinker with your prompts, ChatGPT is听听and听. So don鈥檛 take anything at face value. In the example above, the output mentions a 鈥渞eport鈥 that doesn鈥檛 exist. It probably included this because my prompt asked it to听use only reliable sources.
Midjourney is one of the most popular tools for art generation, and one of the听. So let鈥檚 use it for our next example.
Unlike for text generation, elaborate prompts aren鈥檛 necessarily better for image generation. The following example shows how a basic prompt combined with a style keyword is enough to create a variety of interesting images. Your style keyword may refer to a genre, art movement, technique, artist or specific work.
The following images were based on the prompt听leopard on tree听followed by different style keywords. These were (from the top left clockwise)听synthwave,听hyperrealist,听expressionist听and听in the style of Zena Holloway.听听is a British photographer known for capturing her subjects in ethereal and somewhat surreal scenes, most often underwater.
Images generated by Midjourney.
You can also add keywords relating to:
With Midjourney, you can even use certain specific commands for different features, including听鈥撯赌揳谤听or听鈥撯赌揳蝉辫别肠迟听to set the听,听鈥撯赌搉辞听to omit certain objects, and听鈥撯赌揷听to produce more 鈥渦nusual鈥 results. This command accepts values between 0-100 after it, where the default is 0 and 100 leads to the most unusual result.
You can also use听鈥撯赌搒听or听鈥撯赌搒tylize听to generate more artistic images (at the expense of following the prompt less closely).
The following example applies some of these ideas to create a fantasy image with a dreamlike and futuristic look. The prompt used here was听dreamy futuristic cityscape, beautiful, clouds, interesting colors, cinematic lighting, 8k, 4k 鈥撯赌揳谤 7:4 鈥撯赌揷 25 鈥撯赌搉辞 windows.
Midjourney accepts multiple prompts for one image if you use a double colon. This can lead to results such as the image below, where I provided separate prompts for the owl and plants. The full prompt was听oil painting of an ethereal owl :: flowers, colors :: abstract :: wisdom 鈥撯赌揳谤 7:4.
A more advanced type of prompting is to include an image as part of the prompt. Midjourney will then take the style of that image into account when generating a new one.
A good way to find inspiration and ideas is to explore the听听and听.
As generative AI models enter everyday life, prompting skills are likely to become more听, especially from听听looking to get results using AI generators.
Some听听are asking if becoming a 鈥減rompt engineer鈥 may be a way for professionals such as designers, software engineers and content writers to save their jobs from automation, by integrating generative AI into their work. Others have听听prompt engineering will itself be a career.
It鈥檚 hard to听听what role prompt engineering will play as AI models advance.
But it鈥檚 almost a given that more sophisticated generators will be able to handle more complex requests, inviting users to stretch their creativity. They will likely also have a better grasp of our preferences, reducing the need for tinkering.
This article was first published in听听as 'How to perfect your prompt writing for ChatGPT, Midjourney and other AI听generators'.听Dr Marcel Scharth is听a Lecturer in Business Analytics at the 爆料王 Business School.