0% found this document useful (0 votes)
69 views26 pages

Prompt Engineering for Generative AI

The document outlines the fundamentals of Generative AI and prompt engineering, detailing the components of effective prompts and common errors. It covers the definition and functioning of Large Language Models (LLMs), along with strategies for writing good prompts and advanced prompting techniques. Additionally, it highlights the limitations of generative models and their various applications.

Uploaded by

FAISHAL RAIYAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views26 pages

Prompt Engineering for Generative AI

The document outlines the fundamentals of Generative AI and prompt engineering, detailing the components of effective prompts and common errors. It covers the definition and functioning of Large Language Models (LLMs), along with strategies for writing good prompts and advanced prompting techniques. Additionally, it highlights the limitations of generative models and their various applications.

Uploaded by

FAISHAL RAIYAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Prompt Engineering

djfaishalraiyan@[Link]
GB01C8SJZ7

Unleashing the Power of Gen AI

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7

● Common Prompting Errors


● Limitations of Generative Models
● Applications of Prompt Engineering

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Introduction to Generative AI (Gen AI)

djfaishalraiyan@[Link]
GB01C8SJZ7

Generative AI (Gen AI) refers to Artificial Intelligence that can generate


content — be it text, images, or code — based on the input it receives from
the user.

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Understanding Gen AI

Artificial
Intelligence

Machine
Learning
djfaishalraiyan@[Link]
GB01C8SJZ7

Deep
Learning

Gen AI

LLM

ChatGPT isProprietary
here content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7
self-supervised learning on vast amounts of unlabeled text.

Base LLMs Foundational LLMs like GPT-3

LLMs

Instruction- Task-specific models following


based LLMs provided directives
Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Introduction to Large Language Models (LLMs)
How do LLMs work?

Input LLMs Tasks

1. Text Summarization
djfaishalraiyan@[Link]
Generative 2. Sentiment Analysis
Text
GB01C8SJZ7
3. Question Answering
Models 4. Information Extraction
5. Text Translation

Pre-training Fine-tuning

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Popular LLMs

djfaishalraiyan@[Link]
GB01C8SJZ7

GPT by OpenAI Mistral by OpenAI Gemini by Google Llama by Meta

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Basics of Prompt Engineering
Prompt engineering is as much an art as it is a
Idea
science.

Prompt: A detailed set of guidelines given to an


LLM to do a task. Test or
Prompt
Engineering: Developing a task-specific prompt
djfaishalraiyan@[Link]
GB01C8SJZ7 Feedback
iteratively.

Prompt Engineering is an iterative process. Results

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Basics of Prompt Engineering
Prompts

1 2
Parameters Structure
djfaishalraiyan@[Link]
GB01C8SJZ7

1. Temperature: Lower for creativity and deterministic results; Higher for


diversity and factual QA.
2. Top P: Control model determinism; Low for factual, high for diverse.
3. Max Length: Manage response length.

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
djfaishalraiyan@[Link]
GB01C8SJZ7 Let’s write a few prompts!!

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Components of a Good Prompt

Context
external information or Instruction

Additional context that A specific task or


can steer the model to instruction you want the
better responses. model to perform.
djfaishalraiyan@[Link]
GB01C8SJZ7

Input Data Output Indicator

The input or question The type or format of the


that we are interested in output.
finding a response for.

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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.
djfaishalraiyan@[Link]
GB01C8SJZ7

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7
will promote nor demote the content.

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7

Input Data and Output Indicator


Output Indicator Feedback: The storyline for the series was
Input Data
repetitive and abysmal.
Sentiment:
The input or question The type or format of the
that we are interested in output.
finding a response for.

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7
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.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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.
djfaishalraiyan@[Link]
GB01C8SJZ7
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.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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,
djfaishalraiyan@[Link]
GB01C8SJZ7
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.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7 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.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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)
djfaishalraiyan@[Link]
GB01C8SJZ7

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.
This file is meant for personal use by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Examples
djfaishalraiyan@[Link]
GB01C8SJZ7

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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.

● Few-Shot Learning – Teaching with examples in the prompt.


djfaishalraiyan@[Link]
GB01C8SJZ7

● Chain of Thought Process – Asking to show its work or thought process.

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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
djfaishalraiyan@[Link]
GB01C8SJZ7

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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

djfaishalraiyan@[Link]
GB01C8SJZ7

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Applications of Prompt Engineering

Content Customer Support Data Analysis and


Generation and Engagement Science

- Copywriting and Advertising - Chatbots and Virtual - Data Cleaning and


- Creative Writing Assistants Preparation
- Educational Content - -
djfaishalraiyan@[Link]
GB01C8SJZ7 Instructional Guides Statistical Analysis and
Visualization

Code Generation Research and


and Software Information
Development Retrieval

- Automating Code Writing


- Text Summarization
- Debugging Assistance
- Question Answering
- Documentation Generation
Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Applications of Prompt Engineering

Machine Sentiment Other


Translation Analysis Domains

- Information Sharing - Consumer Feedback Analysis - Healthcare


- Internal Communication
djfaishalraiyan@[Link] - Brand Management - Manufacturing
GB01C8SJZ7
- Marketing - Security
- Retail and Shopping

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
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.
djfaishalraiyan@[Link]
GB01C8SJZ7

Proprietary content.
This file ©Great for
is meant Learning. All Rights
personal useReserved. Unauthorized use or distribution prohibited.
by djfaishalraiyan@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.

You might also like