Unit 5: Generative AI & Ethics; Prompt Engineering - Subjective Questions
INT428 — Artificial Intelligence Essentials • Practice Questions with Detailed Answers
20 questions
Define Generative AI and explain how it fundamentally differs from Discriminative AI.
Generative AI refers to a class of artificial intelligence models capable of creating new content such as text, images, audio, video, or code by learning the underlying patterns and distributions of training data.
Key differences from Discriminative AI:
-
Purpose:
- Generative models learn the joint probability distribution and can generate new data samples.
- Discriminative models learn the conditional probability and focus on classifying or predicting labels.
-
Output:
- Generative: produces new samples (e.g., a new image, a paragraph of text).
- Discriminative: produces a decision boundary or label (e.g., spam vs. not spam).
-
Examples:
- Generative: GANs, VAEs, GPT, Diffusion models.
- Discriminative: Logistic Regression, SVM, standard CNN classifiers.
-
Complexity: Generative modeling is generally harder because it must capture the full data distribution rather than just the boundaries between classes.
In summary, generative AI creates, while discriminative AI distinguishes.
Explain the architecture and working principle of Large Language Models (LLMs).
Large Language Models (LLMs) are deep neural networks trained on massive text corpora to understand and generate human-like language.
Core Architecture — The Transformer:
- LLMs are built on the Transformer architecture (Vaswani et al., 2017).
- The central innovation is the self-attention mechanism, which computes relationships between all tokens in a sequence:
where , , and are the Query, Key, and Value matrices, and is the dimension of the keys.
Working Principle:
- Tokenization: Input text is split into tokens and converted into embeddings.
- Positional Encoding: Added to embeddings to preserve word order.
- Attention Layers: Multiple stacked layers capture context and dependencies.
- Prediction: The model predicts the next token by outputting a probability distribution over the vocabulary.
Key characteristics:
- Scale: Billions of parameters (e.g., GPT-3 has 175B).
- Pre-training: Learns general language patterns via self-supervised learning.
- Fine-tuning: Adapted to specific tasks.
- Emergent abilities: Reasoning, translation, and summarization emerge at scale.
LLMs generate text autoregressively, predicting one token at a time based on prior context.
Describe the working of Generative Adversarial Networks (GANs) with a diagram-based explanation.
Generative Adversarial Networks (GANs), introduced by Ian Goodfellow (2014), consist of two neural networks competing in a min-max game.
Two Components:
- Generator (G): Takes random noise and generates fake data that mimics real data.
- Discriminator (D): Tries to distinguish real data from fake data, outputting a probability that the input is real.
Working Flow:
Noise (z) --> [Generator] --> Fake Data
|
Real Data ----------------------> [Discriminator] --> Real / Fake
Objective Function (Min-Max Game):
Training Process:
- The Discriminator is trained to maximize its accuracy in classifying real vs. fake.
- The Generator is trained to fool the discriminator by producing realistic samples.
- Training continues until an equilibrium is reached where the generator produces highly realistic data.
Applications: Image synthesis, deepfakes, super-resolution, style transfer, and data augmentation.
Challenges: Mode collapse, training instability, and non-convergence.
Explain how Diffusion Models work for generating images.
Diffusion Models are generative models that create data by learning to reverse a gradual noising process. They power tools like DALL·E 2, Stable Diffusion, and Midjourney.
Two Main Processes:
-
Forward Diffusion Process (Adding Noise):
- Gaussian noise is progressively added to the original data over steps until it becomes pure noise.
- At each step:
- where is the noise schedule.
-
Reverse Diffusion Process (Denoising):
- A neural network learns to remove noise step by step, reconstructing data from noise.
- The model predicts and subtracts the noise at each step to recover the clean image.
Working Principle:
- Start with random noise.
- Apply the trained model iteratively to denoise.
- After reverse steps, a coherent image emerges.
Advantages over GANs:
- More stable training (no adversarial competition).
- High-quality, diverse outputs.
- Avoids mode collapse.
Disadvantages:
- Slower generation due to many iterative steps.
- Computationally expensive.
Diffusion models excel at producing photorealistic, high-resolution images.
Distinguish between GANs, VAEs, and Diffusion Models as generative approaches.
The three dominant generative modeling paradigms differ in their mechanisms and trade-offs.
| Feature | GANs | VAEs | Diffusion Models |
|---|---|---|---|
| Mechanism | Adversarial (Generator vs Discriminator) | Encoder-Decoder with latent space | Iterative noising & denoising |
| Training Stability | Unstable, prone to mode collapse | Stable | Very stable |
| Output Quality | Sharp, realistic | Slightly blurry | Highest quality, photorealistic |
| Sample Diversity | Limited (mode collapse) | Good | Excellent |
| Generation Speed | Fast (single pass) | Fast | Slow (many steps) |
| Loss Function | Min-max adversarial loss | Reconstruction + KL divergence | Denoising objective |
Summary:
- GANs produce sharp images quickly but are hard to train.
- VAEs provide a smooth, interpretable latent space but blurrier outputs.
- Diffusion models offer the best quality and diversity at the cost of speed.
The choice depends on the trade-off between quality, speed, and stability required by the application.
Discuss the major industrial applications of Generative AI in content creation and automation.
Generative AI has transformed numerous industries through content creation and process automation.
1. Content Creation:
- Text Generation: Blog posts, marketing copy, emails, and reports (e.g., ChatGPT).
- Image & Design: Logos, artwork, product mockups (e.g., DALL·E, Midjourney).
- Video & Audio: Automated video editing, voice synthesis, music composition.
- Code Generation: Auto-completion and code writing (e.g., GitHub Copilot).
2. Automation:
- Customer Support: AI chatbots handling queries 24/7.
- Document Processing: Summarizing contracts, extracting key data.
- Software Development: Automated testing, debugging, and documentation.
- Workflow Automation: Generating reports and automating repetitive tasks.
3. Industry-Specific Uses:
- Healthcare: Drug discovery, synthetic medical data generation.
- Finance: Report generation, fraud pattern simulation.
- Marketing: Personalized ad content and campaigns.
- Entertainment: Game asset creation, scriptwriting.
- Education: Personalized tutoring and content generation.
Benefits: Increased productivity, cost reduction, personalization at scale, and faster prototyping.
Considerations: Quality control, factual accuracy, and ethical use remain important challenges.
Explain the key ethical concerns associated with Generative AI and the principles of its responsible use.
Generative AI raises significant ethical challenges that demand responsible governance.
Major Ethical Concerns:
- Misinformation & Deepfakes: AI can create realistic fake images, videos, and news, enabling manipulation.
- Bias & Fairness: Models trained on biased data can perpetuate stereotypes and discrimination.
- Copyright & IP: Training on copyrighted material and ownership of generated content raise legal questions.
- Privacy: Models may memorize and leak sensitive personal data.
- Job Displacement: Automation may replace certain human roles.
- Plagiarism & Academic Integrity: Misuse in education and research.
- Environmental Impact: High energy consumption for training large models.
Principles of Responsible Use:
- Transparency: Disclose AI-generated content clearly.
- Accountability: Establish responsibility for AI outputs.
- Fairness: Mitigate bias through diverse and balanced datasets.
- Privacy Protection: Safeguard personal and sensitive data.
- Human Oversight: Keep humans in the decision-making loop.
- Safety: Implement guardrails to prevent harmful outputs.
Best Practices: Watermarking AI content, obtaining consent, auditing models regularly, and complying with regulations like the EU AI Act.
Responsible use ensures generative AI benefits society while minimizing harm.
What is a prompt in the context of generative AI? Explain the fundamentals of prompting.
A prompt is the input text or instruction given to a generative AI model to guide its output. It serves as the primary means of communication between the user and the model.
Fundamentals of Prompting:
-
Definition: A prompt can be a question, command, statement, or context that directs the model's response.
-
Components of a Prompt:
- Instruction: The specific task (e.g., "Summarize the following text").
- Context: Background information to guide the response.
- Input Data: The content to process.
- Output Indicator: The desired format or structure.
-
Types of Prompts:
- Zero-shot: No examples provided, just the instruction.
- One-shot: One example given.
- Few-shot: Multiple examples to demonstrate the pattern.
How Prompts Work:
- The model interprets the prompt and predicts the most probable continuation based on its training.
- The quality and clarity of the prompt directly affect output quality.
Example:
Prompt: "Explain photosynthesis in simple terms for a 10-year-old."
A well-crafted prompt yields relevant, accurate, and useful responses, while a vague prompt produces poor results.
Explain the importance of Prompt Engineering and why it is a critical skill in the AI era.
Prompt Engineering is the practice of designing and refining input prompts to elicit optimal responses from generative AI models.
Why It Is Important:
-
Maximizes Output Quality: Well-structured prompts produce more accurate, relevant, and coherent responses.
-
Cost Efficiency: Reduces the need for expensive model retraining or fine-tuning — a good prompt can achieve desired results directly.
-
Task Control: Enables precise control over tone, format, length, and style of output.
-
Unlocks Model Capabilities: Techniques like Chain-of-Thought prompting improve reasoning abilities.
-
Reduces Errors & Hallucinations: Clear prompts minimize incorrect or fabricated outputs.
-
Accessibility: Allows non-technical users to leverage powerful AI without coding.
Key Reasons It Is Critical:
- The same model can give vastly different outputs depending on the prompt.
- It bridges the gap between human intent and machine understanding.
- It is a fast, iterative way to adapt models to new tasks.
Impact: As AI adoption grows, prompt engineering has become a valuable professional skill across industries, enabling effective human-AI collaboration.
In essence, prompt engineering turns a general-purpose model into a task-specific tool.
Provide an overview of language models and describe their evolution.
Language Models (LMs) are AI systems that assign probabilities to sequences of words and predict text, forming the foundation of NLP.
Core Concept:
- A language model estimates the probability of a word sequence:
Evolution of Language Models:
-
1. Statistical Models (N-grams):
- Predict the next word based on the previous words.
- Limited by short context and data sparsity.
-
2. Neural Language Models:
- Use word embeddings and neural networks (e.g., RNNs, LSTMs).
- Capture longer dependencies but struggle with very long sequences.
-
3. Transformer-based Models:
- Introduced self-attention (2017).
- Handle long-range dependencies efficiently and parallelize training.
-
4. Large Language Models (LLMs):
- Massive scale (billions of parameters): GPT, BERT, LLaMA, Gemini.
- Exhibit emergent capabilities like reasoning and few-shot learning.
Types by Architecture:
- Encoder-only (BERT): Understanding tasks.
- Decoder-only (GPT): Generation tasks.
- Encoder-Decoder (T5): Translation, summarization.
Language models have progressed from simple statistical counting to sophisticated systems capable of human-like language understanding and generation.
Describe the key elements of a good prompt with examples.
A well-designed prompt significantly improves the quality of AI responses. The following are its key elements:
1. Clarity and Specificity:
- Be precise about what you want.
- Poor: "Tell me about dogs."
- Good: "List 5 popular dog breeds suitable for apartment living with brief reasons."
2. Context:
- Provide relevant background information.
- Example: "As a nutritionist, suggest a balanced vegetarian meal plan."
3. Role/Persona Assignment:
- Assign a role to guide tone and expertise.
- Example: "You are an expert Python developer..."
4. Explicit Instructions:
- State the exact task and constraints (length, format, style).
- Example: "Summarize in 3 bullet points."
5. Output Format:
- Specify the desired structure (table, JSON, list).
- Example: "Present the answer as a Markdown table."
6. Examples (Few-shot):
- Provide sample input-output pairs to demonstrate the pattern.
7. Constraints and Tone:
- Define limitations and desired tone (formal, casual, technical).
Summary Checklist:
- ✔ Clear instruction
- ✔ Sufficient context
- ✔ Defined role
- ✔ Specified format
- ✔ Appropriate examples
Combining these elements results in accurate, relevant, and well-structured outputs.
Explain common Prompt Patterns used in prompt engineering with examples.
Prompt Patterns are reusable, structured approaches to crafting prompts that reliably produce good results.
1. Persona Pattern:
- Assign a specific role to the AI.
- Example: "Act as a cybersecurity expert and review this code for vulnerabilities."
2. Zero-shot / Few-shot Pattern:
- Provide zero or a few examples to guide behavior.
- Example: Giving 2-3 sample translations before asking for a new one.
3. Chain-of-Thought (CoT) Pattern:
- Instruct the model to reason step by step.
- Example: "Solve this problem step by step, showing your reasoning."
4. Template Pattern:
- Provide a fixed structure for the output.
- Example: "Fill in this template: Name: , Role: , Skills: __."
5. Question Refinement Pattern:
- Ask the AI to improve or clarify your question first.
- Example: "Suggest a better version of my question before answering."
6. Cognitive Verifier Pattern:
- Ask the model to break a question into sub-questions and answer each.
7. Flipped Interaction Pattern:
- The AI asks you questions to gather needed information.
- Example: "Ask me questions until you have enough details to plan my trip."
8. Output Automator Pattern:
- Request output in a directly usable format (script, code, list).
These patterns help achieve consistency, reliability, and higher-quality outputs across tasks.
What is Prompt Tuning? Explain how it differs from traditional fine-tuning.
Prompt Tuning is a parameter-efficient technique for adapting a large pre-trained language model to specific tasks by learning a small set of continuous prompt vectors (soft prompts), while keeping the model's original weights frozen.
How Prompt Tuning Works:
- Instead of modifying billions of model parameters, it optimizes a small set of trainable embeddings (soft prompts) prepended to the input.
- These soft prompts are learned via backpropagation to guide the model toward desired outputs.
- The base model remains unchanged and frozen.
Difference from Traditional Fine-Tuning:
| Aspect | Prompt Tuning | Fine-Tuning |
|---|---|---|
| Parameters Updated | Only soft prompt vectors (tiny) | All model weights (huge) |
| Cost | Very low | Very high |
| Storage | One base model + small prompts per task | Separate full model per task |
| Speed | Fast | Slow |
| Data Needs | Less | More |
| Performance | Near fine-tuning at scale | Best control |
Related Techniques:
- Prefix Tuning: Adds trainable prefixes to each layer.
- LoRA: Low-rank adaptation of weights.
- P-Tuning: Uses trainable continuous prompts.
Advantages:
- Memory and cost efficient.
- Enables multi-task deployment with one shared model.
Prompt tuning is ideal when full fine-tuning is too expensive, offering a lightweight path to task adaptation.
Explain the concept of hallucination in generative AI and discuss strategies to mitigate it.
Hallucination in generative AI refers to the phenomenon where a model produces outputs that are factually incorrect, fabricated, or nonsensical while presenting them confidently as true.
Why Hallucinations Occur:
- Models predict the most probable next token, not the most factual one.
- Gaps or biases in training data.
- Lack of real-time or grounded knowledge.
- Ambiguous or vague prompts.
- Over-generalization from patterns.
Types of Hallucination:
- Factual Hallucination: Inventing false facts or statistics.
- Faithfulness Hallucination: Output contradicts the provided source.
Mitigation Strategies:
- Retrieval-Augmented Generation (RAG): Ground responses in verified external documents.
- Clear, Specific Prompts: Reduce ambiguity.
- Instruction to Cite Sources: Ask the model to reference evidence.
- Temperature Control: Lower temperature for more deterministic, factual outputs.
- Human Verification: Fact-check critical outputs.
- Fine-tuning / RLHF: Align models with truthful behavior.
- Chain-of-Thought: Encourage step-by-step reasoning to reduce errors.
Importance: Mitigating hallucination is crucial in high-stakes domains like healthcare, law, and finance where accuracy is essential.
While hallucinations cannot be fully eliminated, these strategies substantially reduce their occurrence and impact.
Compare Zero-shot, One-shot, and Few-shot prompting with examples.
These are three prompting strategies based on the number of examples provided to the model.
1. Zero-shot Prompting:
- Definition: The model is given only an instruction with no examples.
- Example: "Translate 'Hello' into French."
- Use case: Simple, well-understood tasks.
2. One-shot Prompting:
-
Definition: The model is given one example before the actual task.
-
Example:
English: Cat -> French: Chat
English: Dog -> French: ? -
Use case: When a single example clarifies the expected format.
3. Few-shot Prompting:
-
Definition: The model is given multiple examples to demonstrate the pattern.
-
Example:
Review: 'Great!' -> Sentiment: Positive
Review: 'Terrible' -> Sentiment: Negative
Review: 'It was okay' -> Sentiment: ? -
Use case: Complex tasks requiring pattern recognition.
Comparison Table:
| Strategy | Examples | Complexity Handled | Accuracy |
|---|---|---|---|
| Zero-shot | 0 | Simple tasks | Moderate |
| One-shot | 1 | Moderate tasks | Better |
| Few-shot | 2+ | Complex tasks | Best |
Key Insight: More examples generally improve performance but consume more of the context window (tokens). The choice depends on task complexity and available context space.
Explain the role of temperature and other decoding parameters in controlling generative AI output.
Generative models use several decoding parameters to control how text is generated from probability distributions.
1. Temperature:
- Controls the randomness/creativity of outputs.
- Applied to the softmax function:
- Low temperature (): More deterministic, focused, and repetitive.
- High temperature (): More random, creative, and diverse.
2. Top-k Sampling:
- Restricts choices to the top most probable tokens.
- Example: considers only the 50 likeliest next tokens.
3. Top-p (Nucleus) Sampling:
- Selects from the smallest set of tokens whose cumulative probability exceeds .
- Example: includes tokens until 90% probability mass is covered.
4. Max Tokens:
- Limits the maximum length of the generated output.
5. Frequency & Presence Penalties:
- Reduce repetition by penalizing already-used tokens.
Practical Guidance:
| Task | Recommended Setting |
|---|---|
| Factual answers | Low temperature (0.0–0.3) |
| Creative writing | High temperature (0.7–1.0) |
| Balanced output | Medium (0.4–0.6) |
Tuning these parameters lets users balance accuracy vs. creativity based on the task requirements.
Describe the concept of Chain-of-Thought (CoT) prompting and explain why it improves reasoning.
Chain-of-Thought (CoT) prompting is a technique that encourages a language model to generate intermediate reasoning steps before arriving at a final answer, rather than producing the answer directly.
How It Works:
- Instead of asking for just the answer, the prompt instructs the model to "think step by step" or explains the reasoning process.
- The model decomposes a complex problem into smaller, manageable steps.
Example:
Standard Prompt: "If there are 3 cars and each has 4 wheels, how many wheels total?"
CoT Prompt: "Let's think step by step. Each car has 4 wheels. There are 3 cars. So 3 × 4 = 12 wheels."
Why CoT Improves Reasoning:
- Decomposition: Breaking problems into steps reduces the chance of error.
- Mimics Human Reasoning: Sequential logic aligns with how humans solve problems.
- Better for Multi-step Tasks: Especially effective for math, logic, and complex reasoning.
- Self-correction: Intermediate steps allow the model to catch mistakes.
Variants:
- Zero-shot CoT: Simply adding "Let's think step by step."
- Few-shot CoT: Providing example problems with worked-out reasoning.
- Self-Consistency: Generating multiple reasoning paths and choosing the majority answer.
Limitations: Increases token usage and works best on larger models where reasoning abilities emerge.
CoT significantly boosts accuracy on tasks requiring logical, arithmetic, or multi-step reasoning.
Explain the concept of bias in generative AI models and discuss its sources and consequences.
Bias in generative AI refers to systematic and unfair distortions in a model's outputs that favor or disadvantage certain groups, ideas, or perspectives.
Sources of Bias:
- Training Data Bias: Models learn from datasets that reflect societal prejudices, stereotypes, and imbalances.
- Historical Bias: Data captures past inequalities (e.g., gender roles in professions).
- Sampling Bias: Underrepresentation of certain groups in training data.
- Labeling Bias: Human annotators introduce subjective biases.
- Algorithmic Bias: Model design choices amplify certain patterns.
Types of Bias:
- Gender Bias: e.g., associating "nurse" with women, "engineer" with men.
- Racial/Ethnic Bias: Skewed representations or stereotypes.
- Cultural Bias: Favoring dominant languages or cultures.
- Confirmation Bias: Reinforcing existing viewpoints.
Consequences:
- Discrimination in hiring, lending, or law enforcement tools.
- Reinforcement of stereotypes in generated content.
- Erosion of trust in AI systems.
- Legal and reputational risks for organizations.
Mitigation Strategies:
- Use diverse and balanced training data.
- Apply bias detection and auditing tools.
- Implement fairness constraints during training.
- Include human review and feedback (RLHF).
- Ensure transparency about limitations.
Addressing bias is essential for building fair, trustworthy, and inclusive AI systems.
Describe the concept of deepfakes, how they are created using generative AI, and their societal implications.
Deepfakes are synthetic media (images, videos, or audio) in which a person's likeness or voice is realistically replaced or fabricated using generative AI techniques.
How Deepfakes Are Created:
- GANs (Generative Adversarial Networks): The generator creates fake faces/voices while the discriminator evaluates realism, iteratively improving quality.
- Autoencoders: Encode a source face and decode it onto a target, swapping identities.
- Diffusion Models: Increasingly used for high-fidelity synthetic media.
- Voice Cloning: Neural networks replicate a person's voice from audio samples.
Positive Applications:
- Film & Entertainment: De-aging actors, dubbing, visual effects.
- Education: Historical figure recreations.
- Accessibility: Voice restoration for those who lost speech.
Negative Implications:
- Misinformation: Fake videos of politicians or public figures.
- Fraud & Scams: Voice cloning for financial fraud.
- Defamation & Harassment: Non-consensual fake content.
- Erosion of Trust: "Liar's dividend" — real evidence dismissed as fake.
- Political Manipulation: Election interference.
Countermeasures:
- Detection tools that identify AI artifacts.
- Digital watermarking and provenance tracking (e.g., C2PA).
- Legislation criminalizing malicious deepfakes.
- Public awareness and media literacy.
Deepfakes highlight the dual-use nature of generative AI, demanding responsible development and robust safeguards.
Explain the generative process — how generative models learn and create new data. Include the role of probability distributions.
Generative models learn the underlying probability distribution of training data and use it to generate new, similar samples.
Core Idea:
- Given data from a true distribution , a generative model learns an approximate distribution that closely matches it.
- New samples are drawn from .
General Learning Process:
- Data Collection: Gather a large representative dataset.
- Distribution Learning: The model learns patterns, structures, and relationships in the data.
- Latent Space Representation: Complex data is encoded into a compressed latent space.
- Sampling & Generation: New points are sampled from the learned distribution and decoded into outputs.
How Different Models Generate:
- GANs: Learn to map random noise to realistic data via adversarial training.
- VAEs: Learn a probabilistic latent space and reconstruct data by sampling from it.
- Diffusion Models: Learn to reverse a noising process to reconstruct data.
- Autoregressive Models (LLMs): Generate sequences by modeling conditional probabilities:
Role of Probability Distributions:
- Generation is fundamentally a sampling process from a learned distribution.
- The model captures which outputs are likely and generates plausible new data.
- Randomness (sampling) ensures diversity in generated outputs.
Key Insight: Generative models do not copy training data; they learn its statistical essence to synthesize novel, coherent samples that resemble the original distribution.
Define Generative AI and explain how it fundamentally differs from Discriminative AI.
Generative AI refers to a class of artificial intelligence models capable of creating new content such as text, images, audio, video, or code by learning the underlying patterns and distributions of training data.
Key differences from Discriminative AI:
-
Purpose:
- Generative models learn the joint probability distribution and can generate new data samples.
- Discriminative models learn the conditional probability and focus on classifying or predicting labels.
-
Output:
- Generative: produces new samples (e.g., a new image, a paragraph of text).
- Discriminative: produces a decision boundary or label (e.g., spam vs. not spam).
-
Examples:
- Generative: GANs, VAEs, GPT, Diffusion models.
- Discriminative: Logistic Regression, SVM, standard CNN classifiers.
-
Complexity: Generative modeling is generally harder because it must capture the full data distribution rather than just the boundaries between classes.
In summary, generative AI creates, while discriminative AI distinguishes.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →