1 of 88

UNIT - II

Generative Models For Text: Language Models Basics,

Building blocks of Language models,

Transformer Architecture,

Encoder and Decoder,

Attention mechanisms,

Generation of Text,

Models like BERT and GPT models,

Generation of Text,

Autoencoding,

Regression Models,

Exploring ChatGPT,

Prompt Engineering: Designing Prompts,

Revising Prompts using Reinforcement Learning from Human Feedback (RLHF),

Retrieval Augmented Generation,

Multimodal LLM,

Issues of LLM like hallucination.

Classified as Microsoft Confidential

2 of 88

LANGUAGE MODELS BASICS

  • A Language Model (LM) is an Artificial Intelligence (AI) model that learns the patterns, grammar, and relationships between words in a language to predict the next word or token in a sequence.
  • It enables computers to understand and generate human-like text.

Example:

  • Input: "Artificial Intelligence is..."
  • Output: "...transforming the world."

Classified as Microsoft Confidential

3 of 88

COMPONENTS OF A LANGUAGE MODEL

  1. Training Data
    1. Books
    2. Articles
    3. Websites
    4. Research papers
    5. Code repositories
  2. Tokenization

Breaks text into smaller units called tokens.

Example:

    • "Machine Learning is Powerful"
    • ["Machine", "Learning", "is", "Powerful"]

Classified as Microsoft Confidential

4 of 88

3.Vocabulary

    • Collection of all tokens known to the model.

4.Neural Network

    • Learns patterns from training data.
    • Modern language models mainly use the Transformer architecture.

5.Probability Prediction

    • Predicts the most probable next word/token.

Classified as Microsoft Confidential

5 of 88

�������TYPES OF LANGUAGE MODELS

  •  

Classified as Microsoft Confidential

6 of 88

TYPES OF STATISTICAL LANGUAGE MODELS

  1. Unigram
  2. Bigram
  3. Trigram (N-gram)

Classified as Microsoft Confidential

7 of 88

  •  

Classified as Microsoft Confidential

8 of 88

  •  

Classified as Microsoft Confidential

9 of 88

EXAMPLE:CALCULATING WORD PROBABILITY

Classified as Microsoft Confidential

10 of 88

  •  

Classified as Microsoft Confidential

11 of 88

EXAMPLE 2

  •  

Classified as Microsoft Confidential

12 of 88

  •  

Classified as Microsoft Confidential

13 of 88

�����EXAMPLE 1

  •  

Classified as Microsoft Confidential

14 of 88

  •  

Classified as Microsoft Confidential

15 of 88

EXAMPLE

  •  

Classified as Microsoft Confidential

16 of 88

2.Neural Language Models

A Neural Language Model (NLM) is a language model that uses Artificial Neural Networks (ANNs) to learn the probability distribution of words and predict the next word in a sentence. Unlike Statistical Language Models, Neural Language Models learn semantic meaning and context from data using word embeddings and neural networks.

  • Feedforward Neural Networks
  • Recurrent Neural Networks (RNN)
  • Long Short-Term Memory (LSTM)
  • Gated Recurrent Unit (GRU)

Classified as Microsoft Confidential

17 of 88

3.Transformer-Based Language Models

  • A Transformer-Based Language Model (TLM) is a deep learning model that uses the Transformer architecture and the Self-Attention mechanism to understand the relationships between words in a sentence. Unlike RNNs and LSTMs, Transformers process all words in parallel, making them faster and more effective at capturing long-range dependencies.
  • The Transformer architecture was introduced in the research paper "Attention Is All You Need" (2017).
  • GPT
  • BERT
  • T5
  • LLaMA
  • PaLM
  • Gemin

Classified as Microsoft Confidential

18 of 88

������APPLICATIONS

  • Chatbots
  • Machine Translation
  • Text Summarization
  • Question Answering
  • Email Generation
  • Story Writing
  • Code Generation
  • Content Creation
  • Speech Assistants
  • Search Engines

Classified as Microsoft Confidential

19 of 88

BUILDING BLOCKS OF LANGUAGE MODELS

  • Language models are the core component of Generative AI systems. learn patterns, grammar, context, and relationships from large amounts of text data to generate meaningful and coherent text.
  • The following are the fundamental building blocks of language models.

