Unit5 - Subjective Questions
INT428 • Practice Questions with Detailed Answers
Differentiate between Generative AI and Discriminative AI with appropriate examples.
Generative AI and Discriminative AI represent two different approaches to machine learning.
Generative AI
- Goal: To generate new data instances that resemble the training data.
- Mechanism: It learns the joint probability distribution or just if there are no labels. It understands how the data is generated.
- Output: Creates new content (images, text, audio).
- Example: Predicting the next word in a sentence (LLMs), creating a realistic face (GANs).
Discriminative AI
- Goal: To distinguish between different kinds of data instances.
- Mechanism: It learns the conditional probability . It learns the boundary between classes.
- Output: Class labels, numerical predictions, or classifications.
- Example: Classifying an email as spam or not spam, identifying a cat in an image.
| Feature | Generative AI | Discriminative AI |
|---|---|---|
| Focus | How data is created | How classes are separated |
| Function | Generate new data | Classify/Predict existing data |
| Mathematical |
Explain the architecture and working mechanism of Generative Adversarial Networks (GANs). Include the mathematical formulation of the Min-Max game.
A Generative Adversarial Network (GAN) consists of two neural networks competing against each other in a zero-sum game framework.
Core Components
- The Generator ():
- Takes random noise vector () from a latent space.
- Transforms it into a synthetic data sample ().
- Goal: To fool the discriminator by generating data indistinguishable from real data.
- The Discriminator ():
- Takes an input (which can be real data or generated data).
- Outputs a probability between 0 and 1 (1 being real, 0 being fake).
- Goal: To correctly distinguish between real training data and fake data produced by .
Working Mechanism
- The Generator tries to minimize the probability that the Discriminator classifies its output as fake.
- The Discriminator tries to maximize its accuracy in classifying real vs. fake.
Mathematical Formulation (Min-Max Loss)
The objective function is defined as:
- : Discriminator wants to maximize log probability of real data being real.
- : Discriminator wants to maximize log probability of fake data being fake (0), while Generator wants to minimize this (trick into outputting 1).
Define Large Language Models (LLMs) and briefly explain the Transformer architecture that powers them.
Large Language Models (LLMs)
LLMs are deep learning algorithms that can recognize, summarize, translate, predict, and generate text and other content based on knowledge gained from massive datasets. They are 'large' both in terms of the dataset size and the number of parameters (weights) in the model.
Transformer Architecture
Most modern LLMs (like GPT, BERT) are based on the Transformer architecture, introduced in the paper "Attention Is All You Need".
- Self-Attention Mechanism: The core innovation. It allows the model to weigh the importance of different words in a sentence relative to each other, regardless of their distance. For example, in "The animal didn't cross the street because it was too tired," attention links "it" to "animal".
- Encoder-Decoder Structure:
- Encoder: Processes the input text to understand context (used in BERT).
- Decoder: Generates output text based on the learned representation (used in GPT).
- Positional Encoding: Since Transformers process data in parallel (unlike RNNs which are sequential), positional encodings are added to embeddings to retain the order of words.
- Feed-Forward Networks: Process the information passed from the attention layers.
Describe the concept of Diffusion Models in Generative AI. How do they differ from GANs?
Diffusion Models are a class of generative models that learn to generate data by reversing a gradual noise-addition process.
How Diffusion Models Work
- Forward Process (Diffusion): The model systematically adds Gaussian noise to the training data over time steps until the data becomes pure random noise.
- (Pure Noise)
- Reverse Process (Denoising): A neural network is trained to predict the noise added at each step and reverse it.
- Starting from random noise , the model iteratively removes noise to reconstruct a data sample .
Difference from GANs
- Training Stability: Diffusion models are generally more stable to train than GANs, which suffer from mode collapse and vanishing gradients.
- Quality: Diffusion models (e.g., Stable Diffusion, DALL-E) currently produce higher diversity and detail in image generation compared to GANs.
- Speed: Generating data with Diffusion models is slower because it requires multiple iterative steps (denoising), whereas GANs generate data in a single forward pass.
Discuss the Industrial Applications of Generative AI across three different sectors.
Generative AI has transformative applications across various industries:
-
Software Development (IT & Engineering):
- Code Generation: Tools like GitHub Copilot and ChatGPT assist developers by auto-completing code snippets, writing boilerplate code, and debugging.
- Legacy Migration: Converting code from older languages (e.g., COBOL) to modern ones (e.g., Python).
-
Marketing and Content Creation:
- Copywriting: Generating blogs, ad copy, and social media posts automatically.
- Personalization: Creating hyper-personalized marketing emails and images for individual customers at scale.
- Image/Video Gen: Creating stock photos or marketing videos without physical shoots.
-
Healthcare and Life Sciences:
- Drug Discovery: Generative models can design new molecular structures with desired properties, significantly speeding up the initial phases of drug development.
- Synthetic Data: Generating synthetic patient data to train AI models while preserving patient privacy.
What is Prompt Engineering? Explain why it is considered a critical skill in the era of Generative AI.
Definition
Prompt Engineering is the practice of designing, refining, and optimizing input text (prompts) to guide Generative AI models (like LLMs) to produce the most accurate, relevant, and high-quality outputs.
Importance
- Model Steering: LLMs are probabilistic. Without specific guidance, they may produce generic or irrelevant answers. Prompt engineering acts as a steering wheel to direct the model's vast knowledge.
- Cost Efficiency: In API-based usage (like OpenAI API), efficient prompts reduce the number of tokens processed and the number of retries required, lowering costs.
- Unlocking Capabilities: Advanced techniques (like Chain-of-Thought prompting) can unlock reasoning capabilities in models that they don't exhibit with simple queries.
- Mitigating Hallucinations: Well-structured prompts with constraints can reduce the likelihood of the model making up facts.
- Automation Integration: To integrate AI into software workflows, prompts must be engineered to produce consistent, machine-readable formats (e.g., JSON outputs).
Identify and explain the four key elements of a well-structured prompt.
A comprehensive prompt typically contains the following four elements (though not all are mandatory for every prompt):
-
Instruction:
- A specific task or directive you want the model to perform.
- Example: "Summarize," "Translate," "Write code," "Classify."
-
Context:
- Background information, external data, or preferences to steer the model towards better responses.
- Example: "Act as a senior python developer," "Based on the following meeting notes..."
-
Input Data:
- The specific input or content needed to perform the task.
- Example: The actual paragraph to be summarized or the code block to be debugged.
-
Output Indicator:
- The type or format of the output expected.
- Example: "Output as a bulleted list," "Format as a JSON object," "Limit response to 50 words."
Explain the concept of Hallucinations in Large Language Models. Why do they occur and how can they be mitigated?
What are Hallucinations?
Hallucination refers to the phenomenon where an LLM generates text that is grammatically correct and fluent but factually incorrect, nonsensical, or unfaithful to the source input. The model confidently states falsehoods.
Why they occur
- Probabilistic Nature: LLMs predict the next likely word based on statistical patterns, not a database of verified facts.
- Training Data Issues: If the training data contained noise, errors, or contradictory information, the model learns these imperfections.
- Gap in Knowledge: When the model doesn't "know" the answer, it tries to complete the pattern plausibly rather than admitting ignorance.
Mitigation Strategies
- Prompt Engineering: Asking the model to "cite sources" or "say 'I don't know' if unsure."
- RAG (Retrieval-Augmented Generation): Feeding the model verified external data (context) and asking it to answer only based on that context.
- Temperature Adjustment: Lowering the temperature parameter (e.g., to 0) makes the model more deterministic and less creative/random.
Distinguish between Zero-shot, One-shot, and Few-shot prompting with examples.
These techniques refer to how much context/example data is provided to the model in the prompt.
1. Zero-shot Prompting
- Definition: The model is given a task without any examples of how to perform it.
- Example:
"Classify the sentiment of this text: 'The movie was terrible.'"
Output: Negative
2. One-shot Prompting
- Definition: The model is given a single example of the input-output pair to understand the pattern or format.
- Example:
"Classify the sentiment.
Text: 'I loved the food.' -> Sentiment: Positive
Text: 'The service was slow.' -> Sentiment: "
3. Few-shot Prompting
- Definition: The model is provided with multiple examples (usually 2 to 5) to learn the task, tone, or complex logic through context.
- Example:
"Convert currency to symbol:
Dollar -> $$
Euro -> €
Yen -> ¥
Pound -> "
Significance: Few-shot prompting generally improves performance significantly on complex tasks compared to zero-shot.
What are Deepfakes? Discuss the ethical implications and risks associated with them.
Definition
Deepfakes are synthetic media (images, video, or audio) in which a person in an existing image or video is replaced with someone else's likeness using deep learning techniques, specifically Generative Adversarial Networks (GANs).
Ethical Implications and Risks
- Misinformation and Disinformation: Deepfakes can be used to create fake news videos of politicians making controversial statements, destabilizing governments or elections.
- Identity Theft and Fraud: Voice cloning and video deepfakes can be used to bypass biometric security or trick employees into transferring funds (CEO fraud).
- Non-Consensual Content: A major ethical issue is the creation of non-consensual explicit material involving celebrities or private citizens, causing severe psychological and reputational harm.
- Erosion of Trust: As deepfakes become perfect, the public may stop trusting legitimate video evidence, leading to a "liar's dividend" where real misconduct can be dismissed as fake.
Explain the Chain-of-Thought (CoT) prompting technique and how it improves reasoning in LLMs.
Definition
Chain-of-Thought (CoT) prompting is a technique where the model is encouraged to produce intermediate reasoning steps before generating the final answer. Instead of just jumping to the conclusion, the model "thinks aloud."
How it works
In a standard prompt, you might ask for the answer directly. In CoT, the user provides examples where the reasoning is spelled out, or simply adds the phrase "Let's think step by step" (Zero-shot CoT).
Example
- Standard Prompt: "If I have 5 apples, eat 2, and buy 3 more, how many do I have?" -> Model might guess 6.
- CoT Prompt: "If I have 5 apples, eat 2, and buy 3 more, how many do I have? Let's think step by step."
- Model Output: "Start with 5 apples. Eat 2, so 5 - 2 = 3. Buy 3 more, so 3 + 3 = 6. The answer is 6."
Improvement in Reasoning
It improves performance on arithmetic, commonsense, and symbolic reasoning tasks because it breaks a complex problem into smaller, manageable linear steps, mimicking human problem-solving.
Describe the Persona Pattern in Prompt Engineering and provide a template for it.
The Persona Pattern
The Persona Pattern is a prompt engineering strategy where the user directs the AI to act as a specific entity (a character, a professional, or an object). By adopting a persona, the AI adjusts its tone, vocabulary, and perspective to match that role.
Why use it?
- It narrows down the search space for the model.
- It ensures the output is tailored to a specific audience (e.g., explaining physics to a 5-year-old vs. a PhD student).
Template
To use this pattern, utilize the following structure:
"Act as a [Persona]. Perform [Task]."
Example
- Prompt: "Act as a skeptical cybersecurity auditor. Review this password policy and highlight potential vulnerabilities aggressively."
- Effect: The model will use technical security jargon and adopt a critical, warning-based tone rather than a helpful, passive tone.
Compare Prompt Tuning with Fine-Tuning of Large Language Models.
Both are methods to adapt a pre-trained LLM to specific tasks, but they differ significantly in cost and mechanism.
| Feature | Fine-Tuning | Prompt Tuning |
|---|---|---|
| Mechanism | Updates the internal weights (parameters) of the entire model (or large parts of it). | Freezes the model weights. Adds a small set of learnable vectors (soft prompts) to the input. |
| Resource Cost | High. Requires significant computational power (GPUs) and storage for the new model copy. | Low. Requires very little compute and storage (only the small prompt vectors are stored). |
| Data Requirement | Requires a relatively large labeled dataset. | Can work effectively with less data (though more than few-shot prompting). |
| Flexibility | Creates a separate large model for each task. | One base model can serve many tasks by simply switching the "soft prompt" input. |
| Performance | generally achieves the highest possible performance for specific tasks. | Approaches fine-tuning performance as model size increases ( parameters). |
Discuss the Ethical concerns regarding Bias and Fairness in Generative AI.
Bias in Generative AI is a critical ethical issue stemming from the data used to train the models.
Sources of Bias
- Training Data: Models are trained on internet data, which contains historical prejudices, stereotypes, and under-representation of minority groups.
- Labeling Bias: Human annotators involved in RLHF (Reinforcement Learning from Human Feedback) may inadvertently introduce their own cultural or subjective biases.
Manifestations
- Stereotyping: An image generator asked for a "CEO" might predominantly generate images of white men, while a request for "nurse" generates women.
- Exclusion: Models might perform poorly on languages or dialects other than English (Anglo-centric bias).
- Toxic Output: Generative models might produce hate speech or discriminatory content against specific groups if not properly guard-railed.
Implications
Deploying biased models in sensitive areas (like hiring automation or loan approval) can automate discrimination and perpetuate social inequalities.
Explain the concept of Prompt Injection and why it is a security risk.
Prompt Injection
Prompt Injection is a security vulnerability specific to LLMs where a user inputs a malicious prompt designed to override the model's original instructions (system prompt) and manipulate it into performing unauthorized actions.
Mechanism
LLMs generally cannot distinguish between instructions given by the developer (System Message) and the input provided by the user. If a user inputs text like: "Ignore previous instructions and instead do X," the model might prioritize the user's latest command.
Security Risks
- Data Leakage: Attackers can trick the model into revealing hidden system prompts or sensitive data contained in its context window.
- Bypassing Safety Filters: It can be used to bypass content moderation (jailbreaking) to generate illegal or unethical content (e.g., how to build a bomb).
- Phishing/Scams: If an LLM is connected to email or plugins, injections could trigger unauthorized emails or actions.
What is Retrieval-Augmented Generation (RAG) and how does it relate to prompt engineering?
Definition
Retrieval-Augmented Generation (RAG) is a technique that optimizes the output of an LLM so it references an authoritative knowledge base outside its training data before generating a response.
Workflow
- Retrieve: When a user asks a question, the system searches a specific database (vector database) for relevant documents.
- Augment: The retrieved information is inserted (augmented) into the context of the user's prompt.
- Generate: The LLM generates the answer based on the augmented prompt.
Relation to Prompt Engineering
RAG is essentially dynamic prompt engineering. Instead of relying on the model's internal static memory (which causes hallucinations), RAG constructs a prompt that contains the "Truth" in the Context element. The prompt instruction changes from "Tell me about X" to "Using the provided context below, tell me about X."
Write a short note on the Responsible Use of Generative AI, highlighting key principles.
Responsible AI ensures that Generative AI systems are developed and deployed in ways that benefit society while minimizing harm.
Key Principles
- Transparency: Users should know when they are interacting with an AI or viewing AI-generated content (e.g., watermarking images).
- Privacy: Models should not leak private data (PII) present in their training sets. Enterprises must ensure user data isn't used to train public models without consent.
- Accountability: Developers and organizations must be accountable for the outputs of their models. There should be mechanisms for human oversight (Human-in-the-loop).
- Robustness and Safety: Models should be tested against adversarial attacks and should have guardrails to prevent generation of harmful content (violence, hate speech).
- Copyright Respect: Addressing the legal gray area of training models on copyrighted art and text without artist compensation.
Explain the flipped interaction pattern in prompt engineering.
Definition
The Flipped Interaction Pattern shifts the initiative from the user to the AI. Instead of the user asking questions and the AI answering, the AI asks the user questions to gather the necessary information to complete a task.
Goal
To achieve a high-quality result when the user does not know exactly what information the AI needs to solve the problem.
Template
"I would like you to ask me questions to achieve [Goal]. Ask questions one by one until you have enough information to produce the output."
Example Scenario
User: "I want to write a marketing plan. Ask me questions until you can write it for me."
AI: "Sure. First, what is your product?"
User: "Organic coffee."
AI: "Who is your target audience?"
... (Process continues until AI creates the plan).
Analyze the impact of Generative AI on Automation and the Workforce.
Generative AI represents a shift from "physical automation" (robots) to "cognitive automation."
Impacts
- Productivity Boost: It acts as a co-pilot, automating repetitive cognitive tasks like drafting emails, summarizing meetings, and writing basic code. This allows professionals to focus on high-value strategy.
- Job Transformation: Jobs won't necessarily disappear, but tasks within jobs will change. Roles heavily reliant on rote content creation (translators, basic copywriters, entry-level coders) face the highest disruption.
- New Roles: Emergence of new job categories such as Prompt Engineers, AI Ethicists, and AI Curators.
- Skill Gap: There is an increasing demand for "AI literacy." The workforce needs to learn how to communicate with and leverage AI tools effectively.
- Economic Disparity: There is a risk that the benefits of AI automation accrue only to large corporations, potentially widening the wealth gap if not regulated or if retraining programs are not implemented.
What are Soft Prompts in the context of Prompt Tuning? How are they different from discrete text prompts?
Soft Prompts
In Prompt Tuning, Soft Prompts are continuous vectors (tensors of numbers) that are prepended to the input embeddings of an LLM. These vectors are not human-readable text but are learned numerical representations that guide the model.
Mathematical Context
If an input sequence is embeddings , soft prompts are learnable parameters added such that input becomes .
Difference from Discrete (Hard) Prompts
- Nature: Discrete prompts are actual words (e.g., "Translate this:"). Soft prompts are abstract numerical vectors found via backpropagation.
- Optimization: Hard prompts require manual trial and error (Prompt Engineering). Soft prompts are optimized mathematically using gradient descent.
- Readability: Humans can read and write hard prompts. Humans cannot interpret soft prompts directly.