DevInterviewMasterStart free →
AI & AutomationFree to read

AI/ML Overview & Key Concepts

The Complete Mental Model for AI, ML, and Deep Learning

Understand the fundamental hierarchy of AI, Machine Learning, and Deep Learning. Build a rock-solid mental model before diving into LLMs and advanced topics.

What is AI, ML, and Deep Learning?

The Nested Hierarchy - AI > ML > DL > GenAI

Artificial Intelligence (AI)

AI is the broadest term. It refers to any system that can perform tasks that normally require human intelligence. This includes everything from a simple rule-based chess engine to GPT-4. Even an if-else spam filter is technically AI.

Think of AI as the entire universe. Every smart system lives inside this universe.

Machine Learning (ML)

ML is a subset of AI where systems learn from data instead of being explicitly programmed. Instead of writing rules, you feed data and the algorithm discovers patterns itself.

Example: Instead of writing 1000 rules to detect spam, you give 10,000 emails labeled as spam/not-spam, and the ML model learns the patterns automatically.

Deep Learning (DL)

DL is a subset of ML that uses neural networks with many layers (hence "deep"). These networks can learn incredibly complex patterns from raw data - images, audio, text.

Why "deep"? Because the neural network has multiple hidden layers. A network with 2 layers is shallow. GPT-4 has 120+ layers - that is deep!

Generative AI (GenAI)

GenAI is a subset of Deep Learning focused on creating new content - text, images, code, music, video. ChatGPT, DALL-E, Midjourney, GitHub Copilot are all GenAI.

The hierarchy: AI > ML > Deep Learning > Generative AI > LLMs

Note: Remember the nesting: AI is the biggest circle, ML fits inside it, DL fits inside ML, and GenAI/LLMs fit inside DL. Every LLM is AI, but not every AI is an LLM.

Types of Machine Learning

The Three Main Approaches to Learning from Data

1. Supervised Learning - Learning with a Teacher

You give the model labeled data (input + correct answer pairs). The model learns the mapping from input to output.

Analogy: Like a student solving math problems from a textbook that has answer keys. They practice on known questions, then take the exam (unseen data).

  • Classification: Is this email spam or not? (Categories)
  • Regression: What will this house sell for? (Numbers)

Real-world: Flipkart product recommendation, Swiggy delivery time prediction, bank fraud detection

2. Unsupervised Learning - Finding Hidden Patterns

You give the model unlabeled data and it discovers patterns, groups, or structure on its own. No answer key provided.

Analogy: Like sorting a pile of unsorted clothes - you naturally group them by type, color, or season without anyone telling you the categories.

  • Clustering: Group similar customers together
  • Dimensionality Reduction: Compress data while keeping important patterns
  • Anomaly Detection: Find unusual patterns (fraudulent transactions)

3. Reinforcement Learning - Learning by Trial and Error

An agent takes actions in an environment and receives rewards or penalties. It learns to maximize total reward over time.

Analogy: Like training a dog - give treats for good behavior, no treat for bad. The dog learns which actions get rewards.

Fun fact: RLHF (Reinforcement Learning from Human Feedback) is what makes ChatGPT helpful and safe. Humans rate responses, and the model learns to produce better ones.

4. Self-Supervised Learning - The Secret Behind LLMs

The model creates its own labels from the data. For text, it masks a word and tries to predict it. This is how BERT and GPT are pre-trained on billions of web pages.

This is the most important learning paradigm for modern AI because it allows training on massive unlabeled data from the internet.

Note: LLMs use self-supervised pre-training (predict next word) followed by supervised fine-tuning (instruction following) and RLHF (human preference alignment). It is a combination of all approaches!

Neural Networks - The Building Blocks

How Machines Actually Learn

What is a Neural Network?

A neural network is a mathematical model inspired by (but not identical to) the human brain. It is made of layers of neurons (nodes) connected by weights. Data flows through these layers, getting transformed at each step.

Simple analogy: Imagine a series of filters. Raw water (input data) passes through filter 1, then filter 2, then filter 3. Each filter removes different impurities. The final output is clean water (prediction). The network learns what each filter should do.

