0% found this document useful (0 votes)
6 views25 pages

GenAI Complete Guide

This document is a comprehensive guide to Generative AI, detailing its definition, types of models, and the underlying technology such as Transformers. It explains the differences between generative and discriminative models, the significance of generative AI in modern applications, and provides insights into neural networks and large language models. Additionally, it covers practical aspects like prompt engineering and retrieval-augmented generation (RAG) for enhancing AI interactions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views25 pages

GenAI Complete Guide

This document is a comprehensive guide to Generative AI, detailing its definition, types of models, and the underlying technology such as Transformers. It explains the differences between generative and discriminative models, the significance of generative AI in modern applications, and provides insights into neural networks and large language models. Additionally, it covers practical aspects like prompt engineering and retrieval-augmented generation (RAG) for enhancing AI interactions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Generative AI — Complete Guide

Generative AI
A Complete Beginner-to-Advanced Guide
Concepts • Visuals • Worked Examples • Code • Interview Prep

A self-contained study companion covering what Generative AI is, how the


models work, how to build with them, and how to talk about them in interviews.

Page 1 of 25
Generative AI — Complete Guide

Table of Contents
TOC \h \o "1-2"

Page 2 of 25
Generative AI — Complete Guide

1. Introduction to Generative AI
Generative AI (GenAI) is the branch of artificial intelligence that creates new content — text,
images, audio, video, code, or 3D — rather than only analysing existing content. When you ask
a chatbot to write an email, ask an image tool to paint a fox in a spacesuit, or ask a coding
assistant to draft a function, you are using a generative model.

DEFINITION — Generative AI
A class of machine-learning models that learn the underlying patterns of a dataset and then
produce brand-new samples that resemble — but are not copies of — the data they were
trained on.

1.1 Generative vs. Discriminative Models


The cleanest way to understand GenAI is to contrast it with the older, more familiar style of AI:
discriminative models. A discriminative model draws a line between categories (“is this email
spam or not?”). A generative model instead learns the shape of the data well enough to invent
new members of it (“write me a new email”).

Figure: Discriminative models classify; generative models create.

Aspect Discriminative model Generative model


Main goal Separate / classify Create new samples
Typical question “Is this spam?” “Write me an email.”
What it learns The boundary between classes The distribution of the data
Everyday Spam filter, fraud detection ChatGPT, image & music generators
examples

IN PLAIN ENGLISH
Discriminative = “judge”. Generative = “artist”. The judge points at things and names them;
the artist makes new things in the same style.

Page 3 of 25
Generative AI — Complete Guide

1.2 Why Generative AI Matters Now


Three forces converged to make GenAI suddenly practical: vast amounts of digital training data,
cheap parallel compute (GPUs/TPUs), and a breakthrough model design called the Transformer
(2017). Together they let models scale to billions of parameters and develop surprisingly
general capabilities.
• Productivity: drafting, summarising, translating, and coding at speed.
• Accessibility: natural language becomes the interface to software.
• Creativity: rapid prototyping of images, music, and design.
• New risks: hallucinations, copyright questions, and misuse — covered in Section 12.

Page 4 of 25
Generative AI — Complete Guide

2. Foundations: AI, ML, Deep Learning


Generative AI sits at the centre of a set of nested fields. Understanding the hierarchy clears up
most beginner confusion about “where does GenAI fit?”

Figure: AI contains ML, which contains deep learning, which contains most modern GenAI.

DEFINITION — Machine Learning (ML)


Systems that improve at a task by learning patterns from data instead of being explicitly
programmed with rules.

DEFINITION — Deep Learning (DL)


A subset of ML that uses multi-layer neural networks to learn complex patterns directly from
raw data such as pixels or text.

2.1 Neural Networks — the Engine


Almost every modern generative model is a deep neural network. A neural network is a stack of
layers of simple units (“neurons”). Each connection has a weight; each neuron adds up its
inputs, applies a non-linear function, and passes the result on. Training adjusts the weights so
the network's output matches the desired target.