Classified as Microsoft Confidential

20 of 88

�������1 .TEXT CORPUS (TRAINING DATA)

  • A text corpus is a large collection of text used to train the language model.
  • It may include books, articles, websites, research papers, and conversations.
  • The quality and diversity of the corpus directly affect model performance.

Examples:

  • Wikipedia articles
  • News datasets
  • Common Crawl
  • Books and scientific papers

Classified as Microsoft Confidential

21 of 88

2. TOKENIZATION

Tokenization is the process of dividing text into smaller units called tokens.

Types of Tokens:

  • Word Tokens
  • Character Tokens
  • Subword Tokens (BPE, WordPiece)

Example:

Sentence:

Artificial Intelligence is powerful.

Tokens:

  • ["Artificial", "Intelligence", "is", "powerful", "."]

Classified as Microsoft Confidential

22 of 88

3. VOCABULARY

Vocabulary is the collection of all unique tokens known by the model.

Vocabulary

------------------

Artificial

Intelligence

Machine

Learning

Data

Science

AI

A larger vocabulary improves language understanding but increases computational cost.

Classified as Microsoft Confidential

23 of 88

4. WORD EMBEDDINGS

Embeddings convert words into numerical vectors that capture semantic meaning.

  • Example:

Word

Vector Representation

Cat

[0.12, 0.45, -0.31]

Dog

[0.15, 0.42, -0.29]

Car

[-0.72, 0.08, 0.91]

Classified as Microsoft Confidential

24 of 88

5. POSITIONAL ENCODING

Transformers process all words simultaneously, so they require positional information.

Example:

Sentence:

  • I love AI

Token

Position

I

1

Love

2

AI

3

Classified as Microsoft Confidential

25 of 88

6. NEURAL NETWORK ARCHITECTURE

Modern language models use Transformer architecture.

Main Components:

  • Input Embedding Layer
  • Multi-Head Self-Attention
  • Feed Forward Network
  • Layer Normalization
  • Residual Connections
  • Output Layer

Classified as Microsoft Confidential

26 of 88

7. ATTENTION MECHANISM

Attention allows the model to focus on the most relevant words while predicting the next token.

Example:

Sentence:

‘”The student submitted the assignment because he completed it”.

  • The model understands that "he" refers to "student".

Benefits:

  • Better context understanding
  • Improved translation and summarization
  • Handles long sentences effectively

Classified as Microsoft Confidential

27 of 88

8. CONTEXT WINDOW

The context window is the maximum number of previous tokens the model can consider.

Example:

  • Previous 2048 tokens

  • Current Prediction

Larger context windows improve:

  • Long document understanding
  • Multi-turn conversations
  • Code generation

Classified as Microsoft Confidential

28 of 88

9. PROBABILITY DISTRIBUTION

Language models predict the probability of the next token.

Example:

Input:

  • I love

Word

Probability

AI

0.55

Programming

0.20

Cricket

0.10

Music

0.08

Food

0.07

Classified as Microsoft Confidential

29 of 88

10. TRAINING PROCESS

The model learns by minimizing prediction errors using optimization algorithms.

Steps:

  • Collect text data.
  • Tokenize the data.
  • Convert tokens into embeddings.
  • Pass data through the Transformer.
  • Predict the next token.
  • Compute the loss.
  • Update model weights using backpropagation and gradient descent.
  • Repeat over many training iterations.

Classified as Microsoft Confidential

30 of 88

�����11. DECODING STRATEGIES

  • During text generation, different decoding methods are used.
  • Greedy Search : Selects the highest-probability token at each step.
  • Beam Search :Keeps multiple candidate sequences to improve overall quality.
  • Top-k Sampling : Samples from the top k most likely tokens.
  • Top-p (Nucleus) Sampling : Samples from the smallest set of tokens whose cumulative probability exceeds a threshold p.
  • Temperature Sampling :Adjusts randomness; lower values produce more deterministic text, higher values increase diversity.

Classified as Microsoft Confidential

31 of 88

