0% found this document useful (0 votes)
7 views28 pages

Prompt Engineering BAET

The document provides an overview of Prompt Engineering, which involves developing and optimizing prompts for language models to perform various tasks. It covers advanced techniques, vulnerabilities, and guidelines for effective prompting, including the importance of parameters like temperature and max_tokens. Additionally, it discusses the role of Reinforcement Learning from Human Feedback (RLHF) in enhancing model performance and addresses potential issues such as model hallucinations and prompt injections.

Uploaded by

C Mula
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)
7 views28 pages

Prompt Engineering BAET

The document provides an overview of Prompt Engineering, which involves developing and optimizing prompts for language models to perform various tasks. It covers advanced techniques, vulnerabilities, and guidelines for effective prompting, including the importance of parameters like temperature and max_tokens. Additionally, it discusses the role of Reinforcement Learning from Human Feedback (RLHF) in enhancing model performance and addresses potential issues such as model hallucinations and prompt injections.

Uploaded by

C Mula
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
You are on page 1/ 28

Prompt Engineering

By: Akshara Shukla


Agenda

1. Introduction to Prompt Engineering


2. Advanced Techniques for Prompting
3. Prompt Vulnerabilities
4. Continuing with Prompting

2
Introduction to Prompt
Engineering

3
What are Prompts?

Prompts are the inputs or instructions that a user gives to a language


model in order to achieve a desired task.
Prompt Engineering is the field of developing and optimizing prompts to
efficiently use language models (LM) for a variety of applications

4
What are Prompts?

A prompt includes the following components:

• Instruction
• Context
• Input Data
• Output indicator

5
What are Prompts?

• Important parameters:
a. Temperature: It determines how creative the model should be
b. Max_tokens: Sets the maximum length for the model's output
c. Top_p: Cumulative probability distribution
• Prompting is stochastic in nature

6
Prompting Tools

Their are a wide variety of LLM models, APIs, and platforms available for
prompting.

7
Prompting Use Cases

Use Cases:
1. Text Summarization
2. Code Generation
3. Role Playing
4. Entity Extraction
and many more…

8
Text Summarization

9
Code Generation

10
Role Playing

11
Entity Extraction

Use the following text and extract the relevant keywords that
match the labels: name, color, age.

Text: Emily is going on a trip with John and Luuk. Their ages
are 22, 25 and 24 respectively. Additionally, they are all
wearing their favorite colored clothes. Emily wears a blue
color dress, John with brown and Luuk with green.

Name, Color, Age


Emily, Blue, 22
John, Brown, 25
Luuk, Green, 24

12
Advanced Techniques for
Prompting

13
Prompt Engineering Techniques

There are many ways to train or prompt an LLM model:


1. Zero vs Few Shot Learning
2. Chain - of - thought (COT) prompting
3. Program Aided Language Model (Pal)

14
Zero vs Few Shot

Use the following sentences and their


labels to understand the sentiment and
Label the following sentence into use it to predict the label of the input
positive, negative or neutral phrase.
Text: I am so bored!
Label: Positive
Text: Emily is going on a trip to Text: She is working really hard.
Paris! Label: Neutral
Text: They are such a huge group.
Label: Positive
Label: Positive Text: The sky is blue and it’s really
sunny.
Label:

Label: Neutral

15
Chain - of - thought (COT) prompting

• Complex reasoning
capabilities through
intermediate reasoning steps
• Combine it with few shot to get
better results
• Zero Shot -> "Let's think step
by step"

16
Program Aided Language Model (Pal)

• Read and generate


intermediate reasoning
steps as programming
steps

17
Prompt Vulnerabilities

18
Prompt Vulnerabilities

• Prompting is used for improving performance but also an important part


is to ensure the reliability of the result.
• LLMs are prone to various vulnerabilities:
1. Model Hallucinations
2. Prompt Injections
3. Prompt Leaking
4. Jailbreaking
• Possible solutions
• Reinforcement Learning from Human Feedback (RLHF)

19
Model Hallucinations

Causes:
• Insufficient training data
• Presence of unseen data
• Poor written prompts

20
Prompt Injections

• Prompt Injection is the process of overriding original instructions in the


prompt with special user input

21
Prompt Leaking

• Prompt leaking is a form of prompt injection in which the model is asked


to spit out its own prompt.
• Leads to leakage of sensitive or confidential information

22
Jailbreaking

• Process of getting the LLM to do or


say unintended things through
prompting.
• Common method is “Pretending”
• Popular example: DAN (“Do
anything now”)

23
Reinforcement Learning from Human Feedback (RLHF)

• The idea is to use human feedback to measure and improve the


performance of the model.
• Used in: Chatbots, Robotics, Gaming
• Advantages
• Augmented performance
• Continuous improvement
• Enhanced Safety
• Limitations
• Bias in human feedback
• Hallucinations
• Limited and costly human feedback

24
Reinforcement Learning from Human Feedback (RLHF)

Select a pre-trained Fine - tuning the


model model

25
Continuing with Prompting

26
Continuing with Prompting

1. Guidelines:
a. GitHub - dair-ai/Prompt-Engineering-Guide
b. Prompt Engineering Guide (Papers, Datasets, Notebooks)
c. Prompt engineering - OpenAI API

2. Courses:
a. ChatGPT Prompt Engineering for Developers - DeepLearning.AI (Partnered with OpenAI)

3. Research Papers
a. https://arxiv.org/pdf/2302.03494.pdf
b. https://arxiv.org/pdf/2310.14735.pdf

27
Thank you for your
attention!

28

You might also like