Page 5 of 25
Generative AI — Complete Guide

Figure: Information flows left to right; learning flows right to left as weights are nudged.

How it works for beginners


1. Feed an input (e.g. a sentence) into the first layer.
2. Each layer transforms the numbers and passes them forward (the “forward pass”).
3. Compare the final output to the correct answer using a loss function.
4. Use backpropagation to compute how each weight contributed to the error.
5. Nudge every weight a little to reduce the error (gradient descent). Repeat millions of
times.
IN PLAIN ENGLISH
A neural network is just a very large adjustable mathematical function. “Training” means
automatically tuning millions of knobs until the function gives good answers.

Page 6 of 25
Generative AI — Complete Guide

3. How Generative Models Learn


A generative model's job is to learn a probability distribution over data. Loosely: “given
everything I've seen, how likely is this particular arrangement of words/pixels?” Once a model
can score how likely things are, it can also sample — generate new things that are likely under
what it learned.

DEFINITION — Sampling
The process of drawing a new, previously-unseen example from the distribution a
generative model has learned. This is the actual act of “generating”.

3.1 The Core Idea: Predict the Next Piece


Most text generators are trained on one deceptively simple task: predict the next token (word or
word-piece) given all previous tokens. Do this well enough, across trillions of words, and the
model is forced to learn grammar, facts, reasoning patterns, and style — because all of those
help predict what comes next.

PRACTICAL EXAMPLE — Next-token prediction


Input prompt: “The capital of France is”
The model produces a probability for every possible next token:

Paris -> 0.92


the -> 0.03
a -> 0.01
Lyon -> 0.005
...

It then samples (often the highest, sometimes a weighted pick) and appends the chosen token, then repeats.

Generating a paragraph is just this loop running hundreds of times, each new token fed
back in as part of the input.

Page 7 of 25
Generative AI — Complete Guide

4. Types of Generative Models


There are four model families worth knowing. Modern text and chat assistants are almost all
Transformers (Section 5); images historically used GANs and now mostly use diffusion models.

4.1 Generative Adversarial Networks (GANs)


DEFINITION — GAN
Two neural networks trained in competition: a Generator that creates fakes and a
Discriminator that tries to tell fakes from real data. Their contest drives both to improve.

Figure: The generator and discriminator improve by competing, like a forger versus a detective.

How it works for beginners


• The Generator starts producing random noise and gradually learns to make realistic
samples.
• The Discriminator learns to spot the difference between real and generated samples.
• Each one's success becomes the other's training signal — an “arms race” that ends when
fakes look real.
• Strengths: sharp, realistic images. Weaknesses: unstable training and “mode collapse”
(low variety).

4.2 Variational Autoencoders (VAEs)


DEFINITION — VAE
A model that compresses data into a smooth, continuous “latent space” and then
reconstructs it, allowing new samples to be generated by picking points in that space.
VAEs encode an input into a compact vector, then decode it back. Because the latent space is
smooth, you can interpolate between points to blend concepts. They tend to produce slightly
blurrier images than GANs but are stable and great for learning structured representations.

Page 8 of 25
Generative AI — Complete Guide

4.3 Diffusion Models


DEFINITION — Diffusion model
A generator that learns to reverse a gradual noising process: it starts from pure random
noise and removes noise step by step until a clean sample emerges.

Figure: Training adds noise; generation reverses it, denoising from static into an image.

How it works for beginners


1. Forward process: take a real image and add a little noise, repeatedly, until it's pure static.
2. The model trains to predict and remove the noise added at each step.
3. Generation: start from random static and apply the learned denoiser many times to reveal
a new image.
IN PLAIN ENGLISH
Diffusion is like sculpting: you begin with a shapeless block of noise and chip away until a
picture appears. This powers Stable Diffusion, DALL·E, and Midjourney.

4.4 Autoregressive / Transformer Models