���TRANSFORMER ARCHITECTURE

  • The Transformer architecture is the foundation of many modern Generative AI and Large Language Models (LLMs).
  • It was introduced in the paper “Attention Is All You Need” (2017) and is mainly based on the Self-Attention mechanism

Classified as Microsoft Confidential

32 of 88

Classified as Microsoft Confidential

33 of 88

���TRANSFORMERS WORK

1. Input Representation

The first step in processing input data involves converting raw text into a format that the transformer model can understand. This involves tokenization and embedding.

  1. Tokenization: The input text is split into smaller units called tokens, which can be words, sub words or characters. Tokenization ensures that the text is broken down into manageable pieces.
  2. Embedding: Each token is then converted into a fixed-size vector using an embedding layer. This layer maps each token to a dense vector representation that captures its semantic meaning.
  3. Positional encodings: are added to these embeddings to provide information about the token positions within the sequence.

Classified as Microsoft Confidential

34 of 88

2. ENCODER PROCESS IN TRANSFORMERS

  1. Input Embedding: The input sequence is tokenized and converted into embeddings with positional encodings added.
  2. Self-Attention Mechanism: Each token in the input sequence attends to every other token to capture dependencies and contextual information.

Query, Key and Value

  • Self-attention uses three vectors:
  • Query (Q) – What am I looking for?
  • Key (K) – What information do I contain?
  • Value (V) – What information should I provide?

The attention calculation is:

Where:

  • Q = Query
  • K = Key
  • V = Value
  • dk​ = dimension of Key

Classified as Microsoft Confidential

35 of 88

3.Feed-Forward Network: The output from the self-attention mechanism is passed through a position-wise feed-forward network.

4.Layer Normalization and Residual Connections: Layer normalization and residual connections are applied.

Classified as Microsoft Confidential

36 of 88

Multi-Head Attention Mechanism

Classified as Microsoft Confidential

37 of 88

��3. DECODER PROCESS

  1. Input Embedding and Positional Encoding: The partially generated output sequence is tokenized and embedded with positional encodings added.
  2. Masked Self-Attention Mechanism: The decoder uses masked self-attention to prevent attending to future tokens ensuring that the model generates the sequence step-by-step.

Example;

Sentence :

I love AI today

  • I ✓ ✗ ✗ ✗
  • love ✓ ✓ ✗ ✗
  • AI ✓ ✓ ✓ ✗
  • today ✓ ✓ ✓ ✓

Classified as Microsoft Confidential

38 of 88

3.Encoder-Decoder Attention Mechanism: The decoder attends to the encoder's output allowing it to focus on relevant parts of the input sequence.

4.Feed-Forward Network: Similar to the encoder the output from the attention mechanisms is passed through a position-wise feed-forward network.

5.Layer Normalization and Residual Connections: Similar to the encoder Layer normalization and residual connections are applied.

Classified as Microsoft Confidential

39 of 88

Classified as Microsoft Confidential

40 of 88

4. TRAINING AND INFERENCE

  • Transformers are trained with teacher forcing, where the correct previous tokens are provided during training to predict the next token.
  • Their encoder-decoder architecture combined with multi-head attention and feed-forward networks enables highly effective handling of sequential data.
  • Transformers have transformed deep learning by using self-attention mechanisms to efficiently process and generate sequences capturing long-range dependencies and contextual relationships.
  • Their encoder-decoder architecture combined with multi-head attention and feed-forward networks enables highly effective handling of sequential data.

Classified as Microsoft Confidential

41 of 88

ENCODER AND DECODER

  • The encoder-decoder model is a neural network used for tasks where both input and output are sequences, often of different lengths. It is commonly applied in areas like translation, summarization and speech processing.
  • The encoder processes the input sequence and converts it into a fixed representation (context vector)
  • The decoder uses this representation to generate the output sequence step by step
  • Works well for tasks where input and output lengths are different

Example:

Input → Encoder → Latent Representation → Decoder → Output

English:�I love AI

Encoder

Context representation

Decoder

Telugu:�నేను AIని ప్రేమిస్తున్నాను

Classified as Microsoft Confidential

42 of 88

