0% found this document useful (0 votes)
36 views38 pages

Hope To Skills: Lecture# 02 Irfan Malik, Dr. Sheraz Naseer

The document outlines the basics of Natural Language Processing (NLP), including concepts like stemming, lemmatization, tokenization, and the introduction of ChatGPT as an advanced AI language model. It discusses applications of ChatGPT, the importance of prompt engineering, and provides examples of refining prompts for better outputs. Additionally, it introduces Stable Diffusion as a tool for image generation and announces a quiz for upcoming lectures.

Uploaded by

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

Hope To Skills: Lecture# 02 Irfan Malik, Dr. Sheraz Naseer

The document outlines the basics of Natural Language Processing (NLP), including concepts like stemming, lemmatization, tokenization, and the introduction of ChatGPT as an advanced AI language model. It discusses applications of ChatGPT, the importance of prompt engineering, and provides examples of refining prompts for better outputs. Additionally, it introduces Stable Diffusion as a tool for image generation and announces a quiz for upcoming lectures.

Uploaded by

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

Hope to Skills

Lecture# 02
Irfan Malik, Dr. Sheraz Naseer
ChatGPT: Possibilities for us ?
Basics of NLP
Stemming vs Lemmatization
Stemming Lemmatization

Removing the last few characters of Lemmatization considers the context


a given word, to obtain a shorter form, and converts the word to its
often leading to incorrect meanings meaningful short form
and spelling

For example: Stemming the word For example: lemmatizing the word
‘Caring’ would return ‘Car’ ‘Caring’ would return ‘Care’

4
Tokenization
Definition: Tokenization is the process of breaking down text into smaller units
called tokens, which can be words, phrases, or even characters.

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
Getting Started with chat.openai: A Tutorial for
Beginners
(Click to skip the Tutorial)

8
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 .

9
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.

10
11
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.

12
13
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.

14
15
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.

16
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:
● Guidance: 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.

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 less coherent or
relevant outputs.

18
Temperature of Language Model
Definition: Temperature is a parameter used in language models that controls the
randomness of generated text.
Purpose: Temperature determines the degree of exploration versus exploitation
in the model's output.
● Low Temperature (e.g., 0.1): Results in more deterministic and focused
responses, with the model choosing the most probable tokens.
● High Temperature (e.g., 1.0): Introduces randomness, allowing for more
diverse and creative responses from the model.

19
OpenAI Playground

20
A Brief Overview

21
Prompt Engineering

22
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.

23
Anatomy of Prompt
Definition: In the context of Parts of a Good Prompt (Not all are
language models, a prompt necessary for each and every prompt. )
refers to the input or 1- Simulate Persona
instruction provided to the 2- Task
3- Steps to complete Task
model to generate a specific
4- Context/Constraints
response or output 5- Goal
6- Format Output

24
General Structure of Prompt
Context: Start the prompt by providing relevant information or context that informs
the model about the desired output.
Instruction: Clearly state the desired task, format, or outcome to guide the model's
response.
Additional Details: Include any specific constraints, requirements, or specifications
that shape the response.
Example: Provide an example or demonstration to illustrate the expected format or
desired output.

25
Importance of Prompt Engineering
● Ensures accurate and relevant responses.
● Mitigates bias and promotes ethical use of AI.
● Helps avoid undesired or harmful outputs.
● Enables control over chatbot behavior.

26
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.

27
Best Practices
● Understand the model: Familiarize yourself with the strengths and limitations
of the language model you are using.
● Start simple: Begin with straightforward prompts and gradually refine them
based on experimentation and feedback.
● Domain-specific prompts: Tailor prompts to specific topics or domains to
enhance response quality in specialized areas.

28
Open AI Playground
(Click here to use)

29
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."

30
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."
31
Scenario 1: Diagnosis of a Patient's Symptoms
Step 1 (Bad Prompt): "Diagnose a patient with chest pain."

Step 2 (Refined Prompt): "Based on a patient presenting with acute chest pain,
provide a differential diagnosis considering common causes such as angina,
myocardial infarction, pericarditis, and gastroesophageal reflux disease (GERD)."

Step 3 (Further Refinement): "Analyze the symptoms, medical history, and


relevant diagnostic tests of a patient experiencing acute chest pain, and formulate a
well-reasoned diagnosis, including the most likely primary condition along with
potential differential diagnoses that should be ruled out."
32
Scenario 2: Treatment Plan for a Chronic Disease
Step 1 (Bad Prompt): "Design a treatment plan for a patient with diabetes."

Step 2 (Refined Prompt): "Develop an individualized treatment plan for a newly


diagnosed patient with type 2 diabetes, taking into account their age, lifestyle factors,
comorbidities, and preferences, with a focus on diet modification and exercise."

Step 3 (Further Refinement): "Construct a comprehensive, evidence-based treatment


plan for a middle-aged patient recently diagnosed with type 2 diabetes, addressing
glycemic control, weight management, cardiovascular risk reduction, and patient
education, while considering medication options, monitoring protocols, and
psychological support." 33
Scenario 1: Debugging Code
Step 1 (Bad Prompt): "Fix the code. It's not working."

Step 2 (Refined Prompt): "Debug the provided code snippet and identify and correct any
syntax errors or logical issues that prevent it from functioning as intended. Clearly explain
the changes made and provide a tested version of the corrected code."

Step 3 (Further Refinement): "Analyze the given code segment, isolate the bugs, and
systematically address each issue, including incorrect variable assignments, missing
semicolons, and logical errors. Provide a comprehensive explanation of the debugging
process and present a refined version of the code that produces the expected output."
34
Scenario 2: Algorithm Optimization
Step 1 (Bad Prompt): "Optimize the algorithm for sorting an array."

Step 2 (Refined Prompt): "Analyze the provided sorting algorithm and identify areas
where its time complexity can be improved. Suggest specific modifications or
alternative algorithms to achieve better performance."

Step 3 (Further Refinement): "Evaluate the time and space complexity of the given
sorting algorithm, propose algorithmic modifications (e.g., switching from bubble sort
to quicksort or introducing caching techniques), and explain the expected impact on
efficiency. Discuss trade-offs and provide empirical evidence to support the proposed
35
optimization."
Introduction to Stable Diffusion
● A cutting-edge image generation tool utilizing stable diffusion models.
● Generates realistic and high-quality images through advanced diffusion
techniques.
● Allows users to explore the possibilities of image generation by controlling
diffusion parameters.
● Used in various fields including art, design, and computer vision for diverse
image generation tasks.

36
Introduction to Stable Diffusion (Try it)

37
Important Announcement
There will be a Quiz in the next lecture from the content of lecture#01 and
Lecture#1.5

38

You might also like