DEFINITION — Autoregressive model
A model that generates a sequence one element at a time, with each new element
conditioned on everything generated so far.
This is the family behind large language models. They generate text token-by-token (Section
3.1) and are built on the Transformer architecture, which we cover next because it is the heart of
modern GenAI.

Family Best at Note


GAN Realistic images Hard to train
VAE Smooth latent spaces Slightly blurry
Diffusion High-quality images/video Slower to sample
Transformer Text, code, multimodal Dominant today

Page 9 of 25
Generative AI — Complete Guide

5. The Transformer Architecture


The 2017 paper “Attention Is All You Need” introduced the Transformer, the design behind
GPT, Claude, Gemini, Llama, and most modern GenAI. Its key innovation is the attention
mechanism, which lets the model weigh the relevance of every word to every other word in
parallel.

DEFINITION — Attention
A mechanism that lets a model decide, for each token, how much to focus on every other
token when building its representation — capturing context and long-range relationships.

Figure: Self-attention: “sat” draws most strongly on “cat” to understand who is sitting.

5.1 Self-Attention, Step by Step


For every token the model creates three vectors: a Query (what am I looking for?), a Key (what
do I offer?), and a Value (what do I carry?). It compares each Query to all Keys to get attention
weights, then mixes the Values accordingly.
1. Turn each token into Query, Key, and Value vectors.
2. Score a token against every other by comparing Query · Key.
3. Convert scores to weights with softmax (they sum to 1).
4. Output = weighted sum of Values — a context-aware representation of the token.
IN PLAIN ENGLISH
Attention is like reading a sentence and, for each word, highlighting the other words that
help you understand it. “Multi-head” attention just does this several times in parallel to catch
different kinds of relationships.

Page 10 of 25
Generative AI — Complete Guide

5.2 Anatomy of a Transformer Block


A Transformer stacks many identical blocks. Each block contains a multi-head self-attention
layer and a small feed-forward network, with residual connections and layer normalisation that
keep training stable. Stack dozens of these and add hundreds of billions of parameters, and you
get a large language model.

Component What it does


Token + positional embedding Turn words into vectors and encode their order
Multi-head self-attention Mix context across all tokens
Feed-forward network Transform each token's representation
Residual + LayerNorm Stabilise and speed up training
Output / unembedding Convert final vectors into next-token probabilities

Page 11 of 25
Generative AI — Complete Guide

6. Large Language Models (LLMs)


DEFINITION — Large Language Model
A Transformer-based model with billions of parameters, trained on massive text corpora to
predict the next token, resulting in broad language and reasoning abilities.

6.1 Tokens and Parameters


LLMs don't read whole words; they read tokens — common chunks of text. “Generative” might
be one token; a rare word may be split into several. Parameters are the learned weights; more
parameters generally means more capacity (and cost).

PRACTICAL EXAMPLE — Tokenisation


The sentence “GenAI is amazing!” might split into:

["Gen", "AI", " is", " amazing", "!"] -> 5 tokens

Roughly 1 token ≈ 0.75 English words. Pricing and context limits are measured in tokens.

6.2 How an LLM Is Built: Three Stages

Figure: From raw next-word predictor to aligned, helpful assistant.

1. Pre-training: the model learns language by predicting the next token across enormous
text. Expensive; produces a raw “base model.”
2. Supervised fine-tuning (SFT): trained on curated instruction–response pairs so it follows
instructions.
3. Alignment (RLHF/DPO): humans rank responses and the model is tuned toward helpful,
harmless, honest behaviour.
DEFINITION — RLHF
Reinforcement Learning from Human Feedback — using human preference rankings to train
a reward signal that steers the model toward responses people prefer.

Page 12 of 25
Generative AI — Complete Guide

6.3 Controlling Generation


At generation time you can steer the output's randomness and length with a few parameters:

