What is prompt engineering?

| Article
An old fashioned type writer with a sheet of paper advancing from it. The paper has the pattern of a brain made of recently typed letters imprinted upon it.
An old fashioned type writer with a sheet of paper advancing from it. The paper has the pattern of a brain made of recently typed letters imprinted upon it.

Let’s say you’re making spaghetti marinara for dinner. Sauce from a jar is perfectly fine. But what if you buy your tomatoes and basil from the farmers market to make your own sauce? Chances are it will taste a lot better. And what if you grow your own ingredients in your garden and make your own fresh pasta? A whole new level of savory deliciousness.

Just as better ingredients can make for a better dinner, better inputs into a generative AI (gen AI) model can make for better results. These inputs are called prompts, and the practice of writing them is called prompt engineering. Skilled prompt engineers design inputs that interact optimally with other inputs in a gen AI tool. These inputs help elicit better answers from the AI model, meaning the model can perform its tasks better, such as writing marketing emails, generating code, analyzing and synthesizing text, engaging with customers via chatbots, creating digital art, composing music, or any of the other hundreds, if not thousands, of current applications.

Get to know and directly engage with senior McKinsey experts on prompt engineering

Rodney Zemmel is a senior partner in McKinsey’s New York office and the global leader of McKinsey Digital; Alex Singla is a senior partner in the Chicago office and the global coleader of QuantumBlack, AI by McKinsey; Chandra Gnanasambandam, Olivia White, and Lareina Yee are senior partners in the Bay Area office, where Roger Roberts is an expert partner; Jared Moon, and Kate Smaje are senior partners in the London office, where Alex Sukharevsky is a senior partner and the global coleader of QuantumBlack, AI by McKinsey. Other experts include Sven Blumberg, a senior partner in the Istanbul office; Aamer Baig, a senior partner in the Chicago office; Eric Hazan, a senior partner in the Paris office; Steve Reis, a senior partner in the Atlanta office; Kweilin Ellingrud, a senior partner in the Minneapolis office; and Delphine Zurkiya, a senior partner in the Boston office.

Gen AI has an important role to play in the future of business and society. But where does prompt engineering fit in? And how do you write a good prompt? Read on to find out.

Learn more about McKinsey’s Digital Practice.

What is generative AI?

First things first: a refresher on gen AI. Gen AI models are applications typically built using foundation models. These models contain expansive artificial neural networks, inspired by the billions of neurons connected in the human brain. Foundation models are part of what’s called deep learning, which refers to the many deep layers within neural networks. Deep learning has powered many recent advances in AI—things you’re probably already using, like Alexa or Siri—but foundation models represent a significant evolution within deep learning. Unlike previous deep-learning models, foundation models can process massive and varied sets of unstructured data. AI that is trained on these models can perform tasks such as answering questions and classifying, editing, summarizing, and drafting new content.

Here is an example of the value of specificity in prompt engineering. We asked Lilli, McKinsey’s proprietary gen AI tool, to help summarize a report. We gave the tool two prompts, with specific requests for different kinds of information. Take a look at the different outputs Lilli provided.

Specific prompts help models understand what you want

How are organizations deploying gen AI?

Developing a gen AI model from scratch is so resource intensive that it’s out of the question for most companies. Organizations looking to incorporate gen AI tools into their business models can either use off-the-shelf gen AI models or customize an existing model by training it with their own data.

Other organizations, including McKinsey, have launched their own gen AI tools. Morgan Stanley has launched a gen AI tool to help its financial advisers better apply insights from the company’s 100,000-plus research reports. The government of Iceland has partnered with OpenAI to work on preserving the Icelandic language. And enterprise software company Salesforce has integrated gen AI technology into its popular customer relationship management (CRM) platform. McKinsey’s Lilli provides streamlined, impartial search and synthesis of vast stores of knowledge to bring the best insights, capabilities, and technology solutions to clients.

How can you develop prompt engineering skills?

Getting good outputs isn’t rocket science, but it can take patience and iteration. Just like when you’re asking a human for something, providing specific, clear instructions with examples is more likely to result in good outputs than vague ones.

How will gen AI affect the workforce?

