What is prompt engineering?
image prompted in Stable Diffusion in a few seconds

What is prompt engineering?

Prompt engineering is the art of writing instructions for generative AI models to get a result that is fit for your purpose.

This process involves iteratively coaching these models, typically within a code script such as Python, with the instructions themselves using natural language. The models – and prompt engineering techniques – are still in their infancy and are expected to evolve rapidly.

Generative AI models include Large Language Models (LLMs) which are language-specific models based on Foundation Models (FMs). There are already nearly 20,000 open-source and proprietary models available, and more are being launched every week. AWS offers models from AI21 Labs, Anthropic, Cohere, Meta, Stability AI, in addition to their own models. Google provides FMs like Imagen, Muse, Codey, and Chirp, while OpenAI has GPT-4 and GPT3.5 (which powers ChatGPT).


These models offer unique challenges and opportunities

The challenge lies in crafting prompts that yield optimal results, necessitating a deep understanding of the model's intricacies, strengths, and limitations. It's akin to teaching a model how to think through a problem, emphasising clarity, specificity, and context.

The opportunity here is immense; it enables the quick generation of value in innovative ways that were previously time-consuming, expensive, or technically challenging.


Prompt engineering is a novel field, with interest only recently surging in 2023. Interest over time as per Google Trends has only started to pick up in 2023, and the role is arguably less than 2 years old depending on the definition of the role you use. On a recent search for the exact term “prompt engineering” on LinkedIn jobs for the UK and the US, the combined number of open roles was fewer than 20.


Google Trends Topic: Prompt Engineering – as of 9 October 2023


Which use cases should a prompt engineer focus on?

This should be related to use cases for which generative AI is most suited – these are problem statements that:

  1. are not overly simple (which should leverage simpler tools and techniques),
  2. involve unstructured data (such as text),
  3. do not demand 100% accuracy, and
  4. do not require detailed explainability (like reasons for loan rejections).

Promising experiments are underway to improve results in deterministic tasks (such as fetching numbers and performing calculations), which have been a weakness of LLMs. One specific challenge is finding tabular data in a database, especially when column names are unclear. We’ve had some success with instructing models to construct SQL queries from natural text, but this required specific data setup so the model would “look” in the correct places for the data. While some deterministic tasks can be engineered to work, LLMs work even better in the following use cases.


Better use cases for models

Certain cases where directional insights still provide value are good candidates to address with LLMs. One example is categorising customer chat logs into their reasons for the contact – by applying certain prompt engineering we can also determine with very good accuracy whether the customer had contacted the organisation because something was not done right. This changes the focus of the organisation to how and how well the business creates value for customers. Counts of certain issues can be tracked over time so that changes can be validated as true improvements from the customers’ point of view.


Four use case archetypes (and examples)

To generalize, the following archetypes of use cases can help leaders think of where prompt engineering on a LLM/FM might make a positive difference in their organisations:

1. Inferring (topic definition, sentiment analysis)

1.1 Topic Definition: Generative AI models can analyse large volumes of text data to identify prevalent topics. For instance, in social media monitoring, these models can group posts and discussions into relevant topics, aiding businesses in understanding public sentiment. These insights can be integrated into customer CRM records, creating profiles of customer interests over time.

1.2 Sentiment Analysis: Generative AI models can discern the emotional tone of text, analysing customer reviews or social media posts. While high-level, these analyses provide some insight into customer sentiment trends over time, especially when filtered for sentiment by product or geography.


2. Summarising (distilling customer complaints, meeting notes)

2.1 Customer Complaints: Generative AI models can process lengthy customer complaints into concise summaries, enabling effective problem resolution and product improvement.

2.2 Meeting notes summaries: Audio data can be transcribed into text that lists the key discussion points from video calls, facilitating efficient communication among team members about the items discussed and next steps. Data on next steps and task owners can be pushed to messaging systems or project management software.


3. Transforming (offering writing style advice, translation)

3.1 Writing Style Advice: Generative AI models can analyse writing style and provide tailored suggestions, allowing businesses to adapt content for different platforms and audiences. The advice can be based on a style guide that is provided to the model, based on a corpus of previous works.

3.2. Translation: Generative AI models aid in language translation, breaking down language barriers and ensuring accurate communication, especially for businesses operating in diverse regions.


4. Creating (generating relevant text)

Generative AI can automate drafting social media posts, emails, or chatbot responses, enhancing customer experiences based on contextual understanding and personalisation.


Considerations for prompt engineering

Let’s look at an example using ChatGPT.

Poor Prompt: "Give me tips for starting a business."        

This prompt is general and lacks context. "Tips for starting a business" could encompass a wide range of topics such as funding, marketing, or operations. The response that ChatGPT generated was long and rather generic, and had little insight to a specific situation.

Improved Prompt: "What are the key legal considerations entrepreneurs should be aware of when starting a tech startup in Japan?"        

In this improved version, the prompt is specific and more focused on a particular context: starting a technology-based business in a specific location (Japan). It addresses a specific aspect (legal considerations) and narrows down the scope to provide precise information. The output did touch on a several legal considerations specific to Japan.

The improved prompt still yielded several other generic answers, but these outputs give the prompt engineer hints on where to iterate next.


General rules differ by model

There are some general rules that can help us prompt a model, although different models work better with different rules. This is partially because of the data that certain models have been trained on.

For example, the following are good practices with the OpenAI API (or application programming interface, which is code that helps two pieces of software talk to each other):

1. Use the latest models, such as "text-davinci-003" for text generation or "code-davinci-002" for code generation (as of Nov 2022).

2. Place instructions at the beginning of the prompt and use something like triple quotes (""") to separate instructions from context.

3. Provide explicit, detailed instructions about the desired outcome, context, and length.

4. Give examples that demonstrate the desired output format.

5. Try first “zero-shot” (no examples), then “few-shot” (several examples), followed by fine-tuning (which is more involved).

6. Avoid vague descriptions.

7. Say what to do (instead of what not to do).

8. Give hints to the model if you want specific code written.

9. Use parameters such as "temperature" where a higher setting increase randomness, while a temperature of 0 suits factual and truthful responses.


How we think influences prompting

Our views on how a business should be managed can significantly impact how models are prompted and, consequently, their outcomes. For instance, prompting models to categorise all customer contacts as demand to be addressed might overlook insights essential for problem prevention. Management thinking shapes the insights that prompt engineers look for with models, so clear communication of the company's purpose, particularly in terms that resonate with customers, is crucial.


Summary

Prompt engineering involves crafting precise instructions for generative AI models, emphasising clarity, specificity, and context. It requires a blend of programming, instructing, and iterative coaching. While the field is still emerging, its potential is significant. The effectiveness of prompt engineering relies on a deep understanding of the model's nuances, use of best practices, and a creative approach to iteration. As this field continues to evolve, it holds immense promise for transforming businesses and customer experiences.


#artificialintelligence #technology #data


Great article on prompt engineering, Jason!

回复

要查看或添加评论,请登录

Jason Frank的更多文章

社区洞察

其他会员也浏览了