Parameter Effect
temperature Higher = more random/creative; lower = more focused/deterministic
top_p (nucleus) Sample only from the smallest set of tokens covering p probability
max_tokens Caps the length of the response
stop sequences Strings that, when produced, end the generation

Page 13 of 25
Generative AI — Complete Guide

7. Embeddings & Vector Databases


DEFINITION — Embedding
A list of numbers (a vector) that represents the meaning of a piece of text, image, or other
data, positioned so that similar meanings are close together in space.

Figure: Meaning becomes geometry: related concepts cluster; relationships become directions.

Embeddings are how machines measure semantic similarity. Two sentences with similar
meaning produce vectors that are close (small cosine distance) even if they share no words.
This unlocks semantic search, recommendation, clustering, and — crucially — RAG (Section 9).

DEFINITION — Vector database


A database optimised to store embeddings and instantly find the nearest vectors to a query
vector (e.g. Pinecone, Weaviate, FAISS, Chroma).

PRACTICAL EXAMPLE — Semantic search


A user searches “how to reset my password.” A keyword system misses a doc titled
“Recovering account access,” but an embedding system finds it because the two phrases
land near each other in vector space.

Page 14 of 25
Generative AI — Complete Guide

8. Prompt Engineering
DEFINITION — Prompt engineering
The practice of designing the text input to an LLM so that it produces the most accurate,
relevant, and well-formatted output.

8.1 Core Techniques


• Be specific: state the role, task, format, and constraints explicitly.
• Few-shot prompting: include 1–5 examples of the input→output you want.
• Chain-of-thought: ask the model to “think step by step” for reasoning tasks.
• Delimit context: wrap reference material in quotes or tags so it's clearly separated from
instructions.
PRACTICAL EXAMPLE — Weak vs. strong prompt
Weak: “Write about dogs.”
Strong: “You are a vet. Write a 100-word, friendly paragraph for first-time owners explaining
how often to feed a puppy. Use simple language and end with one safety tip.”
The strong prompt fixes role, length, audience, tone, and structure — removing the
guesswork that produces generic output.

Zero-shot vs. few-shot


# Zero-shot: just ask
Classify the sentiment: 'The film dragged on.'

# Few-shot: show the pattern first


Review: 'Loved every minute!' -> Positive
Review: 'Total waste of time.' -> Negative
Review: 'The film dragged on.' -> ?

Few-shot examples teach the format and label set without any retraining.

Page 15 of 25
Generative AI — Complete Guide

9. Retrieval-Augmented Generation (RAG)


DEFINITION — RAG
A technique that retrieves relevant documents from a knowledge base and inserts them into
the prompt, so the LLM answers using up-to-date, source-grounded information instead of
memory alone.

Figure: RAG grounds the model in your own documents before it answers.

9.1 Why RAG?


LLMs have a fixed knowledge cutoff and can hallucinate. RAG fixes both by fetching the right
facts at query time. It is the most common pattern for building chatbots over private or current
data — documentation, policies, product catalogues — without retraining the model.
How it works for beginners
1. Split your documents into chunks and embed each chunk; store vectors in a vector
database (done once).
2. When a question arrives, embed the question.
3. Retrieve the top-k most similar chunks from the database.
4. Paste those chunks into the prompt alongside the question.
5. The LLM answers using the supplied context and can cite its sources.
IN PLAIN ENGLISH
RAG turns a “closed-book exam” into an “open-book exam.” The model no longer has to
remember everything — you hand it the relevant page right before it answers.

Page 16 of 25
Generative AI — Complete Guide

9.2 Fine-tuning vs. RAG vs. Prompting


Approach Best for Trade-off
Prompting Quick tasks, formatting, style Limited by context window
RAG Grounding in private/current facts Needs a retrieval pipeline
Fine-tuning Teaching a consistent skill/voice Costly; data-hungry; can go
stale

IN PLAIN ENGLISH
Rule of thumb: start with prompting, add RAG when the model needs facts it doesn't have,
and fine-tune only when you need a behaviour or style that prompting can't reliably produce.

