Introduction to AI and Applications
1BAI203
Module 3
Prompt Engineering and Generative AI
Prompting Techniques
Overview of Generative AI Models
By,
Prof. Chaitra D B
Assistant Professor
Dept. of Information Science & Engineering
BMS Institute of Technology, Bengaluru.
Department of Information Science and Engg
1
Transform Here
Chapter 1
Prompt Engineering and
Generative AI
1. Basics of Prompting
2. Prompt Elements
3. General tips for designing prompts
4. Examples of prompts
Department of Information Science and Engg
Transform Here
What is Prompt Engineering?
• Consider an LLM as a huge, intricate network of creativity and
information.
• The goal of prompt engineering is to intertwine instructions and
information into this web in a way that leads the LLM toward the
intended result.
• A prompt is the query, directive, or example given to an LLM. It
establishes the background, clarifies the assignment, and provides the
LLM answer framework.
• We can adjust the language, provide particulars, and apply different
strategies to make the LLM’s output creative, convincing, educational,
or anything else we desire.
• These prompts can be presented as conditional restrictions,
system-defined instructions, or instructions in natural language.
Department of Information Science and Engg
Transform Here
Types of Prompts
1. Natural Language Prompts:
• These prompts mimic human-like directions, offering direction in the
form of clues found in natural language. They make it possible for
developers to engage with the model more naturally by providing
commands that mimic human speech.
• Ex: What were the top news stories today?
2. System Prompts:
• These are pre-written guidelines or templates that developers supply
to direct the output of the model. They give the model clear
instructions on how to express the intended output format or behavior
in an organized manner.
• Ex: You are an AI that receives an input text. Your task is to output a
python string where every string is the name of a person with what
they are associated with.
Department of Information Science and Engg
4
Transform Here
3. Conditional Prompts:
• Conditional prompts entail subjecting the model to particular
limitations or contexts. Developers can direct the behavior of the
model by implementing conditional prompts, which are based on
conditional statements like:
“If X, then Y” or “Given A, generate B.”
Department of Information Science and Engg
5
Transform Here
Department of Information Science and Engg
6
Transform Here
Basics of Prompting
•Prompting an LLM
•Prompt Formatting
Department of Information Science and Engg
7
Transform Here
Prompting an LLM
Prompting is the action of saying something to persuade,
encourage, or remind someone to do or say something.
• The quality of results depends on how much information you
provide it and how well-crafted the prompt is.
• A prompt can contain information like
Instruction or question you are passing to the model
Other details such as context, inputs, or examples.
• You can use these elements to instruct the model more
effectively to improve the quality of results.
Department of Information Science and Engg
Transform Here
Prompt : The sky is Let's try to improve it a bit:
Output : blue. Prompt:
Complete the sentence:
The sky is
Output:
blue during the day and dark at night.
With the prompt above you are instructing the model to complete the sentence
so the result looks a lot better.
This approach of designing effective prompts to instruct the model to perform a
desired task is known as prompt engineering.
Today's LLMs are able to perform all kinds of advanced tasks that range from
text summarization to mathematical reasoning to code generation.
Department of Information Science and Engg
9
Transform Here
LLM stands for Large Language Model
An LLM is an AI system trained on vast amounts of text data to understand and
generate human-like language. It learns patterns, grammar, facts, reasoning, and
context from that data.
How it works
It uses a neural network architecture called a transformer.
During training, it processes billions (or trillions) of words to predict the next word
in a sentence.
Over time, it learns relationships between words, sentences, and ideas — giving it
the ability to chat, translate, summarize, or even code.
What they can do
Examples LLMs can:
• GPT-5 — made by OpenAI. •Answer questions
• Claude — by Anthropic. •Write essays, poems, or code
• Gemini — by Google DeepMind. •Translate languages
• LLaMA — by Meta. •Analyze or summarize documents
• Etc. •Simulate conversations or reasoning
Department of Information Science and Engg
10
Transform Here
How are LLMs Trained?
Step-1: Data Collection
• LLMs are trained on enormous amounts of text — from books, articles, websites, forums, and
other sources.
• The text is cleaned, filtered, and tokenized (split into small pieces called tokens — like words
or word fragments).
Step-2: Pretraining
• The model learns to predict the next word in a sentence.
• For example, given:
“The cat sat on the ___”
it learns that “mat” is a likely next token.
• By doing this billions of times, the model learns grammar, facts, and reasoning patterns.
Step-3: Architecture: Transformers
• Transformers use attention mechanisms to figure out which words in a sentence are most
relevant to each other.
• This is what lets the model handle long passages and nuanced (subtle) meanings.
Department of Information Science and Engg
11
Transform Here
Step-4: Fine-tuning
• After pretraining, the model is further trained for specific goals — e.g., to
follow instructions, stay safe, or write code.
• OpenAI uses Reinforcement Learning from Human Feedback (RLHF) —
where humans rate the model’s responses, and it learns to produce helpful,
truthful, and harmless outputs.
Step-5: Continuous Improvement
Later versions may add new data, refine alignment, or integrate external tools
(like web browsing or code execution).
GPT-3: Known / Estimated Training Data & Model Size
• It is reported that the dataset used involved ~45 terabytes of compressed text
data from the web, books, Wikipedia, etc.
• Token-count estimations: For GPT-3, ~300 billion tokens were used in
training.
• Model size: GPT-3 has ~175 billion parameters (weights and biases).
Department of Information Science and Engg
12
Transform Here
• The quality of results depends on how much information you provide in
the prompt and how well-crafted the prompt is.
• A prompt can contain information like the instruction or question you are
passing to the model and include other details such as context, inputs,
or examples. You can use these elements to instruct the model more
effectively to improve the quality of results.
• Here is a basic example of a simple prompt in OpenAI playground:
Prompt:The sky is
Output: blue
Department of Information Science and Engg
13
Transform Here
Department of Information Science and Engg
14
Transform Here
Department of Information Science and Engg
15
Transform Here
Department of Information Science and Engg
16
Transform Here
Prompt Formatting
• A standard prompt has the following format:
<Question>?
or
<Instruction>
• You can format a prompt into a question answering (QA) format,
which is standard in a lot of QA datasets, as follows:
• Q: <Question>?A:
• When prompting like the above, it's also referred to as zero-shot
prompting, i.e., you are directly prompting the model for a response
without any examples or demonstrations about the task you want it to
achieve.
Department of Information Science and Engg
17
Transform Here
• Some large language models have the ability to perform zero-shot
prompting but it depends on the complexity and knowledge of the task
at hand and the tasks the model was trained to perform good on.
• A concrete prompt example is as follows:
Prompt
Q: What is prompt engineering?
• With some of the more recent models you can skip the "Q:" part as it
is implied and understood by the model as a question answering task
based on how the sequence is composed. In other words, the prompt
could be simplified as follows:
Prompt
What is prompt engineering?
Department of Information Science and Engg
18
Transform Here
• Given the standard format above, one popular and effective technique
to prompting is referred to as few-shot prompting where you provide
exemplars (i.e., demonstrations). You can format few-shot prompts as
follows:
<Question>?<Answer>
<Question>?<Answer>
<Question>?<Answer>
<Question>?
• The QA format version would look like this:
Q: <Question>?A: <Answer>
Q: <Question>?A: <Answer>
Q: <Question>?A: <Answer>
Q: <Question>?A:
• Keep in mind that it's not required to use the QA format. The prompt
format depends on the task at hand.
Department of Information Science and Engg
19
Transform Here
Example for few-shot prompting
Prompt:
This is awesome! // Positive
This is bad! // Negative
Wow that movie was rad! // Positive
What a horrible show! //
Output:
Negative
• Few-shot prompts enable in-context learning, which is the ability of
language models to learn tasks given a few demonstrations.
Department of Information Science and Engg
20
Transform Here
Prompt Elements
Department of Information Science and Engg
21
Transform Here
A prompt contains any of the following elements:
Instruction - a specific task or instruction you want the model to perform
Context - external information or additional context that can steer the model
to better responses
Input Data - the input or question that we are interested to find a response
for
Output Indicator - the type or format of the output.
Prompt
Classify the text into neutral, negative, or positive Instruction
Text: I think the food was okay. Input Data
Sentiment: Output Indicator
Department of Information Science and Engg
22
Transform Here
General Tips for Designing Prompts
1. Start Simple
• As you get started with designing prompts, you should keep in mind that it is
really an iterative process that requires a lot of experimentation to get
optimal results. Using a simple playground from OpenAI or Cohere is a
good starting point.
• You can start with simple prompts and keep adding more elements and
context as you aim for better results.
• When you have a big task that involves many different subtasks, you can try
to break down the task into simpler subtasks and keep building up as you get
better results. This avoids adding too much complexity to the prompt design
process at the beginning.
Department of Information Science and Engg
23
Transform Here
2. The Instruction
• You can design effective prompts for various simple tasks by using
commands to instruct the model what you want to achieve, such as
"Write", "Classify", "Summarize", "Translate", "Order", etc.
• Others recommend that you place instructions at the beginning of the
prompt. Another recommendation is to use some clear separator like "###"
to separate the instruction and context.
Prompt:
### Instruction ###
Translate the text below to Spanish:
Text: "hello!“
Output:
¡Hola!
Department of Information Science and Engg
Transform Here
3. Specificity
• Be very specific about the instruction and task you want the model to perform.
This is particularly important when you have a desired outcome or style of
generation you are seeking.
• There aren't specific tokens or keywords that lead to better results. It's more
important to have a good format and descriptive prompt. In fact, providing
examples in the prompt is very effective to get desired output in specific
formats.
• When designing prompts, you should also keep in mind the length of the
prompt as there are limitations regarding how long the prompt can be.
• Including too many unnecessary details is not necessarily a good approach. The
details should be relevant and contribute to the task at hand.
• This is something you will need to experiment with a lot. A lot of
experimentation and iteration have to be done to optimize prompts for your
applications.
Department of Information Science and Engg
25
Transform Here
Prompt:
Extract the name of places in the following text.
Desired format:
Place: <comma_separated_list_of_places>
Input: "Although these developments are encouraging to researchers, much is
still a mystery. “We often have a black box between the brain and the effect we
see in the periphery,” says Henrique Veiga-Fernandes, a neuroimmunologist at
the Champalimaud Centre for the Unknown in Lisbon. “If we want to use it in the
therapeutic context, we actually need to understand the mechanism.“"
Output:
Place: Champalimaud Centre for the Unknown, Lisbon
Department of Information Science and Engg
26
Transform Here
4. Avoid Impreciseness
• It's easy to fall into the trap of wanting to be too clever about prompts and
potentially creating imprecise descriptions. It's often better to be specific and
direct. The analogy here is very similar to effective communication -- the
more direct, the more effective the message gets across.
• For example, you might be interested in learning the concept of prompt
engineering. You might try something like:
Explain the concept prompt engineering. Keep the explanation short, only a few
sentences, and don't be too descriptive.
• It's not clear from the prompt above how many sentences to use and what
style. You might still somewhat get good responses with the above prompts
but the better prompt would be one that is very specific, concise, and to the
point. Something like:
Use 2-3 sentences to explain the concept of prompt engineering to a high school
student.
Department of Information Science and Engg
27
Transform Here
5. To do or not to do?
• When designing prompts, avoid saying what not to do but say what to do
instead. This encourages more specificity and focuses on the details that lead to
good responses from the model.
• Here is an example of a movie recommendation chatbot focusing on what not
to do. Hence, the output will not be accurate.
Prompt:
The following is an agent that recommends movies to a customer.
DO NOT ASK FOR INTERESTS. DO NOT ASK FOR PERSONAL
INFORMATION.
Customer: Please recommend a movie based on my interests.
Agent:
Output:
Sure, I can recommend a movie based on your interests. What kind of movie
would you like to watch? Do you prefer action, comedy, romance, or something
else?
Department of Information Science and Engg
28
Transform Here
Here is a better prompt:
Prompt:
The following is an agent that recommends movies to a customer. The agent is
responsible to recommend a movie from the top global trending movies. It should
refrain from asking users for their preferences and avoid asking for personal
information. If the agent doesn't have a movie to recommend, it should respond
"Sorry, couldn't find a movie to recommend today.".
Customer: Please recommend a movie based on my interests.
Agent:
Output:
Sorry, I don't have any information about your interests. However, here's a list of
the top global trending movies right now: [list of movies].
I hope you find something you like!
Department of Information Science and Engg
29
Transform Here
Examples of prompts
1. Text Summarization
2. Information Extraction
3. Question Answering
4. Text Classification
5. Conversation
6. Code Generation
7. Reasoning
Department of Information Science and Engg
30
Transform Here
1. Text Summarization
• One of the most promising applications of language models is the ability
to summarize articles and concepts into quick and easy-to-read
summaries.
Prompt:
Explain antibiotics
A:
Output:
Antibiotics are a type of medication used to treat bacterial infections. They
work by either killing the bacteria or preventing them from reproducing,
allowing the body’s immune system to fight off the infection. Antibiotics
are usually taken orally in the form of pills, capsules, or liquid solutions, or
sometimes administered intravenously. They are not effective against viral
infections, and using them inappropriately can lead to antibiotic resistance.
• The "A:" is an explicit prompt format that you use in question answering.
You used it here to tell the model that there is an answer expected further.
Department of Information Science and Engg
31
Transform Here
2. Information Extraction
• While language models are trained to perform natural language generation
and related tasks, it's also very capable of performing classification and a
range of other natural language processing (NLP) tasks.
Prompt:
Author-contribution statements and acknowledgements in research papers
should state clearly and specifically whether, and to what extent, the authors
used AI technologies such as ChatGPT in the preparation of their manuscript
and analysis. They should also indicate which LLMs were used. This will
alert editors and reviewers to scrutinize manuscripts more carefully for
potential biases, inaccuracies and improper source crediting. Likewise,
scientific journals should be transparent about their use of LLMs, for
example when selecting submitted manuscripts. Mention the large language
model-based product mentioned in the paragraph above:
Output:
The large language model-based product mentioned in the paragraph above is
ChatGPT.
Department of Information Science and Engg
32
Transform Here
3. Question Answering
• One of the best ways to get the model to respond with specific answers is to
improve the format of the prompt.
• A prompt could combine instructions, context, input, and output indicators to get
improved results.
Prompt:
Answer the question based on the context below. Keep the answer short and
concise. Respond "Unsure about answer" if not sure about the answer.
Context: Teplizumab traces its roots to a New Jersey drug company called Ortho
Pharmaceutical. There, scientists generated an early version of the antibody,
dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the
surface of T cells and limit their cell-killing potential. In 1986, it was approved to
help prevent organ rejection after kidney transplants, making it the first
therapeutic antibody allowed for human use.
Question: What was OKT3 originally sourced from?
Answer:
Output:
Mice.
Department of Information Science and Engg
33
Transform Here
4. Text Classification
• Text classification is such a task where you need to think more about
the context and the different elements you can use in a prompt.
Prompt:
Classify the text into neutral, negative or positive.
Text: I think the food was okay.
Sentiment:
Output:
Neutral
• Instead of Neutral, you want it to return neutral. You care about
specificity here, so the more information you can provide the prompt,
the better results. You can try providing examples to specify the
correct behavior.
Department of Information Science and Engg
34
Transform Here
Prompt:
Classify the text into neutral, negative or positive.
Text: I think the vacation is okay.
Sentiment: neutral
Text: I think the food was okay.
Sentiment:
Output:
neutral
Department of Information Science and Engg
35
Transform Here
Prompt:
Classify the text into nutral, negative or positive.
Text: I think the vacation is okay.
Sentiment:
Output:
Neutral
• Though there is a mistake in the instruction, the model returns
‘Neutral’ because of its bias towards that label. If you still want the
model to return ‘nutral’, you need to give examples in the prompt.
Department of Information Science and Engg
36
Transform Here
5. Conversation
• Instructing an LLM using prompt engineering is particularly useful
when you are building conversational systems like customer service
chatbots.
• Let's create a conversational system that's able to generate more
technical and scientific responses to questions. Note how you are
explicitly telling it how to behave through the instruction. This is
sometimes referred to as role prompting.
• In the prompt shown in the example (next slide), if I say the answer
should be simple enough for school kids understanding levels, the
output would be different.
Department of Information Science and Engg
37
Transform Here
Prompt:
The following is a conversation with an AI research assistant. The
assistant tone is technical and scientific.
Human: Hello, who are you?
AI: Greeting! I am an AI research assistant. How can I help you today?
Human: Can you tell me about the creation of blackholes?
AI:
Output:
Sure! Black holes are regions of spacetime where the gravitational force
is so strong that nothing, not even light, can escape from it. They are
created when a very massive star dies and its core collapses in on itself,
forming a singularity of infinite density. The intense gravity of the
singularity pulls in all the matter and radiation around it, creating the
black hole.
Department of Information Science and Engg
38
Transform Here
6. Code Generation
• Copilot is a great example of code generating AI model. There are a
vast number of code-generation tasks you can perform with clever
prompts.
Prompt:
/*Ask the user for their name and say "Hello"*/
Output:
let name = prompt("What is your name?");[Link](`Hello,
${name}!`);
• Notice that you didn't even need to specify the language to use.
Department of Information Science and Engg
39
Transform Here
Prompt:
“““Table departments, columns = [DepartmentId,
DepartmentName]Table students, columns = [DepartmentId, StudentId,
StudentName] Create a MySQL query for all students in the Computer
Science Department”””
Output:
SELECT StudentId, StudentName FROM students WHERE
DepartmentId IN (SELECT DepartmentId FROM departments
WHERE DepartmentName = 'Computer Science’);
• In this case, you provided data about the database schema and asked it
to generate a valid MySQL query.
Department of Information Science and Engg
40
Transform Here
7. Reasoning
• Reasoning is one of most interesting areas due to the types of complex
applications that can emerge from LLMs.
• Current LLMs struggle to perform reasoning tasks. So, this requires
even more advanced prompt engineering techniques.
• Here are a few basic examples to show arithmetic capabilities.
Prompt:
What is 9,000 * 9,000?
Output:
81,000,000
Department of Information Science and Engg
41
Transform Here
Prompt:
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82,
7, 1.
A:
Output
No, the odd numbers in this group add up to an odd number: 119.
That's incorrect! Let's try to improve this by improving the prompt.
Prompt:
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82,
7, 1. Solve by breaking the problem into steps. First, identify the odd
numbers, add them, and indicate whether the result is odd or even.
Output:
Odd numbers: 15, 5, 13, 7, 1 Sum: 41 41 is an odd number.
• For this task, the model may fail a couple of times. If you provide better
instructions combined with examples, it might help to get more accurate
results.
Department of Information Science and Engg
42
Transform Here
Chapter 2
Prompting Techniques
1. Zero-shot Prompting
2. Few-shot Prompting
3. Chain-of-thought Prompting
4. Meta Prompting
Department of Information Science and Engg
Transform Here
Prompting Techniques
• Prompt Engineering helps to effectively design and improve prompts to get
better results on different tasks with LLMs.
In this section, we cover more advanced prompt engineering techniques that
allow us to achieve more complex tasks and improve reliability and
performance of LLMs.
1. Zero-Shot Prompting
• Large language models (LLMs) today, such as GPT-3.5 Turbo, GPT-4, and
Claude 3, are tuned to follow instructions and are trained on large amounts of
data.
• Large-scale training makes these models capable of performing some tasks in
a "zero-shot" manner.
• Zero-shot prompting means that the prompt used to interact with the model
won't contain examples or demonstrations. The zero-shot prompt directly
instructs the model to perform a task without any additional examples to steer
it.
Here is one of the examples (i.e., text classification) we used:
Department of Information Science and Engg
44
Transform Here
Prompt:
Classify the text into neutral, negative or positive.
Text: I think the vacation is okay.
Sentiment:
Output:
Neutral
Note that in the prompt above we didn't provide the model with any examples of text
alongside their classifications, the LLM already understands "sentiment" -- that's the
zero-shot capabilities at work.
• Instruction tuning has been shown to improve zero-shot learning - Wei et al. (2022).
Instruction tuning is essentially the concept of finetuning models on datasets described
via instructions.
• Furthermore, RLHF (reinforcement learning from human feedback) has been adopted to
scale instruction tuning wherein the model is aligned to better fit human preferences. This
recent development powers models like ChatGPT.
When zero-shot doesn't work, it's recommended to provide demonstrations or examples in
the prompt which leads to few-shot prompting.
Department of Information Science and Engg
45
Transform Here
Zero-Prompt Technique - Examples
Example 1: Summarization without asking for a summary
Input to model:
“Artificial Intelligence is transforming industries by automating routine tasks,
enhancing decision-making, and enabling new capabilities like predictive
analytics and natural language processing.”
Model Output (zero-prompted):
“A short explanation of how AI is reshaping industries.”
The model decides on its own to summarize because the user gave only
content.
Example 2: Sentiment inference without asking for sentiment
Input:
“I waited for the service engineer for three hours, and no one showed up.”
Model Output:
“The writer is expressing frustration about poor service.”
The model infers the task: sentiment/meaning extraction.
Department of Information Science and Engg
46
Transform Here
Example 3: Classification without asking to classify
Input:
“BMW, Audi, Mercedes, Toyota, Honda, Ford”
Model Output:
“A list of car manufacturers.”
The model recognizes the category automatically.
Department of Information Science and Engg
47
Transform Here
2. Few-Shot Prompting
• While large-language models demonstrate remarkable zero-shot capabilities,
they still fall short on more complex tasks when using the zero-shot setting.
• Few-shot prompting can be used as a technique to enable in-context
learning where we provide demonstrations in the prompt to steer the model
to better performance.
• The demonstrations serve as conditioning for subsequent examples where
we would like the model to generate a response.
• According to Touvron et al. 2023, few shot properties first appeared when
models were scaled to a sufficient size (Kaplan et al., 2020).
• Let's demonstrate few-shot prompting via an example that was presented in
a research work by Brown et al. 2020. In the example, the task is to correctly
use a new word in a sentence.
Department of Information Science and Engg
48
Transform Here
What is 1-Shot Prompting?
You give one example of what you want, and the model uses that example to
follow the pattern.
Example 2: Email Rewriting
Example 1: Text Classification
User Prompt:
User Prompt:
Example:
Example:
Input: “Send the report.”
Input: “The movie was fantastic and thrilling.”
Output: “Could you please send the report
Output: “Positive”
when you get a chance?”
Now classify:
Now rewrite:
Input: “The food was cold and tasteless.”
Input: “Prepare the slides.”
Expected Model Output:
Expected Output:
“Negative”
“Could you please prepare the slides when
you get a chance?”
Department of Information Science and Engg
49
Transform Here
Example 3: Summarization Pattern
User Prompt:
Example Summary:
Text: “AI improves productivity by automating tasks and reducing human error.”
Summary: “AI boosts productivity.”
Now summarize:
Text: “Cloud computing lowers infrastructure costs and improves scalability.”
Expected Output:
“Cloud reduces cost and improves scalability.”
Example 4: Converting Style
User Prompt:
Example:
Input: “I’m unable to attend the meeting today.”
Output: “I regret to inform you that I will not be able to attend the meeting today.”
Now convert:
Input: “I can’t take this class tomorrow.”
Expected Output:
“I regret to inform you that I will not be able to take this class tomorrow.”
Department of Information Science and Engg
50
Transform Here
Prompt:
A "whatpu" is a small, furry animal native to Tanzania. An example of a sentence
that uses the word whatpu is:
We were traveling in Africa and we saw these very cute whatpus.
To do a "farduddle" means to jump up and down really fast. An example of a
sentence that uses the word farduddle is:
Output:
When we won the game, we all started to farduddle in celebration.
We can observe that the model has somehow learned how to perform the task by
providing it with just one example (i.e., 1-shot). For more difficult tasks, we can
experiment with increasing the demonstrations (e.g., 3-shot, 5-shot, 10-shot, etc.).
“Show 2–5 examples → then ask the model to continue in the same style.”
The demonstrations serve as conditioning for subsequent examples where we
would like the model to generate a response.
Simple Definition
Few-shot prompting = Providing a few examples + a new query.
The model uses the examples as guidance to generate the correct output.
Department of Information Science and Engg
51
Transform Here
Following the findings from Min et al. (2022), here are a few more tips about
demonstrations when doing few-shot:
1. The label space and the distribution of the input text specified by the
demonstrations are both important (regardless of whether the labels are
correct for individual inputs)“
[Link] format you use also plays a key role in performance, even if you just use
random labels, this is much better than no labels at all.
3. Additional results show that selecting random labels from a true distribution
of labels (instead of a uniform distribution) also helps.
• Let's try out a few examples. Let's first try an example with random labels
(meaning the labels Negative and Positive are randomly assigned to the
inputs):
Department of Information Science and Engg
52
Transform Here
Prompt:
This is awesome! // Negative
This is bad! // Positive
Wow that movie was rad! // Positive
What a horrible show! //
Output:
Negative
We still get the correct answer, even though the labels have been randomized. Note that
we also kept the format, which helps too. In fact, with further experimentation, it seems
the newer GPT models we are experimenting with are becoming more robust to even
random formats. Example:
Department of Information Science and Engg
53
Transform Here
Prompt:
Positive This is awesome!
This is bad! Negative
Wow that movie was rad!
Positive
What a horrible show! --
Output:
Negative
There is no consistency in the format above, but the model still predicted the
correct label. We have to conduct a more thorough analysis to confirm if this
holds for different and more complex tasks, including different variations of
prompts.
Department of Information Science and Engg
54
Transform Here
Example (few-shot email rewriting)
Example 1:
Input: “Send the file.”
Output: “Could you please send the file?”
Example 2:
Input: “Share the details.”
Output: “Could you please share the
details?”
Now your turn:
Input: “Check the report.”
Expected Output:
“Could you please check the report?”
When to use it?
•When the model struggles with zero/one-shot accuracy
•When you need consistent style
•When the task is complex or domain-specific
Department of Information Science and Engg
55
Transform Here
Example (few-shot email rewriting)
Example given 1:
Input: “Send the file.”
Output: “Could you please send the file?”
Example given 2:
Input: “Share the details.”
Output: “Could you please share the
details?”
Now your turn:
Input: “Check the report.”
Expected Output:
“Could you please check the report?”
When to use it?
•When the model struggles with zero/one-shot accuracy
•When you need consistent style
•When the task is complex or domain-specific
Department of Information Science and Engg
56
Transform Here
Limitations of Few-shot Prompting
• Standard few-shot prompting works well for many tasks but is still not a perfect
technique, especially when dealing with more complex reasoning tasks.
Let's demonstrate why this is the case.
Prompt:
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:
• If we try this again, the model outputs the following:
Yes, the odd numbers in this group add up to 107, which is an even number.
This is not the correct response, which not only highlights the limitations of these
systems but that there is a need for more advanced prompt engineering.
Department of Information Science and Engg
57
Transform Here
• That didn't work. It seems like few-shot prompting is not enough to get
reliable responses for this type of reasoning problem.
• The example above provides basic information on the task. If you take a
closer look, the type of task we have introduced involves a few more
reasoning steps.
• In other words, it might help if we break the problem down into steps and
demonstrate that to the model.
• More recently, chain-of-thought (CoT) prompting has been popularized to
address more complex arithmetic, commonsense, and symbolic reasoning
tasks.
• Overall, it seems that providing examples is useful for solving some tasks.
When zero-shot prompting and few-shot prompting are not sufficient, it might
mean that whatever was learned by the model isn't enough to do well at the
task.
• From here it is recommended to start thinking about fine-tuning your models
or experimenting with more advanced prompting techniques.
Department of Information Science and Engg
58
Transform Here
3. Chain-of-Thought Prompting
• Chain-of-thought prompting encourages the model to show step-by-step
reasoning instead of jumping directly to the final answer.
• This helps the model produce more accurate, logical, and explainable results
— especially for math, logic, coding, and multi-step problems.
Department of Information Science and Engg
59
Transform Here
Simple Definition
Chain of Thought = Thinking step-by-step before giving the final answer.
You prompt the model to reason through the steps like a teacher showing work.
Prompt:
The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.
A: Adding all the odd numbers (9, 15, 1) gives 25. The answer is False.
The odd numbers in this group add up to an even number: 17, 10, 19, 4, 8, 12, 24.
A: Adding all the odd numbers (17, 19) gives 36. The answer is True.
The odd numbers in this group add up to an even number: 16, 11, 14, 4, 8, 13, 24.
A: Adding all the odd numbers (11, 13) gives 24. The answer is True.
The odd numbers in this group add up to an even number: 17, 9, 10, 12, 13, 4, 2.
A: Adding all the odd numbers (17, 9, 13) gives 39. The answer is False.
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:
Output:
Adding all the odd numbers (15, 5, 13, 7, 1) gives 41. The answer is False.
Department of Information Science and Engg
60
Transform Here
Example
Problem:
A shop sells 3 pens for ₹30.
How much do 12 pens cost?
Chain-of-Thought Answer:
3 pens cost ₹30 Another Example (Logic)
So 1 pen costs ₹30 ÷ 3 = ₹10 Question:
Therefore, 12 pens cost 12 × ₹10 = ₹120 If all roses are flowers and some flowers fade
Final Answer: ₹120 quickly, can we conclude that some roses may
fade quickly?
Chain-of-Thought:
•All roses are part of the flower group.
Why Chain-of-Thought Helps •Some flowers fade quickly.
•Breaks complex problems into simple steps •Since roses are flowers, it's possible that some
•Reduces mistakes roses are in the group that fades quickly.
•Improves reasoning quality Conclusion: Yes, it is possible.
•Makes answers explainable (useful for students)
Department of Information Science and Engg
61
Transform Here
Zero-shot COT Prompting
Department of Information Science and Engg
62
Transform Here
• Automatic Chain-of-Thought (Auto-CoT) is an improved prompting
technique that automatically generates step-by-step reasoning examples for a
task without requiring the user to manually prepare examples.
• It solves the problem of few-shot prompting where the teacher (or user) must
create many chain-of-thought examples by hand.
• Auto-CoT = The model itself generates reasoning examples → then uses
those examples to solve new problems.
How Auto-CoT Works?
• Collect a few sample questions
(The system selects these automatically.)
• The model generates step-by-step reasoning for each sample
(No human-written examples needed.)
• These AI-generated examples become the “few-shot prompt.”
• The model then answers the final question using these examples.
• So the system builds its own few-shot CoT prompt.
Department of Information Science and Engg
63
Transform Here
Tiny Example of the working og Auto-CoT:
Step 1: System picks sample problems
•Q1: “If a train travels 60 km in 1.5 hours, what is its speed?”
•Q2: “What is 15% of 200?”
Step 2: AI creates its own CoT reasoning
Example 1:
•Distance = 60 km, Time = 1.5 hrs
•Speed = Distance / Time = 60 / 1.5 = 40 km/hr
Example 2:
•15% = 15/100
•15/100 × 200 = 30
Step 3: Use these examples to answer the real question
Final Question:
“How many kilometers will a vehicle travel in 5 hours at 50 km/hr?”
Auto-CoT reasoning:
•Speed = 50 km/hr
•Time = 5 hours
•Distance = Speed × Time = 50 × 5 = 250 km
Final Answer: 250 km
Department of Information Science and Engg
64
Transform Here
Why Auto-CoT is Useful?
1. Removes the burden of manually creating examples
2. Produces more consistent reasoning
3. Works well for reasoning-intensive tasks
4. Improves accuracy on math, logic, and multi-step tasks
5. Helps educators by auto-generating CoT demonstrations
Department of Information Science and Engg
65
Transform Here
Meta Prompting
• Meta Prompting is a prompting technique where you give the model
instructions about how it should think, behave, or generate answers, rather
than giving it a specific task alone.
• You are essentially giving a prompt about how to create prompts or how to
process prompts — that’s why it’s called meta (thinking about thinking).
Simple Definition
• Meta Prompting = Giving the model high-level guidance about its role, style,
rules, or strategy before performing the actual task.
• Instead of telling the model what to do, you tell it how to do it.
Department of Information Science and Engg
66
Transform Here
• Example (Simple)
• Meta Prompt:
“You are an expert grammar tutor. When I give you a sentence, first explain the mistake
briefly and then provide the corrected version.”
• Task Input: “The boy are playing.”
• Model Output: “The verb does not agree with the subject.
Correct sentence: The boy is playing.”
• Here, the meta prompt sets the behavioural rules.
Example (Meta Prompt + Task Prompt)
Meta Prompt:
“Always think step-by-step before answering.”
Task Prompt: “What is 25 × 14?”
Output:
•25 × 14 = (25 × 10) + (25 × 4)
•= 250 + 100
•= 350
Answer: 350
The sentence “think step-by-step” is a meta instruction that changes how the model works.
Department of Information Science and Engg
67
Transform Here
• Example (Role-based Meta Prompt)
• Meta Prompt: “You are a cybersecurity auditor. Answer only with risks and
mitigation steps.”
• Task: “What are the issues with weak passwords in a university system?”
• Output:
• Risk 1: Easy to guess → Mitigation: Enforce strong password policy
• Risk 2: Reuse across systems → Mitigation: Multi-factor authentication
• The meta prompt defines role + constraints.
• Why Meta Prompting is Useful
• Sets guidelines for the model’s behavior
• Achieves consistent style and structure
• Reduces ambiguity
• Improves reasoning
• Helps in exam setting, teaching, design, creativity, etc.
Department of Information Science and Engg
68
Transform Here
Chapter 3
Overview of Generative AI Models
1. ChatGPT
2. Claude 3
3. Gemini
4. Grok-1,
5. LLaMA
6. Mistral 7B
7. Sora
Department of Information Science and Engg
69
Transform Here
Overview of Generative AI Models
What is Generative AI?
• Branch of AI designed to create new data
• Learns underlying patterns from training data, can generate:
– Text
– Images & Videos
– Audio & Music
– Code & Designs
• Example: ChatGPT, Midjourney, Gemini, DALL-E
Why Generative AI?
• Boosts creativity and productivity
• Automates routine content creation
• Enhances human capabilities
• Drives innovation in multiple industries
• Enables personalized digital experiences
Department of Information Science and Engg
70
Transform Here
Key Applications
• Conversational AI
• Art & graphic design
• Code generation
• Healthcare diagnostics
• Marketing & content automation
• Game development & digital twins
Challenges & Risks
• Bias & inaccurate content
• Copyright and ownership issues
• Privacy & data leakage
• Misuse: deepfakes, misinformation
• Need Responsible AI frameworks
Department of Information Science and Engg
71
Transform Here
Future Directions
•More efficient, smaller & powerful models
•Improved reasoning and memory
•Real-time multimodal intelligence
•Human-AI collaboration — not replacement
•Stronger ethics & governance
Summary
•Generative AI can create new data similar to human creativity
•Several model types:
– LLMs, GANs, VAEs, Diffusion, Multimodal
•Rapidly transforming industries
•Importance of ethical deployment
Department of Information Science and Engg
72
Transform Here
Comparison of Major Generative AI Models
Department of Information Science and Engg
73
Transform Here
Discriminative vs Generative Models
Feature Discriminative Generative
Goal Classify data Generate new data
Logistic Regression,
Examples GANs, VAEs, LLMs
SVM
Output Labels Creative content
Types of Generative AI Models
1⃣ Autoregressive Models (LLMs)
2⃣ GANs (Generative Adversarial Networks)
3⃣ VAEs (Variational Autoencoders)
4⃣ Diffusion Models
5⃣ Multimodal Models (text + images/audio)
6⃣ Hybrid Architectures
Department of Information Science and Engg
74
Transform Here
Autoregressive Models (LLMs)
• Predict the next token based on previous context
• Based on Transformer architecture
• Examples:
– GPT, LLaMA, PaLM
• Applications:
– Chatbots, coding, summarization, reasoning
Department of Information Science and Engg
75
Transform Here
GANs – Generative Adversarial Networks
GANs are a class of generative models introduced by Ian Goodfellow
(2014). They learn to create new data that resembles real-world data.
• Two neural-network setup:
– Generator: creates fake data
– Discriminator: detects fake vs real
• Improve via adversarial learning
• Applications: Photorealistic images, deepfakes, art
VAEs – Variational Autoencoders
• Encode data → learn compressed latent representation
• Decode to reconstruct data
• Good for controlled & diverse generation
• Applications: anomaly detection, design, healthcare modeling
Department of Information Science and Engg
76
Transform Here
Diffusion Models
•Learn to remove noise from corrupted data
•High-quality synthetic images/video
•Examples: Stable Diffusion, Imagen, DALL-E 3
•State-of-the-art for creativity & realism
Multimodal Generative Models
•Handle multiple inputs/output formats
(Text ⇄ Image ⇄ Audio ⇄ Video)
•Examples:
– GPT-4o, Gemini, Claude
•Enables real-world human-like interaction
Department of Information Science and Engg
77
Transform Here
Training Data & Scale
• Trained on large datasets (web-scale)
• Requires:
– High compute (GPUs/TPUs)
– Large memory & distributed training
• Pretraining + Fine-tuning for specialization
Department of Information Science and Engg
78
Transform Here
Key Applications
• Conversational AI
• Art & graphic design
• Code generation
• Healthcare diagnostics
• Marketing & content automation
• Game development & digital twins
Challenges & Risks
• Bias & inaccurate content
• Copyright and ownership issues
• Privacy & data leakage
• Misuse: deepfakes, misinformation
• Need Responsible AI frameworks
Department of Information Science and Engg
79
Transform Here
Future Directions
•More efficient, smaller & powerful models
•Improved reasoning and memory
•Real-time multimodal intelligence
•Human-AI collaboration — not replacement
•Stronger ethics & governance
Summary
•Generative AI can create new data similar to human creativity
•Several model types:
– LLMs, GANs, VAEs, Diffusion, Multimodal
•Rapidly transforming industries
•Importance of ethical deployment
Department of Information Science and Engg
80
Transform Here
Department of Information Science and Engg
81
Transform Here
Department of Information Science and Engg
82
Transform Here