Module 3
Introduction to Prompt Engineering
1.1 Introduction to Prompt Engineering
What is Generative AI?
Generative AI is an AI that can create something like:
Text
Images
Audio
Videos
3D models
Generative AIs analyze and use existing data and input from a user to generate these things.
Giving Generative AIs input is known as AI Prompt Writing or AI Prompt Engineering.
1.1.1 What is Prompt Engineering?
AI Prompt Writing (or Engineering) is the process of creating input (usually text) instructing
the Generative AI to generate the desired response.
In other words, prompting is the way we ask an AI to do something.
A prompt should be tailored to the type of response you want to receive and to the specifics
of the Generative AI you use.
Fig. 1 Prompt input
Prompt Engineering is the process of designing and refining the inputs (called prompts)
given to large language models (LLMs) like GPT-5 to achieve desired, accurate, and reliable
outputs. Since these models generate responses based on the text they receive, the quality and
structure of the prompt directly influence the quality of the result.
What Is a Prompt?
A prompt is any input or instruction given to an AI model to generate a response.
It can be as simple as a question —
“Explain photosynthesis in simple terms.”
or as complex as a structured instruction —
“Write a 200-word blog introduction about renewable energy using a friendly tone, including
two key statistics.”
Why Prompt Engineering Is Important
Prompt engineering helps you:
1. Improve accuracy – Better prompts yield more relevant, factual answers.
2. Control output style – You can define tone, format, and length.
3. Save time – Well-designed prompts reduce trial-and-error.
4. Enhance creativity – Prompts can inspire new ideas or solutions.
5. Enable complex tasks – With multi-step or chain prompts, you can perform
reasoning, analysis, or coding tasks efficiently.
Core Principles of Prompt Engineering
1. Clarity: Be specific and unambiguous.
2. Context: Provide background information and examples.
3. Constraints: Specify format, tone, or length.
4. Role Assignment: Tell the model who it should act as (e.g., “Act as a data
analyst…”).
5. Iteration: Refine prompts based on results (prompt tuning).
Example
Poor prompt:
"Tell me about AI."
Better prompt:
"Explain artificial intelligence in 150 words suitable for high school students, highlighting its
real-life applications in healthcare and education."
Applications of Prompt Engineering
Education: Creating study materials and quizzes.
Software development: Generating or debugging code.
Content creation: Writing blogs, scripts, or social media posts.
Data analysis: Summarizing reports or extracting insights.
Research: Assisting in literature reviews and concept explanations.
The main prompt components in prompt engineering
Prompt components refer to the key elements that make up a well-structured prompt when
interacting with an AI model like ChatGPT (or while designing prompts for any generative AI
system). These components guide the AI’s behavior and ensure clear, useful, and relevant
responses.
Fig. 2 Components of Prompt
The main components of a prompt:
1. Instruction
This is the core directive — what you want the AI to do.
It should be clear, specific, and actionable.
Examples:
“Summarize this paragraph in 3 sentences.”
“Write a Python program to find the factorial of a number.”
“Explain photosynthesis in simple terms.”
2. Context
This provides background information or situation details to help the AI give a relevant
response.
Context helps avoid vague or generic answers.
Examples:
“You are a teacher preparing questions for a 10th-grade science class.”
“Assume this is for a job application for an assistant professor position.”
“The dataset includes information about customer purchases.”
3. Input Data (or Content)
The text, code, or data on which the AI should act.
This can be a passage to summarize, a dataset, or a code snippet.
Examples:
“Here’s the paragraph: ‘Photosynthesis is the process…’”
Given this list of numbers: [3, 7, 9, 2, 8], find the average.”
4. Output Format or Style
Specifies how you want the answer presented — list, paragraph, table, code, etc.
It helps shape the tone, length, or structure of the output.
Examples:
“Answer in bullet points.”
“Give the result in JSON format.”
“Write in a formal academic tone.”
“Provide a short answer followed by a brief explanation.”
5. Examples (optional but powerful)
Providing examples helps the AI understand the pattern or style you expect.
Examples:
Example input: “Cat”
Example output: “A small domesticated carnivorous mammal.”
6. Role (optional)
Defines the persona or perspective the AI should adopt — e.g., teacher, developer,
interviewer,
etc.
Examples:
“You are an expert Python tutor.”
“Act as a recruiter reviewing resumes.”
“Imagine you are a travel guide.”
1.1.2 What Makes Prompt Engineering Vital?
Prompt engineering is vital because it directly influences how effectively users can
communicate with AI systems and how accurately these systems understand and execute
human intentions. Its importance can be understood through the following key dimensions:
1. Increasing Precision and Management
Prompt engineering enhances the accuracy, control, and manageability of AI responses.
A well-structured prompt reduces ambiguity and helps the model focus on the user’s exact
requirement. This results in:
More precise and reliable outputs
Better management of information flow
Responses that follow specific instructions (tone, format, length, style)
Reduced errors, misunderstandings, or irrelevant answers
By controlling the AI’s reasoning, constraints, and structure, prompt engineering ensures
high-quality, targeted, and well-organized communication.
2. Increasing Uniqueness and Creativity
Prompt engineering is essential for unlocking the creative potential of AI.
Through carefully crafted prompts, users can encourage AI to:
Generate original ideas and perspectives
Produce stories, designs, examples, and inventions
Engage in brainstorming and problem-solving
Create unique content tailored to specific themes or audiences
By influencing the model’s creative direction, prompt engineering transforms AI from a
simple information tool into a source of innovation, imagination, and novel thinking.
3. Democratizing AI
Prompt engineering makes AI more accessible and usable for people with different skill
levels, backgrounds, and purposes.
It democratizes AI by:
Allowing non-experts to interact effectively with advanced AI models
Simplifying complex tasks through natural language instructions
Enabling individuals without technical expertise to perform tasks like coding,
analysis, or design
Supporting multilingual and inclusive interactions
Reducing the digital divide by making AI tools universally understandable
Through simple and intuitive prompts, AI becomes a tool that anyone can use, empowering a
wider population to benefit from artificial intelligence.
1.2 The Evolution of Prompt Engineering / History of Prompt Engineering
1. Early Origins (Before 2020) – The Foundation
Before the term prompt engineering existed, early AI systems like ELIZA (1966) and
chatbots in the 1990s–2000s already relied on text prompts — simple keyword-based
or rule-based inputs to generate replies.
With the rise of machine learning and natural language processing (NLP),
researchers used structured queries or templates to interact with models like
Word2Vec (2013), ELMo (2018), and BERT (2018).
However, these models were not generative — they understood text but couldn’t
freely produce long, coherent responses.
2. The Birth of Prompting (2018–2020) – GPT Era Begins
In 2018, OpenAI introduced GPT (Generative Pre-trained Transformer) — the
first model capable of understanding and generating human-like text.
GPT-2 (2019) popularized the idea that the same model could perform multiple tasks
just by changing the prompt — no retraining required.
o Example:
“Translate this sentence to French:” → language translation
“Summarize this paragraph:” → text summarization
This was the beginning of prompt-based learning, where wording the input
carefully drastically affected the output.
3. Emergence of Prompt Engineering (2020–2022) – The Skill Takes Shape
With GPT-3 (2020), the concept of Prompt Engineering truly emerged.
o GPT-3 could perform diverse tasks like writing essays, solving logic problems,
or generating code — if prompted correctly.
Researchers and users discovered that:
o Specificity and context improved results.
o Adding examples in the prompt (called few-shot prompting) boosted
accuracy.
Terms like “zero-shot,” “one-shot,” and “few-shot learning” became common.
Professionals began treating prompt design as a new form of programming —
“programming with language.”
4. Refinement and Innovation (2022–2024) – Advanced Prompting
The release of ChatGPT (late 2022) made prompt engineering mainstream.
Techniques like:
o Chain-of-Thought Prompting – guiding the model to “think step-by-step.”
o Role-based prompting – assigning a persona like “You are a legal expert.”
o ReAct (Reason + Act) and Tree-of-Thoughts methods were developed to
structure reasoning.
Communities, courses, and jobs around prompt engineering emerged rapidly.
5. Modern Era (2024–Present) – Prompt Engineering + AI Alignment
Modern large models (e.g., GPT-4, GPT-5, Claude, Gemini) use system prompts and
multi-modal prompting (text + image + code).
Prompt engineering evolved into prompt design and orchestration:
o Combining multiple prompts.
o Using prompt chaining and API-level control.
o Employing AI agents that dynamically generate and refine their own prompts.
The focus today is on precision, ethics, and alignment, ensuring prompts yield safe,
truthful, and useful outputs.
Timeline of Prompt Engineering
Year Milestone Description
1966 ELIZA Early rule-based chatbot using text input
2018 GPT First generative transformer model
2019 GPT-2 Demonstrated power of text-based task control
2020 GPT-3 Prompt engineering recognized as a skill
2022 ChatGPT Mass adoption; prompting techniques formalized
2024+ GPT-4, GPT-5 Advanced prompt strategies and multi-modal systems
Prompt Engineering evolved from simple text inputs into a core discipline of AI interaction.
It’s now a blend of linguistics, psychology, and programming, helping humans
communicate intentions clearly to powerful AI systems — the new literacy of the AI age.
1.3 Different Types of Prompts
1. Natural Language Prompt
The term "Natural Language Prompts" simply refers to the core method of interacting with a
Large Language Model (LLM): using human language (like English, Spanish, etc.) to instruct
the AI, rather than using code, formal queries, or structured commands
Key Components of an Effective Natural Language Prompt
The effectiveness of a natural language prompt often comes down to including the "4 C's":
Context, Command, Constraints, and Cue.
1. Command (The Action)
This is the core task. Use strong action verbs to tell the AI exactly what to do.
Imperative Examples
Summarize "Summarize the following article into three bullet points."
Generate "Generate a list of 5 blog post titles."
Analyze "Analyze the sentiment of this customer review."
Rewrite "Rewrite the first paragraph to be more formal."
Explain "Explain quantum entanglement to a 5th grader."
2. Context (The Background)
This provides the model with the necessary information to frame its answer, ensuring
relevance and accuracy.
Input Data: The text, code, or data the model needs to process (often placed at the end,
separated by delimiters like ### or quotation marks).
Example: "Based on this sales data..."
3. Constraints (The Rules)
These are limits or formatting rules that shape the output, making it predictable and usable.
Constraint Type Example
Format "Format the output as a Markdown table."
Length "Keep the response under 100 words."
Style/Tone "Adopt a humorous and optimistic tone."
Exclusions "Do not mention any specific company names."
4. Persona/Role (The Voice)
This instructs the model to adopt a specific identity, which grounds its knowledge and
influences
its tone and vocabulary.
Example: "Act as a seasoned financial analyst..."
2. System Prompt
A system prompt (also called system instruction or system message) is a special instruction
given to an AI model before the conversation starts. It sets the overall behavior, tone, rules,
and identity of the AI.
It acts like the AI’s “role” or “personality configuration.”
What a System Prompt Does
A system prompt can:
Define how the AI should behave
Define what role it should play (e.g., teacher, mentor, programmer)
Set the tone (formal, friendly, concise, detailed)
Specify rules or constraints (don’t answer certain topics, prioritise accuracy, etc.)
Shape the entire conversation that follows
Example of a System Prompt
You are a helpful AI tutor.
Explain concepts simply, give examples, and avoid technical jargon unless necessary.
If the user asks for code, include comments in every snippet.
Keep the tone friendly and encouraging.
Why System Prompts Are Important
They control:
The quality of responses
The consistency of answers
The safety or specialization of the model
The persona of the AI
System Prompt vs. User Prompt
Type Given By Purpose
System Prompt Developer / Instructor Defines AI’s behavior
User Prompt User Asks questions or tasks
Assistant Prompt AI itself Follows system + user instructions
3. Conditional Prompt
A Conditional Prompt is a prompt structure where the AI’s response changes based on
specific conditions you define.
It works like “IF-THEN” logic inside a prompt.
Definition
A Conditional Prompt tells the AI:
If the user input matches a certain condition, respond in one way
Otherwise, respond differently
It is used to control behavior, classify input, or create branching logic within a
conversation.
Simple Example
If the user asks for definitions, give short and simple answers.
If the user asks for examples, give 3 detailed examples.
If the user asks to compare concepts, provide a table.
Otherwise, ask the user to clarify.
Advanced Example
If the user input contains programming code, correct it and explain the fix.
If the input is a question about theory, answer academically with citations.
If the input is personal writing, rewrite it politely and improve tone.
If none of the above, respond normally.
Conditional Prompt Format
A conditional prompt usually follows this pattern:
When <condition>, do <action>.
When <condition>, do <action>.
Otherwise, <fallback action>.
1.4 How does prompt engineering work?
Prompt engineering works by designing clear, structured, and strategic instructions that
guide an AI model to produce the most accurate, useful, and controlled output. It’s basically
the art + science of “telling an AI exactly what you want.”
How Prompt Engineering Works (Step-by-Step)
1. AI models follow instructions literally
Large Language Models (LLMs) don’t “think” like humans.
They detect patterns in your prompt and generate text that best continues it.
So the quality of your prompt = quality of the answer.
2. Prompts shape the AI’s behavior
A prompt can tell the AI:
who to be (role)
how to write (tone + format)
what to include/exclude
how long or short the answer should be
what method to follow
Example:
Act as a compiler design teacher. Explain the topic in simple words with examples.
This changes the model’s behavior instantly.
3. Prompts act as constraints
AI will follow rules if stated clearly:
Give the answer in 3 points.
Use a table.
Do not repeat the question.
The more specific → the more controlled the output.
4. Prompts can contain hidden logic
Prompts can embed conditional or multi-step instructions.
Example (with steps):
Step 1: Summarize.
Step 2: Break into bullet points.
Step 3: Ask the user if they want examples.
Example (conditional):
If the input is long, summarize it.
If it contains code, debug it.
Otherwise, explain it.
This is how advanced prompt engineering is done.
5. LLMs respond better to structured inputs
Well-structured prompts give better results than vague ones.
Bad prompt:
Explain lexical analysis.
Good prompt:
Explain lexical analysis in compiler design.
Use simple language.
Include one diagram in text form.
Give 2 real-world examples.
The second prompt provides context + constraints + format, so the model performs better.
6. Prompt engineering reduces hallucination
Clear instructions help avoid incorrect or fabricated answers.
Example:
If you are unsure, say 'I don't know'.
Always base your answer on factual information.
7. Prompts can break tasks into smaller problems
This is called Chain-of-Thought prompting.
Example:
Think step-by-step before giving the final answer.
This improves reasoning and accuracy.
1.5 Comprehending Prompt Engineering’s Function in Communication
Prompt engineering plays a crucial role in shaping effective communication between humans
and AI systems. By designing precise, adaptable, and ethically guided prompts, users can
enhance the quality, clarity, and impact of AI-generated responses. Its function in
communication can be understood through the following dimensions:
1. Improving Specificity and Clarity
Prompt engineering helps eliminate ambiguity by guiding the AI to focus on exact
requirements.
Clear, well-structured prompts lead to:
Precise interpretations
More accurate answers
Reduced chances of irrelevant or vague responses
For example, instructing the AI with details such as tone, format, length, or purpose ensures
that communication becomes transparent, targeted, and consistent. This greatly enhances
the effectiveness of human–AI interaction.
2. Increasing Creativity and Engagement
Prompts can be crafted to stimulate the AI’s imaginative and narrative abilities.
By including creativity-oriented instructions—such as storytelling modes, brainstorming
tasks, or role-based perspectives—users can:
Generate innovative ideas
Produce engaging content
Explore multiple viewpoints
Creative prompting makes communication interactive, dynamic, and more engaging,
especially in educational, artistic, and problem-solving contexts.
3. Adapting Communication to Different Contexts
Prompt engineering allows the AI to adjust its communication style based on situational
needs.
Prompts can instruct the AI to function as:
A teacher
A technical expert
A student-level explainer
A formal writer
A marketing professional
This adaptability ensures that responses are contextually appropriate, whether the situation
demands simplicity, professionalism, technical depth, or conversational tone. Thus, prompt
engineering supports contextual flexibility in communication.
4. Overcoming Linguistic Barriers
Prompt engineering helps bridge gaps caused by differences in language proficiency,
vocabulary, or cultural expression.
Through carefully designed prompts, users can request:
Simplified language
Translations
Rephrasing in plain terms
Explanations with examples
Multilingual responses
This allows communication to become more inclusive, accessible, and comprehensible,
enabling users from various linguistic backgrounds to interact effectively with AI.
5. Addressing Ethical Issues
Prompt engineering also has an ethical dimension. Clear prompts can guide the AI to avoid:
Biased language
Harmful content
Sensitive topics
Misleading or fabricated information
By including safety instructions—such as “If unsure, state uncertainty”, “Avoid harmful
assumptions,” or “Follow academic integrity”—users ensure ethical, responsible, and
trustworthy communication.
Thus, prompt engineering helps reinforce fairness, safety, and accountability in AI-based
interactions.
1.6 The Advantages of Prompt Engineering
One effective method for raising LLM performance is prompt engineering. Prompt engineers
can assist LLMs in producing more precise, consistent, and imaginative results by carefully
constructing prompts. Several uses for this could be advantageous, including:
Question answering: By using prompt engineering, LLMs can respond to factual queries with
greater accuracy.
Creative writing: LLMs can produce more imaginative and captivating material, including
stories, poetry, and scripts, by using prompt engineering.
Machine translation: The precision of LLMs’ language translations can be increased through
prompt engineering.
Coding: LLMs can produce more precise and effective code by using prompt engineering.
Fig. 3 Question answering
Fig. 4 Coding
1.7 The Future of LLM Communication
The communication capabilities of Large Language Models (LLMs) are evolving rapidly, and
their future is expected to transform human–computer interaction in several key ways:
1. More Natural and Human-Like Interaction
LLMs will increasingly understand context, tone, and intent.
Conversations will feel more like interacting with a human, with improved empathy,
responsiveness, and coherence.
Multi-turn dialogue will become smoother, with models remembering previous
context across interactions.
2. Enhanced Personalization
Future LLMs will tailor communication based on user preferences, goals, and
knowledge level.
They will adapt responses to be technical for experts or simplified for beginners.
Personalized prompts and memory features will make AI assistants more effective and
relevant.
3. Multimodal and Cross-Lingual Communication
LLMs will not be limited to text—they will integrate voice, images, video, and other
sensory data.
Cross-lingual communication will allow seamless translation and interaction in
multiple languages.
Users will communicate naturally across cultural and linguistic boundaries.
4. Greater Creativity and Problem-Solving
LLMs will support ideation, content creation, and collaborative problem-solving.
Advanced models will combine reasoning, knowledge retrieval, and creative thinking
to generate innovative solutions.
Collaboration between humans and AI will be more dynamic and productive.
5. Ethical and Safe Communication
The future will emphasize trustworthy, safe, and unbiased AI communication.
LLMs will follow stricter ethical guidelines to avoid misinformation, harmful
content, or biases.
Transparent and responsible AI communication will be a priority in all domains.
6. Integration with Everyday Life
LLMs will become part of education, business, healthcare, entertainment, and
personal productivity tools.
Communication with AI will be continuous, contextual, and embedded into daily
routines.
LLMs will act as intelligent assistants, co-creators, and advisors.
1.8 Conclusion
In conclusion, the realm of prompt engineering stands as a gateway to unlocking the vast
potential inherent in large language models (LLMs). Through this chapter’s exploration,
we’ve uncovered the intricate balance between artistry and precision required to craft
prompts that guide these powerful AI systems toward remarkable outcomes. Prompt
engineering embodies the delicate process of directing an LLM’s creativity and knowledge,
akin to inspiring a gifted artist without stifling their unique expression. These prompts serve
as blueprints, framing the context, and steering the LLM’s responses to produce tailored
outputs, whether creative, persuasive, or educational. The significance of prompt engineering
extends beyond mere guidance; it enables LLMs to transcend their pre-programmed limits,
leveraging their vast knowledge for tasks ranging from storytelling to addressing scientific
inquiries. However, precision in prompt creation becomes pivotal, particularly in domains
where accuracy is paramount. Tracing its evolution, from early chatbots to revolutionary
advancements like the Transformer architecture, prompt engineering has undergone
significant development, empowering LLMs to generate human-caliber content. Looking
ahead, specialized prompting languages and ethical considerations are poised to shape the
responsible and streamlined evolution of this field.
Prompt engineering’s role in communication is pivotal, serving as a beacon for clear,
adaptable interactions while requiring ethical vigilance to mitigate biases and ensure
responsible communication practices. Envisioning the future, prompt engineering holds the
potential to revolutionize AI applications, from negotiation tools to personalized news
updates, reshaping human-AI interactions profoundly. This chapter lays the groundwork for a
deeper exploration into the nuanced mechanisms, ethical imperatives, and transformative
possibilities embedded within prompt engineering, inviting further inquiry into its role in
shaping the evolving landscape of human-AI collaboration.