Page 17 of 25
Generative AI — Complete Guide

10. Practical Code Examples


These runnable snippets show the three things you'll do most: call an LLM, create embeddings,
and build a minimal RAG loop. They use the Anthropic Python SDK, but the ideas transfer to
any provider.

10.1 Calling an LLM


import anthropic

client = [Link]() # reads API key from env var

resp = [Link](
model="claude-sonnet-4-6",
max_tokens=300,
temperature=0.7, # creativity dial (Section 6.3)
messages=[{"role": "user",
"content": "Explain embeddings in two sentences."}]
)
print([Link][0].text)

Code explanation below.

Line-by-line: we create a client, then call [Link] with the model name, a length cap
(max_tokens), a temperature controlling randomness, and a list of messages. The reply text
lives in [Link][0].text. Every chat app is, at its core, this loop with conversation history
appended each turn.

10.2 Creating Embeddings & Measuring Similarity


import numpy as np

def cosine(a, b):


a, b = [Link](a), [Link](b)
return a @ b / ([Link](a) * [Link](b))

# embeddings come from an embedding model (provider call omitted)


v_query = embed('how do I reset my password?')
v_doc = embed('steps to recover account access')

print(cosine(v_query, v_doc)) # ~0.86 -> very similar

Cosine similarity returns 1.0 for identical meaning and ~0 for unrelated text.

Explanation: each text is turned into a vector by an embedding model. cosine measures the
angle between two vectors — the standard way to score semantic similarity. A high score
means the strings mean nearly the same thing even though they share no keywords. This single
function is the engine behind semantic search and RAG retrieval.

Page 18 of 25
Generative AI — Complete Guide

10.3 A Minimal RAG Pipeline


# 1) INDEX (once): chunk -> embed -> store
chunks = split_into_chunks(my_documents)
index = [(c, embed(c)) for c in chunks]

# 2) RETRIEVE: find the most relevant chunks


def retrieve(question, k=3):
qv = embed(question)
ranked = sorted(index,
key=lambda ce: cosine(qv, ce[1]),
reverse=True)
return [c for c, _ in ranked[:k]]

# 3) GENERATE: ground the LLM in retrieved context


def answer(question):
context = '\n\n'.join(retrieve(question))
prompt = f'Use ONLY this context:\n{context}\n\nQ: {question}'
return call_llm(prompt)

The three RAG stages from Section 9.1 in code: index, retrieve, generate.

Walkthrough: Step 1 builds a searchable index of (chunk, vector) pairs once. Step 2's
retrieve embeds the question and ranks every chunk by cosine similarity, returning the top k.
Step 3 stitches those chunks into a prompt that instructs the model to answer only from the
supplied context — which is what keeps answers grounded and reduces hallucination.

Page 19 of 25
Generative AI — Complete Guide

11. Evaluating Generative AI


Because output is open-ended, evaluation is harder than for classification. Use a mix of
automatic metrics, model-based judging, and human review.

Method What it checks Example


Reference metrics Overlap with a gold answer BLEU, ROUGE for
translation/summaries
Embedding similarity Semantic closeness to a target BERTScore, cosine similarity
LLM-as-judge Quality scored by another model Rate helpfulness 1–5
Human evaluation Real preference & safety A/B preference tests
Task metrics Did it work? Unit tests pass for generated code

DEFINITION — Hallucination
When a model produces fluent, confident output that is factually wrong or unsupported by its
sources. A central reason to use RAG and human review.

Page 20 of 25
Generative AI — Complete Guide

12. Ethics, Risks & Limitations


Building responsibly means understanding where GenAI fails and who it can affect.
• Hallucination: confident but wrong answers; mitigate with RAG, citations, and
verification.
• Bias: models reflect biases in their training data and can amplify them.
• Privacy: avoid sending sensitive data to third-party APIs without safeguards.
• Copyright & provenance: training data and generated outputs raise unresolved IP
questions.
• Misuse: deepfakes, misinformation, and automated spam.
• Cost & environment: training and serving large models is compute-intensive.
IN PLAIN ENGLISH
Responsible GenAI = keep a human in the loop for high-stakes decisions, cite sources, test
for bias, and be transparent that content is AI-generated.