Classified as Microsoft Confidential

43 of 88

WORKING ENCODER AND DECODER

Classified as Microsoft Confidential

44 of 88

Step 1: Tokenizing the Input Sentence

  • The sentence "I am learning AI" is first broken into tokens: ["I", "am", "learning", "AI"].
  • Each word (token) is converted into a vector that a machine can understand.
  • This process is called embedding.

Step 2: Encoding the Input

  • The encoder processes these embeddings sequentially using an LSTM network.
  • At each step, it updates its hidden state based on the current word and previous context.
  • This helps the model understand the sequence order and relationships between words.
  • After processing the full sentence, the encoder generates a context vector (final hidden and cell states), which represents the meaning of the entire input sentence.

Classified as Microsoft Confidential

45 of 88

Step 3: Passing the Context to the Decoder

  • The Context Vector is passed to the Decoder as shown in image.
  • It acts like a summary of the full input sentence.

Step 4: Decoder Generates Output Step-by-Step

  • The Decoder uses the context and starts creating the output one word at a time.
  • First it predicts the first word then uses that to predict the second word and so on.

Classified as Microsoft Confidential

46 of 88

Step 5: Attention Mechanism

  • Basic encoder-decoder uses a single context vector, which can limit performance for long sequences.
  • Attention mechanism helps the decoder focus on different parts of the input at each step.
  • Improves accuracy by not relying only on one fixed representation.

Step 6: Producing the Final Output

  • The decoder continues generating until the full translated sentence is produced.
  • Each output token depends on the previous ones and the input context.
  • You finally see the output tokens generated on the right side of the diagram completing the translation.

Classified as Microsoft Confidential

47 of 88

ATTENTION MECHANISM

  • Attention Mechanism is a technique used in Generative AI and Transformer models to help the model focus on the most important parts of the input when generating an output.
  • Instead of treating all words equally, attention assigns different importance (weights) to different words.

Example

  • "The student went to the library because he wanted to read."
  • To understand "he", the model should pay more attention to "student".

Classified as Microsoft Confidential

48 of 88

QUERY, KEY AND VALUE

  • Query: Represents the current element being processed.
  • Key: Represents the other elements in the sequence.
  • Value: Represents the actual information that is carried by each element.
  • The model calculates the similarity between Query and Key and applies SoftMax to obtain attention weights.
  • These weights are multiplied with the Value vectors to produce the final attention output.

Classified as Microsoft Confidential

49 of 88

Classified as Microsoft Confidential

50 of 88

SELF-ATTENTION: 

  • Self-attention allows each word/token to look at other words in the same sequence.

Classified as Microsoft Confidential

51 of 88

MULTI-HEAD ATTENTION: 

Multi-Head Attention performs attention using multiple attention heads.

Different heads can learn different relationships, such as:

  • Word relationships
  • Grammar
  • Semantic meaning
  • Long-range dependencies

Classified as Microsoft Confidential

52 of 88

EXAMPLE

Attention Head

What it may learn

Head 1

“he” → “student” (who does he refer to?)

Head 2

“completed” → “assignment” (what was completed?)

Head 3

“submitted” → “assignment” (what was submitted?)

Consider the sentence:

“The student submitted the assignment because he completed it.”

Suppose a Transformer uses 3 attention heads.

Each head focuses on different relationships between the words.

Classified as Microsoft Confidential

53 of 88

���GENERATION OF TEXT

  • Text generation in Generative AI is the process of automatically creating human-like text from a given prompt or input. Modern systems such as GPT use Transformer-based language models to predict the next token based on the previous context.

Basic Process

  • The text generation process can be represented as:

Input Prompt → Tokenization → Embedding → Transformer → Next-Token Prediction → Token Selection → Generated Text

Classified as Microsoft Confidential

54 of 88

STEPS IN TEXT GENERATION

Step 1: Prompt/Input�The user provides text such as:

“Explain Machine Learning.”

Step 2: Tokenization�The input is divided into tokens.

Step 3: Embedding�Tokens are converted into numerical vectors that the model can process.

Step 4: Transformer Processing�The Transformer analyzes the context using Multi-Head Self-Attention and Feed-Forward Networks.

