Module 2 Introduction To Prompt Engineering
Module 2 Introduction To Prompt Engineering
Module 2
Introduction to Prompt Engineering
1BAIA103
Dr. Manjunatha B N
Associate Professor & HoD
Dept., of CS&E (AI & ML)
1
Module 2: Introduction to Prompt Enginee ring
[Link] to Prompt Engineering
Overview of Prompt Engineering
The Evolution of Prompt Engineering
Types of Prompts
How Does Prompt Engineering Work?
The Role of Prompt Engineering in Communication
The Advantages of Prompt Engineering
The Future of Large Language Model (LLM) Communication
3
LLM (Large Language Model)
LLMs are a type of AI model designed to understand, process, and
generate human-like language.
How It Works: Trained on huge amounts of text (books, articles,
websites) so it learns patterns of language.
Examples:
ChatGPT → Answers questions like a human.
Google Gemini / Bard → Summarizes long documents.
Simple Analogy:
➢ Think of an LLM like a very smart English dictionary + storyteller.
➢ If you ask, “Explain photosynthesis, ” it writes an answer as if a teacher
explained it. 4
GenAI (Generative AI)
A special branch of AI that can create new content like text,
images, audio, or video.
How It Works: Uses models like LLMs to generate something new
based on patterns it has learned.
Examples:
Text → ChatGPT writes essays or poems.
Images → DALL·E or MidJourney creates paintings from
descriptions.
Music → AI composes songs.
Simple Analogy:
➢ AI is the brain, and LLM is the language expert, GenAI is
the artist that creates new things
5
AI is the brain, and LLM is the language expert, GenAI is the
artist that creates new things
Imagine you're in a classroom:
AI = The entire school → Many teachers for different subjects.
LLM = The English teacher → Specializes in understanding and writing language.
GenAI = A creative writing teacher → Not only explains grammar but also writes
poems, stories, and essays for you.
6
Overview of Prompt Engineering
Prompt engineering is a technique used to communicate effectively
with Large Language Models (LLMs) like ChatGPT, Gemini, or
Claude.
It focuses on designing precise and clear instructions (prompts) so
that the AI provides accurate, relevant, and desired outputs.
Simple Definition:
Prompt engineering is the skill of crafting well-structured prompts to
make AI understand exactly what you want.
7
Overview of Prompt Engineering
Prompt engineering is a technique used to communicate effectively
with Large Language Models (LLMs) like ChatGPT, Gemini, or
Claude.
It focuses on designing precise and clear instructions (prompts) so
that the AI provides accurate, relevant, and desired outputs.
Simple Definition:
Prompt engineering is the skill of crafting well-structured prompts to
make AI understand exactly what you want.
8
Overview of Prompt Engineering
Why It Matters
LLMs do not think like humans, they generate outputs based on
patterns in data.
A poor prompt = vague or irrelevant answer.
A good prompt = clear, accurate, and useful response.
Example:
❌ Bad Prompt: "Tell me about cars."
✅ Good Prompt: "List 5 differences between electric cars and
gasoline cars, focusing on cost and environmental impact."
9
Overview of Prompt Engineering
A prompt is simply the input instruction you give to an AI model. It
can be a question, command, or example that guides the model to
produce the desired response.
Key idea: The better and clearer the prompt, the better the output.
10
Overview of Prompt Engineering
Why is a Prompt Required?
Guides the AI: A prompt helps the AI understand the context and
generate a relevant response.
Directs the Output: The quality of the AI's response depends on how
well the prompt is crafted. A good prompt leads to better, more
accurate results.
Contextual Clarity: It ensures the model responds to a specific task,
reducing ambiguity in what is expected.
11
Overview of Prompt Engineering
Why is a Prompt Required?
Guides the AI
Directs the Output
Contextual Clarity
Example of a Good Prompt:
Good Prompt: "Write a short story about a dragon and a knight who
become friends." This prompt is clear, specific, and gives the model a
clear task, so it can generate a relevant story.
Example of a Wrong Prompt:
Wrong Prompt: "Tell me about dragons." This prompt is too vague,
and the AI might give a general response about dragons without
focusing on the specific task of creating a story or narrative.
Think of an LLM as a knowledgeable chef.
If you say: "Make food" → The chef is confused.
If you say: "Make a vegetarian pasta with mushrooms, spinach, and
12
cheese" → The chef gives you exactly what you want.
Overview of Prompt Engineering
Why Are Prompts Important?
Guides the AI: Prompts tell the AI what you want it to do. Without a
clear prompt, the AI might give you something completely unrelated.
Helps Generate Accurate Results: The more specific and detailed
your prompt is, the more accurate and useful the AI's output will be.
How is Prompt Engineering Useful?
Optimizing Output: By crafting better prompts (known as prompt
engineering), we can improve the quality of the AI's responses.
Control the AI: You can direct the AI to write stories, summarize
text, generate images, and more, based on how well you ask for it.
Simple Example:
Bad Prompt: "Tell me about cats." - (Because the prompt is: 1. Too
Vague, 2. Lack of Focus & 3. Can Lead to an Unfocused Answer)
Good Prompt: "Write a fun short story about a cat who travels to the
moon."
13
Overview of Prompt Engineering
Instructions Prompt Technique
The Instructions Prompt Technique involves providing specific
guidelines to guide the AI model’s output. This helps ensure that the
generated text aligns with the desired objectives and meets the task’s
requirements.
This technique ensures that AI responses are focused and appropriate
for the task at hand by giving clear instructions.
14
Overview of Prompt Engineering
Examples:
Customer Service:
Instruction: "Responses should be professional and provide accurate
information."
Result: The AI will generate responses that are formal and factually correct.
Example Prompt: User Query: "How can I reset my password?
Legal Document:
Instruction: "The document should comply with relevant laws and regulations."
Result: Ensures the document follows legal standards.
Example Prompt: User Query: "Please create a non-disclosure agreement."
Product Review:
Instruction: "The review should be unbiased and informative."
Combined with role prompting (tech expert) and seed-word prompting
(smartphone features), it generates a detailed and balanced review.
Example Prompt: User Query: "Write a product review for the new
smartphone."
Combining Techniques:
Instructions can be paired with other techniques (like role prompting
15
or seed-word
prompting) to increase the precision and control of the model’s output.
The Evolution of Prompt Engineering
Year Milestone Description
1966 ELIZA Developed by Joseph Weizenbaum, ELIZA was a chatbot that used
simple pattern-matching to simulate a conversation, marking the
beginning of prompt-based interaction.
1970s SHRDLU Created by Terry Winograd, SHRDLU was a natural language
processing system capable of interpreting commands and reasoning
about a virtual environment.
1990s Mad Hatter Systems like Jabberwacky and ALICE used humor and open-ended
Dialogue conversations, pushing the boundaries of natural language
Systems interaction.
2000s Template based Models like Madalyn and Galatea used user input to fill predefined
Approaches templates, setting the foundation for structured prompt engineering.
2017 The The introduction of the Transformer architecture sparked a
Transformer revolution in NLP, leading to models like GPT-3 and Jurassic-1
Revolution Jumbo, which brought prominence to prompt engineering.
2020s Adjusting and Refinement and fine-tuning of large language models for specific
Refining LLMs tasks, using techniques like few-shot learning and conditional
generation for precise control. 16
Types of Prompts
1. Natural Language Prompt
Natural Language Prompt is written in plain, conversational language, just
like talking to another person.
It’s the simplest type of prompt, where you directly ask the AI for what you
want.
Output:
*"Hello! I understand that you are facing an issue with your internet
connection.
Here are a few steps you can try:
1. Restart your modem and router.
2. Check if all cables are securely connected.
3. If the issue persists, please contact our technical support team at
1800-123-456. 18
Types of Prompts
2. System Prompt
System prompts are pre-written instructions or templates that guide the AI
model on how to respond. These prompts can direct the format, style, or tone
of the output, providing a clear framework for the model to follow.
Prompt: "Write a formal email explaining the delay in project delivery."
Output:
Dear [Recipient],
19
Types of Prompts
3. Conditional Prompts
A Conditional Prompt uses if-then logic, where the AI responds differently
Prompt:
"If the user asks about the weather, give the current temperature.
If the user asks about the news, give the latest headline."
User Prompt: "What's the weather like in Bangalore?"
22
How Does Prompt Engineering Work?
Steps for Effective Prompt Engineering
Step 3: Add Specific Details
Goal: The more detailed the prompt, the better the response.
Tip: Provide enough context or constraints to guide the model effectively.
Specificity helps the model understand your exact requirements.
Example:
General Prompt: "Write a poem."
Specific Prompt: "Write a poem about the joy of summer, with imagery of the
beach and sunshine."
The second prompt gives the LLM more to work with, increasing the
chance of generating a relevant poem.
23
How Does Prompt Engineering Work?
Steps for Effective Prompt Engineering
Step 4: Provide Examples
Goal: Help the LLM understand the type of output you're expecting.
Tip: If possible, provide a sample output that demonstrates the desired
style or format. This helps the model align its output with your
expectations.
Example:
Prompt: "Write a summary of the following article in bullet points."
Example Output:
"Article Summary:
• Discusses the impact of climate change.
• Explores renewable energy solutions."
Providing an example shows the model exactly how you want the
summary to look. 24
How Does Prompt Engineering Work?
Steps for Effective Prompt Engineering
Step 5: Experiment and Refine
Goal: Prompt engineering isn’t perfect from the first try.
Tip: Test different prompts to find the one that works best.
Experimentation and iteration are key to discovering the most effective
approach.
Example:
If you’re not getting the right answer, try rephrasing the prompt or
adding more context to see if the response improves.
25
How Does Prompt Engineering Work?
Steps for Effective Prompt Engineering
Step Explanation Example
1. Understand the Be clear about your "Write an apology email for
Task expectations and goals. a delayed response.”
2. Use Precise Avoid jargon, keep it "Write a formal letter" vs.
Language simple, and be clear. "Create a letter to apologize.
3. Add Specific Include enough context "Write a poem about
Details or constraints for better summer with imagery of the
results. beach and sunshine."
4. Provide Show the LLM the type "Write a summary of this
Examples of output you’re article in bullet points like
expecting. this: ..."
5. Experiment and Keep refining your Adjusting wording or adding
Refine prompts by extra context to improve
experimenting with model output.
26
different versions.
The Role of Prompt Engineering in
Communication
Function Explanation Example
Improving Clear, precise prompts ensure "Write an email apologizing
Specificity & unambiguous communication. for the delay in the meeting
Clarity and offer a rescheduled time."
Increasing Prompts spark creativity, "Write a short story about a
Creativity & generating engaging and young artist who discovers a
Engagement thought-provoking outputs. magical paintbrush."
Adapting Prompts adjust the tone to "Write a formal email
Communication match different contexts requesting a meeting."
Styles (formal, casual, persuasive).
Overcoming Prompts help LLMs translate "Translate into Spanish: 'Could
Linguistic languages with accuracy and you please provide me with the
Barriers cultural sensitivity. details by tomorrow?'"
Ethical Issues Ethical prompt design ensures Avoiding prompts that
fairness, inclusivity, and generate biased, harmful, or
prevents manipulation or bias. discriminatory content.
27
The Advantages of Prompt Engineering
Task Benefit Example
Question Increases accuracy in "What is the capital of
Answering providing factual responses. France?" →"Paris"
Creative Enhances creativity and "Write a poem about a
Writing produces engaging, sunset" → Creative poem
imaginative content. generation.
Machine Improves precision and "Translate 'Hello' to
Translation ensures context aware French" → "Bonjour"
translations.
Coding Helps in generating accurate "Write a Python function
and effective code. for factorial" →
Generates correct Python
code.
28
The Future of Large Language Model
(LLM) Communication
▪ As LLM technology progresses, prompt engineering will continue to
evolve, shaping the way we interact with AI models.
▪ Ongoing research into adaptive prompts and AI behavior control
will make communication with LLMs more sophisticated and
contextually aware than ever before.
▪ The future holds exciting possibilities for AI-powered
communication, improving everything from language translation to
creative collaboration.
29
The Advantages of Prompt Engineering
Trend Description Example
AI-Powered AI assists in real-time negotiations, AI suggesting compromises
Negotiation providing balanced solutions for during a business meeting to
Tools win-win agreements. ensure a fair deal.
Real-Time LLMs translating languages with Seamless cross-lingual
Language understanding of cultural nuances communication in a global
Translation and context. business meeting.
Customized Personalized news feeds tailored to A personalized news feed
News Updates individual interests and preferences. focusing on environmental and
technological topics.
Automated AI systems that generate optimized Automated generation of prompts
Prompt prompts for tasks. based on task descriptions.
Generation
Adaptive Prompts adjust dynamically based An AI assistant adapting its
Prompts on user interactions, improving suggestions based on past
personalization over time. interactions.
Subtle Cues AI that responds to subtle cues, AI handling multi-step creative
for Complex managing multi step tasks projects with
30
minimal input.
Tasks intuitively.
Prompt Engineering Techniques for ChatGPT
Introduction to Prompt Engineering Techniques
▪ Prompt engineering involves crafting specific instructions (prompts) to
guide how an AI model generates responses.
▪ By providing clear and structured prompts, developers can direct the AI's
output to be relevant, accurate, and high-quality for a wide range of
tasks.
▪ Goal: The main goal of prompt engineering is to shape the model's
behavior, ensuring that the responses meet the desired standards and
objectives for a given task.
▪ Key Techniques in Prompt Engineering
Standard Prompts: Simple prompts that directly ask the AI to perform a
specific task.
Role Prompting: The model is given a specific role to play, influencing the
tone, style, or behavior of the response.
Seed-Word Prompting: The prompt provides a seed word or phrase that
the model should build upon, guiding its response based on that initial cue.
Conditional Prompting: Conditions or limitations are set for the model,
31
such as "If this, then that".
Prompt Engineering Techniques for ChatGPT
▪ Why is Prompt Engineering Important?
▪ Relevance: Well-crafted prompts ensure the model produces
relevant responses, making them more aligned with the task's
objectives.
▪ Accuracy: Prompt engineering helps the model generate responses
that are factually correct and appropriate for the given context.
▪ Versatility: Different types of prompts can be used to adapt the
model’s output to fit a wide variety of tasks, from casual
conversations to formal reports.
▪ The Future of Prompt Engineering
▪ As AI continues to advance, prompt engineering will become
increasingly important for optimizing language models. Future
developments may involve:
▪ Automated prompt generation to streamline the process.
▪ Dynamic prompts that adjust based on user interactions or context.
▪ Contextual awareness in prompts, allowing the AI to respond more
naturally and flexibly. 32
Instructions Prompt Technique
▪ The Instructions Prompt Technique is a method used to guide the
output of natural language processing models like ChatGPT by
providing specific instructions that the model must follow. This
ensures the generated text aligns with the desired objectives and
requirements of the task.
▪ Purpose: Directs the model to produce outputs based on specific
guidelines or criteria.
▪ Customization: Allows for tailoring the model's response to meet
particular goals, such as professionalism, accuracy, or legal
compliance.
▪ How It Works:
Step 1: Provide clear instructions to the model. These
instructions specify how the model should approach the task or
the style of the output.
Step 2: The model follows these instructions to generate
responses that meet the set criteria. 33
Zero, One, and Few Shot Prompting
▪ Zero, One, and Few Shot Prompting are techniques in prompt
engineering that help guide AI models, like ChatGPT, to generate
responses based on different amounts of context or examples.
▪ These techniques are useful when you want the model to produce
responses with limited information.
a. Zero Shot Prompting
b. One Shot Prompting
c. Few Shot Prompting
34
Zero, One, and Few Shot Prompting
1. Zero Shot Prompting
The model generates a response without any examples or context. You
simply give a prompt or instruction, and the model uses its pre-existing
knowledge to generate an answer.
Example:
Prompt: "Write a poem about nature."
Output: A poem generated by the model based on its general knowledge.
When to Use:
➢ When you want the model to think creatively without any specific
examples.
➢ Useful for open-ended tasks or when you want to explore the model’s
generalization abilities.
Limitation: Sometimes results may be less accurate or relevant without
context. 35
Zero, One, and Few Shot Prompting
2. One Shot Prompting
What It Is: The model generates a response based on one example you
provide. This single example helps guide the model in understanding the
context or task.
Example:
Prompt: "Summarize the following paragraph: 'The sun rises in the east and
sets in the west.’”
Output: "The sun moves across the sky from east to west."
When to Use: When you have one clear example but still need the model to
generate a response with some level of accuracy. Limitation: If the task is
complex, one example might not be enough, and you may need more
36
Zero, One, and Few Shot Prompting
3. Few Shot Prompting
The model generates a response based on a few examples you provide. This
gives the model more context and helps it generate more accurate and
relevant responses.
Example:
Prompt: *"Write a product review based on these features:
Battery life: 10 hours
Camera: 12 MP
Screen: 6.5 inches"*
Output: A detailed product review based on the provided features.
When to Use: When you need more context or examples to help the model
generate precise and relevant responses.
Limitation: You need to ensure that the examples are relevant and complete
to get the best results. 37
Zero, One, and Few Shot Prompting
Technique Description Example
Zero Shot The model generates a "Write a poem about
Prompting response without any nature."
example or context.
Generated Response:
The model, guided by the self-consistency prompt, would
provide an answer that aligns with the scientific consensus and
remains consistent with the data about climate change.
41
Self-Consistency Prompt
When to Use Self-Consistency Prompts:
Educational Content:
Ensures the information presented is accurate and aligned with
established knowledge, making it useful for creating educational
materials.
Technical Discussions:
When discussing specialized topics, like engineering or medicine,
where accuracy and adherence to known facts are critical.
Decision-Making:
In scenarios where decisions rely on consistent data or logical
42
reasoning, like business strategies or technical choices.
Prompts for Creative Thinking
1. Introduction
➢ In today’s world, creativity is essential for innovation and
problem-solving across various fields.
➢ Prompts act as tools to ignite imagination, spark new ideas, and
help overcome mental blocks.
Types of Prompts:
➢ Open-ended questions challenge conventional thinking.
➢ Playful prompts encourage unconventional associations.
Benefits of Prompts:
➢ Help expand imagination and discover new possibilities.
➢ Guide you to connect unrelated ideas and embrace curiosity.
50
Prompts for Effective Writing
Types of Writing Prompts:
Creative Writing Prompts: These prompts encourage imagination and
creativity. They’re perfect for writers working on fiction, poetry, or
storytelling.
Descriptive Writing Prompts: These focus on developing skills to describe
people, places, or objects in detail.
Problem-Solving Writing Prompts: These help you tackle challenges or
work through critical thinking in your writing.
Reflective Writing Prompts: These encourage you to explore your
thoughts, experiences, and feelings.
Persuasive Writing Prompts: These help you practice convincing readers
51
of your viewpoint on a particular issue.
Prompts for Effective Writing
Igniting the Writing Process with Prompts
"Igniting the Writing Process with Prompts" is a helpful guide
designed to kickstart your writing journey. It provides creative
prompts and practical strategies to help writers of all levels overcome
obstacles like writer's block and improve their writing skills.
1. Encourages Creativity
▪ Prompts inspire new ideas and spark imagination for writing.
They give you a starting point when you don't know where to
begin.
Example:
• Prompt: "Write about a character who discovers a hidden door
in their house."
• This prompt gets you thinking about mystery and adventure,
helping you start a story even when you’re stuck.
52
Prompts for Effective Writing
Igniting the Writing Process with Prompts
2. Overcomes Writer's Block
If you're struggling to write, prompts help you break through writer's
block by giving you a clear direction for your writing.
Example:
▪ Prompt: "Describe a place where you feel most at peace."
▪ This prompt helps you focus on writing a peaceful scene, even
if you feel stuck with ideas.
53
Prompts for Effective Writing
Igniting the Writing Process with Prompts
3. Refines Storytelling Skills
Prompts help you develop storytelling skills by encouraging you to
think about different characters, settings, and conflicts.
Example:
▪ Prompt: "Write a dialogue between two people who have just
met for the first time."
▪ This prompt helps you focus on creating characters and
conversation, improving your dialogue-writing skills.
54
Prompts for Effective Writing
Igniting the Writing Process with Prompts
4. Enhances Expression
Prompts encourage you to express yourself in new ways, whether
you're writing fiction, essays, or poetry.
Example:
▪ Prompt: "Write a poem about a rainy day."
▪ This prompt helps you explore descriptive language and
develop your creative expression.
55
Prompts for Effective Writing
Igniting the Writing Process with Prompts
5. Provides Clear Pathways for Writing
Prompts act as guides that lead you through the writing process,
making it easier to organize thoughts and ideas.
Example:
▪ Prompt: "Write an essay arguing why online education is the
future."
▪ This helps you structure your thoughts, guiding you to create a
clear argument for the essay.
56
Prompts for Effective Writing
Igniting the Writing Process with Prompts
6. Builds Confidence
By using prompts, writers gain confidence because they know exactly
where to start and can practice regularly.
Example:
▪ Prompt: "Write a letter to your future self."
▪ Writing something personal like this can make you feel more
comfortable with expressing your thoughts and ideas.
57
Prompts for Effective Writing
Why These Prompts Are Helpful:
Stimulate Creativity: Help you think of new ideas and ways to
approach writing.
Improve Writing: Develop better storytelling, descriptive writing,
and expression.
Build Confidence: Encourage regular practice and creativity, making
writing feel easier.
58
Questions???
1. Define Prompt Engineering and explain its significance in AI.
2. Discuss the evolution of Prompt Engineering.
3. What are the different types of prompts? Give examples.
4. How does Prompt Engineering work in guiding AI models like
ChatGPT?
5. Explain the role of Prompt Engineering in communication and its
importance.
6. List and describe three advantages of Prompt Engineering.
7. What is the future scope of Prompt Engineering in Large Language
Model (LLM) communication?
8. Explain the Instructions Prompt Technique and give a practical
example.
9. What are Zero, One, and Few Shot Prompting? Explain with
examples.
10. Describe the Self-Consistency Prompting technique and discuss
when it should be used.
11. Compare and contrast Zero Shot and Few Shot prompting with
examples.
12. How can prompt engineering techniques improve59the accuracy and
Questions???
13. Define Creative Thinking Prompts and explain their importance in
problem-solving.
14. Explain the key principles for unlocking imagination and fostering
innovation.
15. Discuss top three prompts for unlocking imagination and
innovation and explain their usefulness.
16. How do creative thinking prompts help in cross disciplinary
collaboration and innovation?
17. Explain how embracing failure can be used as a prompt to enhance
creativity.
18. Define a writing prompt and explain its role in effective writing.
19. Discuss the types of writing prompts with examples for each type.
20. Explain how writing prompts help overcome writer's block,
enhance expression, and build confidence.
60