Page 21 of 25
Generative AI — Complete Guide

13. Interview Questions (Beginner → Advanced)


Below are 24 commonly asked questions with concise model answers, grouped from
foundational to advanced. Practise saying each answer aloud in your own words.

13.1 Beginner
Q1. [Beginner] What is Generative AI?
Answer: AI that creates new content (text, images, audio, code) by learning the patterns of
training data and sampling new examples from that learned distribution, rather than only
classifying existing data.
Q2. [Beginner] How does generative differ from discriminative AI?
Answer: Discriminative models learn the boundary between classes to answer “which label?”;
generative models learn how the data is distributed so they can produce brand-new samples.
Q3. [Beginner] What is a token?
Answer: A token is a chunk of text (a word or word-piece) that an LLM processes as a unit.
Roughly one token equals 0.75 English words; context limits and pricing are measured in
tokens.
Q4. [Beginner] What is a prompt?
Answer: The input text you give an LLM. Prompt engineering is the practice of writing it clearly
— specifying role, task, format, and constraints — to get better output.
Q5. [Beginner] What is an embedding?
Answer: A vector of numbers representing the meaning of data, arranged so that similar
meanings are near each other. It powers semantic search, clustering, and RAG.
Q6. [Beginner] What is a hallucination?
Answer: When a model generates fluent but factually incorrect or unsupported content.
Mitigations include RAG, source citations, and human verification.
Q7. [Beginner] Name a few real applications of GenAI.
Answer: Chat assistants, code completion, summarisation, translation, image and video
generation, semantic search, and customer-support bots over private docs.
Q8. [Beginner] What does temperature control?
Answer: The randomness of generation. Low temperature gives focused, repeatable output;
high temperature gives more diverse, creative output.

13.2 Intermediate
Q9. [Intermediate] Explain the attention mechanism.
Answer: Attention lets each token decide how much to focus on every other token. Using
Query, Key, and Value vectors, the model scores token relevance, normalises with softmax, and
outputs a weighted sum of Values — capturing context and long-range dependencies in parallel.
Q10. [Intermediate] Why were Transformers a breakthrough over RNNs?

Page 22 of 25
Generative AI — Complete Guide

Answer: They process all tokens in parallel (faster training), capture long-range dependencies
without vanishing gradients, and scale efficiently to billions of parameters — RNNs processed
sequentially and struggled with long context.
Q11. [Intermediate] How does RAG work and why use it?
Answer: RAG embeds a query, retrieves the most similar chunks from a vector database, and
inserts them into the prompt so the LLM answers from grounded, current sources. It reduces
hallucination and avoids retraining for new data.
Q12. [Intermediate] Compare fine-tuning, RAG, and prompting.
Answer: Prompting steers behaviour at inference with no training; RAG injects external
knowledge at query time; fine-tuning updates weights to teach a consistent skill or style. Start
with prompting, add RAG for facts, fine-tune for behaviour.
Q13. [Intermediate] What are the three stages of training an LLM?
Answer: Pre-training (next-token prediction on huge corpora), supervised fine-tuning
(instruction–response pairs), and alignment via RLHF/DPO (tuning toward human-preferred
responses).
Q14. [Intermediate] How do diffusion models generate images?
Answer: They learn to reverse a noising process: training adds noise to images step by step,
and the model learns to remove it. Generation starts from pure noise and denoises iteratively
into a new image.
Q15. [Intermediate] What is the difference between top_p and temperature?
Answer: Temperature rescales the probability distribution's sharpness; top_p (nucleus
sampling) restricts choices to the smallest set of tokens whose probabilities sum to p. They can
be combined to balance diversity and coherence.
Q16. [Intermediate] How would you reduce hallucinations in a production chatbot?
Answer: Ground answers with RAG and require citations, instruct the model to say “I don't
know” when context is missing, lower temperature, validate outputs, and keep a human in the
loop for high-stakes responses.
Q17. [Intermediate] What is a context window and why does it matter?
Answer: The maximum number of tokens (prompt + response) a model can consider at once. It
limits how much document or conversation history you can include, which drives chunking
strategy in RAG.

