SlideShare a Scribd company logo
Introduction to
Prompt Engineering
CHAMEERA DEDDUWAGE
MANAGER – DIGITAL STRATEGY
B.SC., PG. DIP (APPLIED STATISTICS)
Most of us use ChatGPT and other LLMs
for writing text. But it can do more.
Writing
◦ Elaboration – expands an idea into a larger text.
◦ Summarisation - summarises a large text into a smaller text.
Conceptualisation
◦ Ideation – lateral expansion of a text/idea based on similarities
◦ Extraction – extracting data, features, and information from a text.
◦ Transformation – transform data from one format to another.
Entity-relations
◦ Classification – classifying entities based on given data.
◦ Relationships – find relationships between entities in a text.
Part I: Introduction to
Prompts
What is a
prompt?
A prompt is a natural language request submitted to a
language model to receive a response.
Prompts can contain questions, instructions, contextual
information, examples, and partial input for the model to
complete or continue.
After the model receives a prompt, depending on the type of
model being used, it can generate text, embeddings, code,
images, videos, music, and more.
What are the types of prompts?
Input (required)
◦ Question
◦ Task
◦ Entity
◦ Completion
Context (optional)
Examples (optional)
Question-type inputs
A question input is a question that you ask the
model that the model provides an answer to.
Example:
What are the top 10 most travelled
destinations in Asia?
Task inputs
A task input is a task that you want the model
to perform. For example, you can tell the
model to give you ideas or suggestions for
something.
Example:
Give me a list of steps (numbered) to travel
from Paris to Moscow, using only public
transport.
Entity inputs
An entity input is what the model acts on, such
as classifying or summarising. This type of
input can benefit from the inclusion of
instructions.
Example:
Classify the following items as [large, small].
Elephant
Mouse
Snail
Completion inputs
A completion input is a text that the model is
expected to complete or continue.
Example:
Some simple writing devices to use in fiction
would be...
Context: an example
Marbles:
Color: red
Number: 12
Color: blue
Number: 28
Color: yellow
Number: 15
Color: green
Number: 17
How many green marbles are there?
Context: transformation
E.g.,
Transform this data into JSON format.
Context: transformation
E.g.,
Convert this to an unordered list in LaTex.
Here's the JSON representationconverted into an
unorderedlist in LaTeX format:
begin{itemize}
item textbf{Color:} red, textbf{Number:}12
item textbf{Color:} blue, textbf{Number:}28
item textbf{Color:} yellow, textbf{Number:}15
item textbf{Color:} green, textbf{Number:}17
end{itemize}
Part II: General
Considerations
Clear definition of the task
Example:
Give me a paragraph arguing that Large
Language Models can help humans discover
new, unseen connections.
Applying constraints
Example:
This paragraph was a bit too long. Give me a
50-word paragraph.
Setting rules
Example:
Expand the above paragraph to a 100-word
paragraph. The word "inevitable" must be
there. Mark that word with a bold text.
Setting the tone
Example:
Rewrite the same paragraph in a playful tone.
Define the format
Example:
Transform the same to a bullet list. Preserve
the tone.
Few-shot, one-shot, and zero-shot
Example:
Please choose the most verbose explanation
from these two:
Question: Why is sky blue?
Explanation 1: The sky appears blue because
of Rayleigh scattering, which causes shorter
blue wavelengths of light to be scattered more
easily than longer red wavelengths, making
the sky look blue.
Explanation 2: Due to the Rayleigh scattering
effect.
Context, context, context…
Example:
Consider the following exchange:
Ella: Being a woman is not cosplay.
Betty: That's transphobic!
Context:Ella is a natural-born female, hardcore
Christian, and politically conservative, whereas
Betty is an atheist trans-woman.
Is Betty's exclamation justified?
Enforce selection (1)
Example:
What should I do to fix my disconnected wifi?
The light on my Wifi router is yellow and
blinking slowly.
Enforce selection (2)
Enforce selection (3)
Example:
Multiple choice problem: Which of the
following options describes the book The
Odyssey?
Options:
- thriller
- sci-fi
- mythology
- biography
Prompt not just the content, but the
format as well (1)
Example:
Create an outline for an essay about the
history of Galle, Sri Lanka.
I. Introduction
*
Prompt not just the content, but the
format as well (2)
Example:
At a particular food joint, an order can contain
between 0-5 of the following: Ulundu Vadai,
Masala Vadai, Alu Bonda, and Chai.
A customer orders 2 Masala Vadai + a Chai.
Display the order in JSON format. Display zero-
volume items as well. Display as a copiable
code block.
See you on next
Monday.
THAT’S IT FOR TODAY.