Step 5: Next-Token Prediction�The model calculates probabilities for possible next tokens.

Classified as Microsoft Confidential

55 of 88

Step 6: Token Selection�A token is selected using techniques such as greedy decoding, temperature sampling, Top-k, or Top-p sampling.

Step 7: Repetition�The selected token is added to the sequence, and the model predicts the next token.

Step 8: Stopping�Generation stops when an end token is produced or the maximum generation length is reached.

Classified as Microsoft Confidential

56 of 88

���DIFFERENT APPROACHES TO TEXT GENERATION

  1. Autoregressive models: These models, such as GPT-4, generate text by predicting one word at a time based on the sequence of words that came before it. This approach ensures that the generated text follows a logical and coherent flow, much like how humans write by thinking about the next word based on previous context.
  2. Seq2Seq models: These models are commonly used in tasks like machine translation, where an input sequence (such as a sentence in one language) is transformed into an output sequence (the translated sentence in another language). This method is effective for applications where structured input must be mapped to structured output, ensuring meaningful conversions.
  3. Fine-tuned models: Pre-trained AI models can be further customized using specific datasets to specialize in particular domains, such as generating medical reports, legal documents, or financial summaries. By fine-tuning these models with domain-specific data, they can generate more accurate and contextually relevant outputs tailored to specialized fields.

Classified as Microsoft Confidential

57 of 88

Some of the most powerful models for text generation include:

  • GPT (Generative Pre-trained Transformer) by OpenAI
  • PaLM 2 (Pathways Language Model 2) by Google
  • Claude by Anthropic
  • LLaMA (Large Language Model Meta AI) by Meta AI

Classified as Microsoft Confidential

58 of 88

MODELS LIKE BERT AND GPT MODELS,

  • BERT and GPT are two important Transformer-based language model families, but they are designed for different purposes.
  • BERT → Mainly designed for understanding text
  • GPT → Mainly designed for generating text
  • Both use the Transformer architecture, but their architectures and training objectives are different.

Classified as Microsoft Confidential

59 of 88

Classified as Microsoft Confidential

60 of 88

1. BERT (BIDIRECTIONAL ENCODER REPRESENTATIONS FROM TRANSFORMERS)

BERT (Bidirectional Encoder Representations from Transformers) is an encoder-only Transformer model developed by Google.

  • Uses the Transformer Encoder.
  • Understands context from both the left and right sides of a token.
  • Uses bidirectional self-attention.
  • Mainly designed for language understanding, rather than open-ended text generation.
  • Pre-trained using objectives such as Masked Language Modeling (MLM).

Classified as Microsoft Confidential

61 of 88

2. GPT MODELS

GPT (Generative Pre-trained Transformer) models are primarily decoder-only Transformer models designed for text generation.

  • Uses the Transformer Decoder architecture.
  • Uses causal/masked self-attention.
  • Predicts the next token based on previous tokens.
  • Can generate text sequentially.
  • Modern GPT-style models can perform many tasks from prompts, including writing, summarization, reasoning, and code generation.

Classified as Microsoft Confidential

62 of 88

DIFFERENCE BETWEEN BERT AND GPT

Feature

BERT

GPT

Architecture Type

Encoder only Transformer

Decoder only Transformer

Attention Type

Multi head Attention

Masked Multi head Attention

Context Handling

Considers both left and right context simultaneously

Considers only left context

Primary Purpose

Understanding and extracting meaning from text

Generating coherent and context relevant text

Training Objective

Masked Language Modeling (MLM) predicts masked words using full context

Causal Language Modeling predicts the next word based on past words

Typical Output

Classifications, embeddings, extracted answers

Generated sentences, paragraphs or code

Best Suited For

Sentiment analysis, question answering, classification

Story writing, chatbots, code generation, creative tasks

Classified as Microsoft Confidential

63 of 88

AUTOENCODING

  • Autoencoding is a technique in Generative AI where a neural network learns to compress input data into a smaller representation and then reconstruct the original data.
  • It is mainly based on two components:
  • Encoder – converts the input into a compact representation.
  • Decoder – reconstructs the original input from that representation