Key Components:

  • Neurons: Mathematical functions that take inputs, multiply by weights, add bias, apply activation function
  • Weights: Numbers that determine how important each input is. These are what the network "learns"
  • Bias: An extra number added to shift the output. Like the y-intercept in y = mx + b
  • Activation Function: Introduces non-linearity (ReLU, Sigmoid, Tanh). Without this, the entire network would just be one big linear equation
  • Loss Function: Measures how wrong the prediction is. The goal is to minimize this

How Training Works - Backpropagation:

  1. Forward Pass: Data flows through the network, producing a prediction
  2. Calculate Loss: Compare prediction with actual answer. How wrong are we?
  3. Backward Pass: Calculate how each weight contributed to the error
  4. Update Weights: Adjust weights to reduce the error (using gradient descent)
  5. Repeat: Do this millions of times with different data. Weights gradually improve

Key insight: A neural network does not "understand" anything. It is just finding numerical patterns that minimize prediction errors. But those patterns can be incredibly powerful.

Types of Neural Networks:

TypeBest ForExample
Feedforward (MLP)Tabular dataPredict house prices
CNNImages, spatial dataImage classification
RNN/LSTMSequential dataOld text generation
TransformerText, multimodalGPT, BERT, Claude
GANImage generationFace generation
DiffusionImage/video genStable Diffusion, DALL-E

Note: Transformers have largely replaced RNNs for text tasks. Understanding the Transformer architecture is critical for anyone working with LLMs - we cover this in detail in the next topics.

Key AI/ML Terminology You Must Know

The Vocabulary of AI - From Parameters to Fine-Tuning

Model & Training Terms:

  • Parameters: The learned numbers (weights + biases) in a model. GPT-4 has ~1.8 trillion. More parameters = more capacity to learn patterns
  • Hyperparameters: Settings YOU choose before training: learning rate, batch size, number of layers. These are NOT learned by the model
  • Epoch: One complete pass through the entire training dataset
  • Batch Size: How many examples the model sees before updating weights. Bigger batch = more stable but slower
  • Learning Rate: How big of a step to take when updating weights. Too big = overshoots, too small = painfully slow
  • Overfitting: Model memorizes training data but fails on new data. Like a student who memorizes answers instead of understanding concepts
  • Underfitting: Model is too simple to capture the patterns. Like using a straight line to fit circular data

LLM-Specific Terms:

  • Pre-training: Training on massive text data to learn language (self-supervised, very expensive)
  • Fine-tuning: Taking a pre-trained model and training it further on specific task data (cheaper, focused)
  • RLHF: Using human feedback to align model behavior with human preferences
  • Inference: Using a trained model to make predictions. This is what happens when you chat with ChatGPT
  • Token: The basic unit of text for LLMs. Roughly 3/4 of a word in English
  • Context Window: Maximum number of tokens the model can process at once (input + output)
  • Temperature: Controls randomness. 0 = deterministic, 1 = creative, 2 = chaotic
  • Hallucination: When a model confidently generates false information

Evaluation Terms:

  • Accuracy: % of correct predictions. Simple but can be misleading for imbalanced datasets
  • Precision: Of all items predicted as positive, how many actually were? (Spam filter: of flagged emails, how many were really spam?)
  • Recall: Of all actually positive items, how many did we catch? (Of all spam emails, how many did we catch?)
  • F1 Score: Harmonic mean of precision and recall. Balanced metric
  • Perplexity: How surprised the model is by the text. Lower = better language understanding

Note: You do not need to memorize all terms at once. Keep this as a reference and revisit as you encounter these concepts in practice.

AI/ML in the Real World - Indian Tech Examples

How Indian Companies Use AI/ML Every Day

Swiggy / Zomato - Food Delivery AI

  • ETA Prediction: Supervised ML predicts delivery time based on distance, traffic, restaurant prep time, weather
  • Recommendation: Collaborative filtering suggests restaurants you might like based on similar users
  • Route Optimization: Reinforcement learning optimizes delivery routes for multiple orders
  • Fraud Detection: Anomaly detection catches fake orders and promo abuse

Flipkart / Amazon India

  • Search Ranking: ML models rank products by relevance, popularity, and your purchase history
  • Dynamic Pricing: Adjusts prices based on demand, competition, and inventory
  • Review Analysis: NLP sentiment analysis summarizes thousands of reviews
  • Warehouse Optimization: Predicts which products to stock where for faster delivery