More Related Content

Introduction to Prompt Engineering (Focusing on ChatGPT)

  • 1. Introduction to Prompt Engineering CHAMEERA DEDDUWAGE MANAGER – DIGITAL STRATEGY B.SC., PG. DIP (APPLIED STATISTICS)
  • 2. Most of us use ChatGPT and other LLMs for writing text. But it can do more. Writing ◦ Elaboration – expands an idea into a larger text. ◦ Summarisation - summarises a large text into a smaller text. Conceptualisation ◦ Ideation – lateral expansion of a text/idea based on similarities ◦ Extraction – extracting data, features, and information from a text. ◦ Transformation – transform data from one format to another. Entity-relations ◦ Classification – classifying entities based on given data. ◦ Relationships – find relationships between entities in a text.
  • 3. Part I: Introduction to Prompts
  • 4. What is a prompt? A prompt is a natural language request submitted to a language model to receive a response. Prompts can contain questions, instructions, contextual information, examples, and partial input for the model to complete or continue. After the model receives a prompt, depending on the type of model being used, it can generate text, embeddings, code, images, videos, music, and more.
  • 5. What are the types of prompts? Input (required) ◦ Question ◦ Task ◦ Entity ◦ Completion Context (optional) Examples (optional)
  • 6. Question-type inputs A question input is a question that you ask the model that the model provides an answer to. Example: What are the top 10 most travelled destinations in Asia?
  • 7. Task inputs A task input is a task that you want the model to perform. For example, you can tell the model to give you ideas or suggestions for something. Example: Give me a list of steps (numbered) to travel from Paris to Moscow, using only public transport.
  • 8. Entity inputs An entity input is what the model acts on, such as classifying or summarising. This type of input can benefit from the inclusion of instructions. Example: Classify the following items as [large, small]. Elephant Mouse Snail
  • 9. Completion inputs A completion input is a text that the model is expected to complete or continue. Example: Some simple writing devices to use in fiction would be...
  • 10. Context: an example Marbles: Color: red Number: 12 Color: blue Number: 28 Color: yellow Number: 15 Color: green Number: 17 How many green marbles are there?
  • 12. Context: transformation E.g., Convert this to an unordered list in LaTex. Here's the JSON representationconverted into an unorderedlist in LaTeX format: begin{itemize} item textbf{Color:} red, textbf{Number:}12 item textbf{Color:} blue, textbf{Number:}28 item textbf{Color:} yellow, textbf{Number:}15 item textbf{Color:} green, textbf{Number:}17 end{itemize}
  • 14. Clear definition of the task Example: Give me a paragraph arguing that Large Language Models can help humans discover new, unseen connections.
  • 15. Applying constraints Example: This paragraph was a bit too long. Give me a 50-word paragraph.
  • 16. Setting rules Example: Expand the above paragraph to a 100-word paragraph. The word "inevitable" must be there. Mark that word with a bold text.
  • 17. Setting the tone Example: Rewrite the same paragraph in a playful tone.
  • 18. Define the format Example: Transform the same to a bullet list. Preserve the tone.
  • 19. Few-shot, one-shot, and zero-shot Example: Please choose the most verbose explanation from these two: Question: Why is sky blue? Explanation 1: The sky appears blue because of Rayleigh scattering, which causes shorter blue wavelengths of light to be scattered more easily than longer red wavelengths, making the sky look blue. Explanation 2: Due to the Rayleigh scattering effect.
  • 20. Context, context, context… Example: Consider the following exchange: Ella: Being a woman is not cosplay. Betty: That's transphobic! Context:Ella is a natural-born female, hardcore Christian, and politically conservative, whereas Betty is an atheist trans-woman. Is Betty's exclamation justified?
  • 21. Enforce selection (1) Example: What should I do to fix my disconnected wifi? The light on my Wifi router is yellow and blinking slowly.
  • 23. Enforce selection (3) Example: Multiple choice problem: Which of the following options describes the book The Odyssey? Options: - thriller - sci-fi - mythology - biography
  • 24. Prompt not just the content, but the format as well (1) Example: Create an outline for an essay about the history of Galle, Sri Lanka. I. Introduction *
  • 25. Prompt not just the content, but the format as well (2) Example: At a particular food joint, an order can contain between 0-5 of the following: Ulundu Vadai, Masala Vadai, Alu Bonda, and Chai. A customer orders 2 Masala Vadai + a Chai. Display the order in JSON format. Display zero- volume items as well. Display as a copiable code block.
  • 26. See you on next Monday. THAT’S IT FOR TODAY.