Classified as Microsoft Confidential

64 of 88

Classified as Microsoft Confidential

65 of 88

ENCODER

  • The Encoder takes the input x and converts it into a lower-dimensional representation called the latent representation.

Where:

  • x = input
  • z = latent representation
  • ​ = encoder function

Example

  • An image may contain thousands of pixel values, but the encoder can represent its important features using a smaller vector.

Classified as Microsoft Confidential

66 of 88

LATENT SPACE

  • The latent space contains a compact representation of the important features of the input.

For example, for an image of a handwritten digit, the latent representation may capture:

  • Shape
  • Size
  • Orientation
  • Stroke patterns

Classified as Microsoft Confidential

67 of 88

5. DECODER

  • The Decoder takes the latent representation and attempts to reconstruct the original input.

Where:

  • z = latent representation
  • x^ = reconstructed output
  • ​ = decoder function

The objective is:

x^≈x

Classified as Microsoft Confidential

68 of 88

RECONSTRUCTION LOSS

  • The Autoencoder compares the original input with the reconstructed output.
  • A common loss function is Mean Squared Error (MSE):

Classified as Microsoft Confidential

69 of 88

The main steps are:

  • Input data is provided to the encoder.
  • Encoder compresses the data.
  • A latent representation is created.
  • Decoder reconstructs the input.
  • Original and reconstructed data are compared.
  • Reconstruction loss is calculated.
  • Model parameters are updated.
  • The process is repeated until reconstruction improves.

Classified as Microsoft Confidential

70 of 88

REGRESSION MODELS

Regression is a supervised learning technique used to predict continuous numerical values by learning relationships between input variables (features) and an output variable (target).

Examples:

  • Predicting house prices
  • Predicting temperature
  • Predicting sales
  • Predicting risk scores
  • Predicting continuous values from generated features

Classified as Microsoft Confidential

71 of 88

Classified as Microsoft Confidential

72 of 88

  • The simplest regression model is Linear Regression:

Where:

  • x = input feature
  • y​ = predicted value
  • b0​ = intercept
  • b1​ = coefficient/slope

Classified as Microsoft Confidential

73 of 88

TYPES OF REGRESSION

  • Regression can be classified into different types based on the number of predictor variables and the nature of the relationship between variables:

1. Simple Linear Regression

  • Simple Linear Regression models the relationship between one independent variable and a continuous dependent variable by fitting a straight line that minimizes the sum of squared errors.

Classified as Microsoft Confidential

74 of 88

2. Multiple Linear Regression

Uses multiple input variables.

Example: Predicting house price using area, bedrooms, and location.

Classified as Microsoft Confidential

75 of 88

3. Polynomial Regression

  • Used when the relationship between input and output is nonlinear.

Example: Predicting population growth.

4. Ridge Regression

  • Linear regression with L2 regularization.
  • Helps reduce overfitting.

Classified as Microsoft Confidential

76 of 88

5.Lasso Regression

  • Uses L1 regularization.
  • Can automatically eliminate less important features.

6.Logistic Regression

    • Despite its name, it is mainly used for classification, not continuous-value regression.
    • Example: Predicting whether a patient has a disease: Yes/No.

7.Support Vector Regression (SVR)

    • Extension of Support Vector Machines for predicting continuous values.
    • Useful for complex and non-linear relationships.

8.Decision Tree Regression

    • Uses a tree structure to make numerical predictions.

Classified as Microsoft Confidential

77 of 88

EXAMPLE

  • Suppose we want to predict student marks:

Input Data → Generative Model → Generated Data → Regression Model → Numerical Prediction

  • Input:�Study Hours = 6�Attendance = 85%�Previous Marks = 72
  • Regression Model → Predicted Marks = 82

Classified as Microsoft Confidential

78 of 88

EXPLORING CHATGPT

ChatGPT is a Generative AI-based conversational system developed by OpenAI. It uses large language models (LLMs) to understand user instructions and generate human-like responses in natural language. It can be used for education, programming, research, content creation, and many other applications.

Classified as Microsoft Confidential

79 of 88

1. WORKING OF CHATGPT

