Lecture 05
Irfan Malik
Dr. Sheraz Naseer
Agenda
● Prompt Engineering
● Chat GPT PlayGround
Previous lecture:
Lecture 04 - Deep Dive into Generative AI
Click Here
3
Basics of NLP
4
Stemming vs Lemmatization
Stemming Lemmatization
Removing the last few Lemmatization considers the
characters of a given word, to context and converts the
obtain a shorter form, often word to its meaningful short
leading to incorrect form
meanings and spelling
For example: Stemming the For example: lemmatizing the
word ‘Caring’ would return word ‘Caring’ would return
‘Car’ ‘Care’
5
Introduction to ChatGPT
• ChatGPT stands for Generative Pretrained Transformer.
• ChatGPT is an advanced AI language model developed by OpenAI.
• ChatGPT revolutionizes Natural Language Processing.
6
Applications of ChatGPT
1.Content Generation
2.Text Summarization
3.Chatbots, Virtual Assistants, and Customer Support (Question Answering)
4.Language Translation
5.Interactive Storytelling
6.Education and Tutoring
7
Step 1: Accessing chat.openai
To begin, open your preferred web browser and navigate to the
chat.openai website. The website URL is
https://chat.openai.com/auth/login .
8
Step 2: Creating an Account
• If you already have an account, you can skip this step and proceed to
Step 3. If not, you will need to create a new account.
• Look for the "Sign Up" or "Register" button on the login page and click
on it.
• Click on “Continue with Google”, and then select your Google account.
• Follow the on-screen instructions to open the dashboard.
9
Step 3: Logging In
• Click on the "Log In" button to access your chat.openai
account.
• Click on “Continue with Google”, and then select your google
account.
10
Step 4: Engaging in Conversation
In the chat interface, you will see a text input box where you can type your
message or question.
Simply enter your text and press "Enter" or click the send button to send your
query to the AI model.
Once you've sent your message, the AI model will process it and generate a
response.
11
Generative AI
12
Tokenization
Definition: Tokenization is the process of breaking down text into smaller units
called tokens, which can be words, phrases, or even characters.
13
Tokens in Language Models
Definition: Tokens are the fundamental units of text used by language models.
They can be as short as a single character or as long as a word or phrase.
Importance: Language models process text at the token level, allowing them to
analyze and generate text based on the context and relationships between
individual tokens.
14
Prompt Engineering
15
What is Prompt Engineering?
● Prompt engineering involves crafting tailored instructions or queries to
guide the language model towards desired outputs.
● It helps shape the behavior of the model and improves response quality.
16
Anatomy of Prompt
Definition: In the context of Parts of a Good Prompt (Not all are
necessary for each and every prompt)
language models, a prompt refers
to the input or instruction 1. Simulate Persona
provided to the model to generate 2. Task
3. Steps to complete Task
a specific response or output
4. Context/Constraints
5. Goal
6. Format Output
17
Prompt Limits in Language Models
Definition: Prompt limits refer to the constraints imposed on the input provided to
a language model.
Reasons for Prompt Limits:
● Memory limitations: Language models have a finite capacity to process
and store information.
● Computational constraints: Longer prompts require more processing time
and computational resources.
● Response coherence: Extremely long prompts may result in irrelevant
outputs.
18
OpenAI Playground
19
A Brief Overview
20
Prompting Example 01
Simulate Persona: You are a customer service representative for a tech
company.
Task: Assist a customer in resolving a software issue.
Steps to complete Task:
Greet the customer and ask for details about the issue.
Provide step-by-step instructions to troubleshoot the problem.
If the issue persists, escalate it to the technical support team.
21
Context/Constraints: The customer is not tech-savvy, and you must
communicate in a friendly and non-technical manner.
Goal: Resolve the customer's issue satisfactorily.
Format Output: Provide a summary of the troubleshooting steps and any
additional information the customer might need.
22
Prompting Example 02
Simulate Persona: Imagine you are a mentor guiding a group of individuals new
to prompt engineering.
Task: Identify and address common issues in prompt creation to improve overall
effectiveness.
Steps to complete Task:
Analyze the prompt for Simulate Persona, Task, Steps to complete Task,
Context/constraints, goals and Format Output
Identify and rectify instances of ambiguity or vagueness in prompt language.
Ensure that prompts provide sufficient information for the desired task without
unnecessary complexity. 23
Context/Constraints: Consider the diverse backgrounds and skill levels of those
engaging with the prompts.
Goal: Enhance the quality of prompts by eliminating potential sources of confusion
or misinterpretation.
Format Output: Provide a revised version of a poorly constructed prompt,
highlighting the changes made and explaining how each modification contributes
to better prompt engineering.
24
Context in Prompting
Definition: Context refers to the information and preceding text that informs the
language model about the desired output or influences its response.
Role of Context:
● Context: helps shape the model's behavior and generate more accurate
responses.
● Relevance: Context ensures continuity and relevance in the generated text.
● Interpretation: The language model uses context to understand the desired
meaning and tone of the prompt.
25
Tips for Effective Prompt Engineering
● Be explicit: Clearly specify the desired format or output.
● Provide context: Offer relevant information or background to guide the
model.
● Control output length: Instruct the model to generate responses of a
specific length.
● Restrict responses: Utilize techniques like temperature adjustment to refine
output quality.
● Experiment and iterate: Refine prompts through experimentation and
feedback loops.
26
Scenario 1: Essay Writing For Students
Step 1 (Bad Prompt): "Write an essay about your favorite hobby."
Step 2 (Refined Prompt): "Write an engaging essay describing how your
favorite hobby has positively influenced your personal growth and
development."
Step 3 (Further Refinement): "Write an insightful essay explaining how
your favorite hobby, such as playing a musical instrument, has enhanced
your problem-solving skills, increased your patience, and boosted your
self-confidence."
27
Scenario 2: Historical Event Analysis
Step 1 (Bad Prompt): "Analyze the causes of World War II."
Step 2 (Refined Prompt): "Provide a comprehensive analysis of the political,
economic, and social factors that contributed to the outbreak of World War II,
considering both domestic and international influences."
Step 3 (Further Refinement): "Compose a well-structured and nuanced analysis of
the immediate triggers and long-term underlying causes of World War II, highlighting
key events and decisions that escalated tensions and ultimately led to the global
conflict."
28
Chat GPT PlayGround
29
Summary
1. Prompt Engineering
2. Best Practices
3. ChatGPT PlayGround
4. Sample prompt practise
30
Next Lecture:
Lecture 06 - Diffusion Models
Click Here
31