Paytm / PhonePe - Fintech AI

  • Fraud Detection: Real-time anomaly detection on every transaction
  • Credit Scoring: ML models assess creditworthiness using transaction patterns
  • Chatbot: NLP-powered customer support handling millions of queries
  • KYC Verification: Computer vision verifies Aadhaar, PAN card photos automatically

IRCTC - Railway AI

  • Dynamic Pricing: Tatkal and Vande Bharat use demand-based pricing
  • Waitlist Prediction: ML predicts RAC/waitlist confirmation probability
  • Chatbot (DISHA): NLP bot answers PNR, schedule, and fare queries

Note: AI/ML is not just for big tech. Every major Indian platform uses ML for recommendations, fraud detection, and operational optimization.

Common Misconceptions About AI

What AI Is NOT - Separating Hype from Reality

Myth 1: AI Understands Like Humans

Current AI systems (including GPT-4 and Claude) do NOT understand anything. They are incredibly sophisticated pattern matchers. They predict the next token based on statistical patterns in training data. This is powerful, but it is not understanding.

Myth 2: More Data Always Means Better Models

Quality matters more than quantity. Training on toxic, biased, or low-quality data produces toxic, biased, low-quality models. Garbage in, garbage out applies here more than ever.

Myth 3: AI Will Replace All Developers

AI is a tool amplifier, not a replacement. It makes good developers 10x more productive. But someone still needs to understand requirements, design systems, handle edge cases, and take responsibility for production systems. The nature of work changes, not the need for engineers.

Myth 4: AGI is Coming Next Year

AGI (Artificial General Intelligence) - a system that can do any intellectual task a human can - is still an open research problem. Current AI is "narrow" - amazing at specific tasks but cannot generalize like humans. We do not know when or if AGI will arrive.

Note: Be skeptical of AI hype. Understanding limitations is just as important as understanding capabilities. In interviews, showing you know what AI CANNOT do is often more impressive than listing what it can.

Interview Questions

Q: What is the difference between AI, ML, and Deep Learning?

AI is the broadest term - any system mimicking human intelligence. ML is a subset of AI where systems learn from data. Deep Learning is a subset of ML using multi-layer neural networks. The hierarchy is AI > ML > DL > GenAI > LLMs.

Q: Explain supervised vs unsupervised vs reinforcement learning.

Supervised: Learns from labeled data (input-output pairs). Unsupervised: Finds hidden patterns in unlabeled data (clustering, anomaly detection). Reinforcement: Agent learns by trial-and-error, maximizing rewards in an environment. LLMs use a combination: self-supervised pre-training + supervised fine-tuning + RLHF.

Q: What is overfitting, and how do you prevent it?

Overfitting is when a model memorizes training data but fails on new data. Prevention: (1) More diverse training data, (2) Regularization (dropout, L1/L2), (3) Early stopping, (4) Cross-validation, (5) Data augmentation. For LLMs, overfitting shows up as verbatim memorization of training text.

Q: What is the role of RLHF in modern LLMs?

RLHF (Reinforcement Learning from Human Feedback) is a crucial post-training step. Human raters rank model responses. A reward model learns these preferences. The LLM is then fine-tuned to maximize the reward model score. This is what makes LLMs helpful, harmless, and honest rather than just predicting likely text.

Q: What is the difference between inference and training?

Training is the process of learning - adjusting model weights by processing data, computing loss, and backpropagating. It requires massive compute (thousands of GPUs, weeks/months). Inference is using the trained model to make predictions. It is much cheaper and faster. When you chat with ChatGPT, that is inference.

Frequently Asked Questions

What is AI/ML Overview & Key Concepts?

Understand the fundamental hierarchy of AI, Machine Learning, and Deep Learning. Build a rock-solid mental model before diving into LLMs and advanced topics.

How does AI/ML Overview & Key Concepts work?

The Nested Hierarchy - AI > ML > DL > GenAI Artificial Intelligence (AI) AI is the broadest term. It refers to any system that can perform tasks that normally require human intelligence .

Browse all AI & Automation topics →

Practice this on DevInterviewMaster

Read the full AI/ML Overview & Key Concepts breakdown with interactive demos, quizzes, and Hinglish notes.

Open the interactive topic →

800+ system-design, LLD, coding, and design-pattern topics. Unlock everything with Pro (₹499, one-time) or Ultimate (₹999, one-time) — lifetime access, no subscription.