The basic working process is:

  • User Prompt → Tokenization → Transformer/LLM Processing → Next-Token Prediction → Response Generation
  • Prompt: The user enters a question or instruction.
  • Tokenization: The input text is divided into smaller units called tokens.
  • Language Processing: The Transformer-based model analyzes the tokens and their context.
  • Prediction: The model predicts suitable next tokens based on learned patterns.
  • Response Generation: The predicted tokens are combined to form a meaningful response.

Classified as Microsoft Confidential

80 of 88

APPLICATIONS OF CHATGPT

  • Education: Tutoring, question generation, and learning assistance.
  • Research: Literature summarization and research brainstorming.
  • Programming: Code generation, debugging, and explanation.
  • Business: Report writing, email drafting, and customer support.
  • Healthcare: General information and documentation assistance.
  • Content Creation: Blogs, articles, advertisements, and social-media content.

Classified as Microsoft Confidential

81 of 88

PROMPT ENGINEERING: DESIGNING PROMPTS

Prompt engineering is the process of creating clear and effective prompts that guide AI models to generate accurate responses such as ChatGPT, Gemini, and Claude to obtain accurate, relevant, and useful outputs.

Example

Poor Prompt:

“Explain AI”

Good Prompt:

“Explain Artificial Intelligence in simple language for undergraduate students. Give its definition, three applications, advantages, and limitations in 200 words”

The second prompt provides clear instructions, context, and output requirements, so the AI can generate a better response.

Classified as Microsoft Confidential

82 of 88

Classified as Microsoft Confidential

83 of 88

PROMPT DESIGN FRAMEWORK

  • Role: Defines the persona or perspective the AI should adopt (e.g., teacher, programmer) which sets the tone and style of the response.
  • Task: Clearly states what the AI needs to do such as summarizing, generating content or answering a question.
  • Instructions: Provides specific guidelines on how the task should be done including format, tone, length or any constraints.
  • Context: Adds relevant background information so the AI better understands the situation and produces more accurate results.
  • Input: Includes the actual data or query given to the AI, which acts as the starting point for generating the response.

Classified as Microsoft Confidential

84 of 88

DATABASES AND INFORMATION SOURCES

  • provide external data such as facts, records and knowledge that AI systems use to generate accurate and updated responses.
  • Includes databases, knowledge bases and information systems.
  • Ensures access to current and reliable data.
  • Improves the quality of AI outputs with factual content.
  • Connected to systems so AI can retrieve data when needed.

Classified as Microsoft Confidential

85 of 88

WORKFLOWS

  • refer to a sequence of steps where data is gathered, prompts are created and the AI generates responses. This process is iterative and improves over time.
  • Involves data retrieval, prompt creation and AI response generation.
  • The process repeats to refine and improve results.
  • Different components work together continuously.
  • Helps enhance accuracy and output quality over time.

Classified as Microsoft Confidential

86 of 88

PROMPT LIBRARIES

Prompt Libraries are collections of ready made prompts that help guide AI models to generate useful and consistent responses. They act as reusable templates for different tasks, saving time and improving output quality.

  • Contains ready to use instructions for common tasks.
  • Can be used multiple times for similar queries.
  • Reduces the need to create prompts from scratch.
  • Helps generate more consistent and high quality outputs.

Classified as Microsoft Confidential

87 of 88

GENERATIVE AI

  • refers to AI models that create new content like text, images, code or other data based on given prompts. In prompt engineering, it focuses on generating accurate and useful outputs from well designed instructions.
  • Generates text, images, code and more.
  • Works based on the input instructions provided.
  • Used in writing, design, coding and other tasks.
  • Depends on how well the prompt is designed.

Classified as Microsoft Confidential

88 of 88

IMPORTANT PROMPT DESIGN TECHNIQUES

  • Zero-shot prompting : Give the task without examples.
  • Few-shot prompting : Provide examples to guide the model.
  • Role prompting : Assign a specific role to the AI.
  • Instruction prompting : Give precise instructions.
  • Structured prompting : Organize instructions into sections.
  • Iterative refinement : Improve the prompt based on the generated response.

Classified as Microsoft Confidential