13.3 Advanced
Q18. [Advanced] Walk through self-attention math at a high level.
Answer: For input X, compute Q=XWQ, K=XWK, V=XWV. Attention = softmax(QKᵀ / √d k)V. The
dot products score query–key relevance, the √d scaling stabilises gradients, softmax normalises
to weights, and multiplying by V mixes information. Multi-head attention runs this in parallel
subspaces and concatenates the results.
Q19. [Advanced] What is RLHF and what problems does it solve?
Answer: Reinforcement Learning from Human Feedback: humans rank model outputs, a
reward model is trained on those rankings, and the LLM is optimised (e.g. PPO) to maximise

Page 23 of 25
Generative AI — Complete Guide

that reward. It aligns models with human preferences — helpfulness, harmlessness, honesty —
that raw next-token training doesn't capture. DPO is a simpler, RL-free alternative.
Q20. [Advanced] How would you design a RAG system for millions of documents?
Answer: Chunk thoughtfully (semantic boundaries, overlap), embed with a strong model, store
in a scalable vector DB with ANN indexing (HNSW/IVF), add metadata filtering and hybrid
keyword+vector search, use a reranker on top-k, manage the context budget, cache, and
continuously evaluate retrieval quality and answer faithfulness.
Q21. [Advanced] What causes mode collapse in GANs and how do you address it?
Answer: The generator finds a few outputs that reliably fool the discriminator and stops
producing variety. Remedies include Wasserstein loss with gradient penalty, minibatch
discrimination, unrolled GANs, spectral normalisation, and careful learning-rate balancing
between the two networks.
Q22. [Advanced] Explain parameter-efficient fine-tuning (e.g. LoRA).
Answer: Instead of updating all weights, LoRA freezes the base model and learns small low-
rank adapter matrices added to certain layers. This cuts memory and storage dramatically, lets
you swap task-specific adapters, and avoids catastrophic forgetting — making fine-tuning
feasible on modest hardware.
Q23. [Advanced] What are scaling laws and why do they matter?
Answer: Empirical relationships showing that model loss decreases predictably as parameters,
data, and compute increase together. They guide how to allocate a compute budget (e.g.
Chinchilla showed many models were undertrained on data relative to size) and inform whether
to grow the model or the dataset.
Q24. [Advanced] How do you evaluate an open-ended generative system rigorously?
Answer: Combine automatic reference metrics (ROUGE/BLEU) where references exist,
embedding-based scores (BERTScore), LLM-as-judge with calibrated rubrics, and human
preference tests. Add task-specific checks (unit tests for code, factuality/faithfulness scoring for
RAG), track for bias and safety, and monitor live with user feedback and red-teaming.

Page 24 of 25
Generative AI — Complete Guide

14. Quick-Reference Glossary


Term One-line meaning
GenAI AI that creates new content
LLM Large Transformer trained to predict the next token
Transformer Architecture built on attention; basis of modern GenAI
Attention Mechanism weighing each token's relevance to others
Token A word-piece the model processes
Embedding Vector capturing meaning; similar = nearby
RAG Retrieve documents, then generate a grounded answer
Fine-tuning Updating weights to teach a skill or style
RLHF Aligning models using human preference rankings
Diffusion Generate images by reversing a noising process
GAN Generator vs. discriminator competition
Hallucination Confident but incorrect/unsupported output
Temperature Randomness dial for generation
Context window Max tokens a model handles at once

— End of Guide —

Page 25 of 25

You might also like