Prompt Engineering
Prompt Engineering
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Agenda
In this session, we’ll discuss:
● Introduction to Generative AI and LLMs
● Basics of Prompt Engineering
● Components of a Good Prompt
● How to Write a Prompt?
● Advanced Prompt Strategies
● Common Prompting Errors
● Limitations of Generative Models
● Applications of Prompt Engineering
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Introduction to Generative AI (Gen AI)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Understanding Gen AI
Artificial
Intelligence
Machine
Learning
Deep
Learning
Gen AI
LLM
ChatGPT isProprietary
here content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Introduction to Large Language Models (LLMs)
What are LLMs?
● Large – as it is trained on large amounts of data and billions of trainable parameters.
● Language – as it deals with text data.
● Model – as it predicts the next word/sentence/token.
● LLMs are language models made up of a neural network with billions of parameters that are trained by
self-supervised learning on vast amounts of unlabeled text.
LLMs
1. Text Summarization
Generative 2. Sentiment Analysis
Text Models
3. Question Answering
4. Information Extraction
5. Text Translation
Pre-training Fine-tuning
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Popular LLMs
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Basics of Prompt Engineering
Prompt engineering is as much an art as it is a
Idea
science.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Basics of Prompt Engineering
Prompts
1 2
Parameters Structure
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Let’s write a few prompts!!
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Components of a Good Prompt
Context
external information or Instruction
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Components of a Good Prompt
Context
external information or
Context
Additional context that
Act as an analyst working for an OTT platform. You will have to perform
can steer the model to sentiment analysis based on the feedback provided by the consumers on
better responses. the movies and series put on the OTT platform.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Components of a Good Prompt
Context
external information or Instruction Instruction
Additional context that A specific task or Classify the feedback as neutral, negative, or
can steer the model to instruction you want the positive, where positive is promotor; negative
better responses. model to perform. means demoter, and neutral means neither
will promote nor demote the content.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Components of a Good Prompt
Context
external information or Instruction Example
Feedback: I think the series was okay.
Additional context that A specific task or Sentiment: Neutral
Feedback: The acting of each character in the
can steer the model to instruction you want the
series was awesome.
better responses. model to perform. Sentiment: Positive
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Components of a Good Prompt
Context Instruction Example
Feedback: I think the series was okay.
Act as an analyst Classify the feedback as Sentiment: Neutral
working for an OTT neutral, negative, or Feedback: The acting of each character in the
platform. You will have positive, where positive is series was awesome.
to perform sentiment promotor; negative Sentiment: Positive
analysis based on the means demoter, and
feedback provided by neutral means neither Input Data and Output Indicator
the consumers on the will promote nor demote Feedback: The storyline for the series was
movies and series put the content. repetitive and abysmal.
on the OTT platform. Sentiment:
Negative
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
How to Write a Good Prompt?
Here’s a checklist, to create the most effective prompt and get the best results.
● Define the Goal – Tell ChatGPT what you exactly want it to do.
● Detail out the Format – Specify the format in which you want your output. E.g., tables/paragraphs/lists,
with or without a heading, listed in priority order if any, etc.
● Create a Role – Assign ChatGPT a role to let it process your request from that specific point of view.
E.g., Act as X.
● Clarify who the Audience is – Specify the demographics for ChatGPT to help it tailor its response
appropriately.
● Give Context – Provide every possible information to ChatGPT to help it understand the purpose of
your request.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
How to Write a Good Prompt?
Here’s a checklist, to create the most effective prompt and get the best results.
● Give Examples – Share examples to let ChatGPT learn from it and produce more accurate results.
● Specify the Style – Outline the tone, the communication style, the brand identity and other details in
your prompt for a suitable response.
● Define the Scope – Outlining a scope with further specifications besides giving a context and examples,
will help ChatGPT operate within those parameters.
● Apply Restrictions – Constraints or restrictions applied in your prompt will create the right boundaries
for ChatGPT to produce more relevant responses.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Different Prompt Patterns
What are some of the most common Prompt Patterns?
1. Persona Pattern - Act as X. Do the task Y. (E.g., As a Yoga instructor, create a beginner-friendly routine for joint
mobility.)
2. Audience Persona Pattern - Explain X to me. Assume I’m Y. (E.g., Explain the importance of eating greens. Assume
I’m a skeptical child.)
3. Visualization Generator Pattern - Generate X that can be provided to tool Y for visualization. (E.g., While talking
about the data around user engagement metrics on certain website, generate a CSV that I can use in Tableau to
create a visualization.)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Different Prompt Patterns
What are some of the most common Prompt Patterns?
4. Recipe Pattern - In order to do X, I need to perform steps a, b, c. Provide a complete sequence of steps for me
while filling in any missing steps and removing redundant steps. (Eg: I want to travel from Bangalore to Darjeeling. I
know I have to take a flight to Kolkata. And from there take train and a cab to Darjeeling. Complete the itinerary
for me)
5. Template Pattern - I will provide a template, with placeholders for content. Fit the output with one or more
placeholders that I list.
Eg: Generate a day-wise travel itinerary for visiting Paris.
My placeholders are -
❏ <Day> for the day of the travel plan
❏ <Location> for the place to visit
❏ <Activity> for what to do in that place
❏ <Time> for the best part of the day to visit
Template: For <Day>Proprietary
visit <Location> at <Time> for <Activity>
content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Examples
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Advanced Prompt Strategies
Here’s a few instances of advanced prompt strategies:
● Zero-Shot Learning - Directly instructing the model to perform a task without any additional examples.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Common Prompting Errors
1. Vague or Ambiguous Prompts
2. Biased Prompts
3. Lack of Contextual Information
4. Insufficient Examples or Training Data
5. Complex or Confusing Prompts
6. Not testing prompts thoroughly
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Limitations of Generative Models
1. Hallucinations - produce imaginative and surreal responses
2. Token length - tokens available 4096 tokens for input & 2048 for output
3. Pricing - for better versions / increase in token size
4. Resource Intensive - computationally expensive and resource-intensive
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Applications of Prompt Engineering
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Summary
Here’s a brief recap:
● The key to becoming a proficient prompt engineer is practice.
○ Experiment with different prompts.
○ Analyze the outcomes.
○ Refine your techniques.
● Keep practicing, stay curious, and explore various AI platforms to enhance your skills.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.