The art of the prompt: How to get the best out of generative AI

Generative AI models can crank out anything from poetry and prose to images and code at your command. But to coax your desired output from these AI tools, you need to craft the right input — AKA, the prompt.

Prompts are what guide the AI model’s output and influence its tone, style and quality. And good prompts are what elicit brilliant text and stunning images.

“Writing good prompts is the key to unlocking the power and potential of generative AI,” said Jennifer Marsman, principal engineer in Microsoft’s Office of the Chief Technology Officer. 

“I compare it to the early days of search engines — there was an art to choosing the right keywords to get good results and, over time, both the users and the search engine got better at understanding each other,” she said. “This is the same paradigm. Over time, both we as users and the machine learning models will understand each other better.”

As generative AI tools become increasingly popular for work and play, it’s helpful to know how to get the most out of them. Crafting the right prompt is essential, but it can be a give-and-take. Here are a few of Marsman’s top tips and tricks for writing effective prompts.

Be specific

You had a stunning image in your mind, but when you told Bing Image Creator to make it real, the result wasn’t at all what you imagined. What gives?

It’s essential to provide as much detail as possible when writing prompts, especially when it comes to images, Marsman said. One key element she likes to provide is style. Tell the model to produce the image as a pencil sketch, for example, or an oil painting, or a cartoon. Point of view and lighting are also attributes to consider. In an image of a baseball stadium, are you looking down from the stands, or on the field, or a bird’s-eye view from above? 

In the “underwater palace” example, Marsman added the phrase “high-quality digital art” to her prompt. Without it, the image wouldn’t have had the same level of detail, she said.

Bing Chat conversation showing images of an underwater palace.
Include details like style, point of view and lighting when writing prompts to generate images. Image courtesy of Microsoft.

Marsman was pleased with the output. But don’t be afraid to iterate, she added. Flipping around the order of words in the prompt will bring different elements to the foreground. If she had wanted to add mermaids as the focus, for example, she could have listed “mermaids” first.

Use the right model for the right job

If you’re looking for stories, poems, jokes or other imaginative answers, use the “more creative” mode of Bing Chat.

But if you’re looking for just the facts, use the “more precise” mode. This will yield succinct and fact-based responses, Marsman said. “Balanced” mode is the default and works well for most scenarios, she added.

Fact-check

Bing combines powerful AI models with its immense search index for results that are current, cited and conversational. But one downside of generative AI models is that they can occasionally generate plausible-sounding answers that are, in fact, wrong. Here are a few tips to help make sure that reasonable-sounding output is indeed true:

  • Use the “more precise” conversation style in Bing Chat. This model tends to do better at grounding its responses in the source material from the web. 
  • Read the references carefully. You can click into the citations and verify that the model correctly interpreted the text.  
  • Tell the model to summarize specific information rather than asking an open-ended question. For example, instead of asking, “what is the theory of general relativity,” you could frame your prompt as “summarize the key concepts of general relativity in one paragraph.” This can help guide the model to generate more accurate and relevant responses, Marsman said. 

Tailor results through different points of view 

You can get better answers from a chatbot by telling it how you want it to provide answers. For example, if you want a simple explanation of quantum mechanics, you can ask AI-powered Bing to “explain it to me like I’m in 8th grade.” But if you’re savvy with the jargon and nitty-gritty of the topic, you can ask it to act like a college professor or a technical trainer. This way, you can adjust the Bing Chat’s voice and level of understanding to suit your needs.

Bing Chat conversation that shows an explanation of what causes a rainbow at a 3rd grade level.
You can adjust a Bing Chat’s voice and level of understanding to suit your needs. Image courtesy of Microsoft.

When you want to change the conversation, use the “New topic” button   

If you want to ask follow-up questions on the same topic in Bing Chat, it’s best to keep the current conversation going. When you want to switch topics, hit the “New topic” button. This gives the model a clean slate — it won’t get confused and merge unrelated topics.

You can specify length 

Do you want a succinct answer or a long tale? You can specify the length — two sentences, for example, or two paragraphs — and guide the model accordingly. And if the chatbot stops before you’re satisfied, you can always prompt it to “go on.”

Don’t forget formatting

AI-powered Bing can present data and information from multiple sources across the web and in a variety of different ways to improve understanding. For example, tables and outlines can help users see information in a structured format. Similarly, diagrams and flow charts can help users visualize complex data, making it easier to understand and interpret.

Bing Chat conversation showing a table of recent winners in three different horse races
AI-powered Bing can present data and information from multiple sources and in a variety of different ways. Image courtesy of Microsoft.

Leverage your Copilot for writing good code

Remember that the model is trained with many programming languages, so asking simply to accomplish a coding task could result in any number of programming languages being used. Specify the programming language you want. You should also include any other relevant contextual information, such as libraries, APIs or frameworks you are using. You can also mention context from already-written code, like “the user’s input is stored in a variable called x.”

Don’t forget to always run and test your code!

If at first you don’t succeed, prompt again

It’s important to remember that prompting AI to generate responses is not an exact science, and that iteration is key, Marsman said. The beauty of creating prompts is that you can try multiple approaches to see what works best. Don’t be afraid to experiment with different lengths, tones and voices. If the initial results aren’t what you’re looking for, try tweaking your prompt and running it again. With practice, you’ll get better at guiding the model to the results you want.

Related links:

Read more: Prompts for communicators using the new AI-powered Bing

Learn more: ExplAIning AI: The fundamentals and the frontiers

Top image: A digital image of an underwater palace created by Bing Image Creator. Image courtesy of Microsoft.