McKinsey’s latest research suggests that gen AI is poised to boost performance across sales and marketing, customer operations, software development, and more. In the process, gen AI could add up to $4.4 trillion annually to the global economy, across sectors from banking to life sciences.

The breakthroughs powered by gen AI will also change the workforce. One of gen AI’s strengths is that it can help nearly everyone with their jobs. This is also one of the technology’s greatest challenges. McKinsey estimates that gen AI and other technologies have the potential to automate work activities that absorb up to 70 percent of employees’ time today. This is largely due to gen AI’s ability to predict the patterns found in natural language. This, in turn, means that gen AI stands to have more impact on knowledge work associated with occupations that have higher wages and more educational requirements. And this change will likely happen fast: McKinsey estimates that half of today’s work activities could be automated between 2030 and 2060. That’s roughly a decade earlier than our previous estimates.

Circular, white maze filled with white semicircles.

Introducing McKinsey Explainers: Direct answers to complex questions

These developments will mean big changes in the labor market. Gen AI could enable labor productivity growth of up to 0.6 percent annually through 2040—but that all depends on how fast organizations are able to adopt the technology and effectively redeploy workers’ time. Employees with skills that stand to be automated will need support in learning new skills, and some will need support with changing occupations.

Learn more about McKinsey’s Digital Practice.

Are organizations already hiring prompt engineers?

Organizations are already beginning to make changes to their hiring practices that reflect their gen AI ambitions, according to McKinsey’s latest survey on AI. That includes hiring prompt engineers.

The survey indicates two major shifts. First, organizations using AI are hiring for roles in prompt engineering: 7 percent of respondents whose organizations have adopted AI are hiring in this category. Second, organizations using AI are hiring much fewer engineers for AI-related software than in 2022: 28 percent of organizations reported hiring for these roles in 2023, down from 39 percent in 2022.

If organizations are hiring prompt engineers, does that mean existing employees will be pushed out?

Prompt engineering is likely to become a larger hiring category in the next few years, but organizations also expect to reskill their existing employees in AI. Nearly four in ten respondents reporting AI adoption expect more than a fifth of their companies’ workforces to be reskilled, whereas only 8 percent say the size of their workforces will decrease by more than a fifth.

Learn more about QuantumBlack, AI by McKinsey.

How might prompt engineering help organizations—say, banks—serve clients more efficiently?

As just one example of the potential power of prompt engineering, let’s look at the banking industry. Banks have plenty of value to gain from gen AI. McKinsey estimates that gen AI tools could create value from increased productivity of up to 4.7 percent of the industry’s annual revenues. That translates to nearly $340 billion more per year. Prompt engineering has a role to play in helping banks capture this value. Here’s how.

Let’s say a large corporate bank wants to build its own applications using gen AI to improve the productivity of relationship managers (RMs). RMs spend a lot of time reviewing large documents, such as annual reports and transcripts of earnings calls, to stay up to date on a client’s priorities. The bank decides to build a solution that accesses a gen AI foundation model through an API (or application programming interface, which is code that helps two pieces of software talk to each other). The tool scans documents and can quickly provide synthesized answers to questions asked by RMs. To make sure RMs receive the most accurate answer possible, the bank trains them in prompt engineering. Of course, the bank also should establish verification processes for the model’s outputs, as some models have been known to hallucinate, or put out false information passed off as true.

This isn’t just a hypothetical example. In September 2023, Morgan Stanley launched an AI assistant using GPT-4, with the aim of helping tens of thousands of wealth managers find and synthesize massive amounts of data from the company’s internal knowledge base. The model combines search and content creation so wealth managers can find and tailor information for any client at any moment.

A European bank developed a gen-AI-based environmental, social, and governance virtual expert. The model answers complex questions based on prompts, identifies the source of each answer, and extracts information from pictures and tables.

In these examples, hypothetical and otherwise, the better the prompt, the better the output.

Learn more about McKinsey’s Digital Practice and QuantumBlack, AI by McKinsey. And check out gen-AI-related job opportunities if you’re interested in working at McKinsey.

Pop quiz

Articles referenced:

This article was updated in March 2024; it was originally published in September 2023.

An old fashioned type writer with a sheet of paper advancing from it. The paper has the pattern of a brain made of recently typed letters imprinted upon it.

Want to know more about prompt engineering?