✨ 2nd Edition • Enhanced & Expanded
A Practical Guide for Data Scientists & AI/ML Engineers

HEARD IN DATA SCIENCE INTERVIEWS

Over 650 Most Commonly Asked Interview Questions & Answers

Now with 1000+ Questions • Updated for the Generative AI & Agentic Era

The definitive, battle-tested interview preparation manual for modern AI practitioners. Fully modernized for today’s technical interview bar—featuring end-to-end Python 3 & PyTorch implementations, foundational mathematical derivations, transformer architectures, agentic workflows, and distributed infrastructure.

📚 1,009 Questions & 969 Answers
🐍 100% Python 3 / PyTorch
📄 380+ Pages
By Kal Mishra, Ph.D.
Heard In Data Science Interviews Book Cover
1,009
Total Questions
Spanning junior to principal levels
10
Core Technical Domains
From Math & Stats to Agentic AI
100%
Python & PyTorch
Zero legacy C++ or pseudocode
48
Foundational Citations
Chronological literature grounding
17
Architectural Figures
Clean vector system diagrams

Engineered for the Modern AI Bar

Over the past 8 years, the AI and Data Science interview landscape shifted entirely toward deep learning, Transformers, Generative AI, and distributed systems. The Second Edition has been rebuilt from the ground up to reflect current FAANG and top AI lab interview standards.

🤖

Generative AI & Agentic Systems

Dedicated chapter covering multi-stage RAG (HNSW/IVFFlat, hybrid search, Ragas evaluation), PEFT (LoRA/QLoRA parameter math), ReAct agent loops, tool calling, and alignment (DPO/GRPO).

RAG & Vector DBs LoRA / QLoRA ReAct Agents Tool Calling

Modern Deep Learning & LLMs

Deep technical coverage of Multi-Head/Grouped-Query Attention (MHA/GQA), RoPE positional embeddings, FlashAttention, State Space Models (SSMs/Mamba), Gated DeltaNet, and KV cache memory profiling.

FlashAttention RoPE KV Cache VRAM Gated DeltaNet
🐍

100% Python 3 & PyTorch Native

Complete language migration from legacy C++ to idiomatic Python 3, NumPy, and PyTorch. Includes production-ready code for model training, custom loss functions, and algorithmic solutions.

Python 3 NumPy PyTorch PySpark
📐

Rigorous Mathematical Derivations

No hand-waving. Step-by-step mathematical proofs for variance reduction (CUPED), Expectation-Maximization (EM), backpropagation gradients, Thompson Sampling, and information theory metrics.

CUPED Variance Reduction Bayesian Proofs Gradient Math
🌐

Distributed Systems & Big Data

Enterprise distributed computing architectures including PySpark 3.x execution plans, Ray actors, 3D Parallelism (Data, Tensor, Pipeline), vLLM PagedAttention, and data pipeline design.

PySpark 3.x Ray Core 3D Parallelism vLLM
🎯

Candidate-to-Interviewer Toolkit

40 strategic, high-leverage questions for candidates to reverse-interview panels—evaluating technical debt, AI safety governance, deployment maturity, and product roadmaps.

Reverse Interviewing AI Safety SLAs Leadership Fit

11 Structured Chapters + Comprehensive Solutions

Organized sequentially from core foundational principles to cutting-edge production AI systems. Every question includes a corresponding answer in the solution appendix.

📊 1,009 Questions across 11 Chapters
CH 01

Introduction & The Modern AI Interview Bar

Preface & Strategy
  • Evolution of Data Science & Machine Learning interviews (2018–2026)
  • Interview formats: Coding, ML system design, math derivations, behavioral
  • Evaluation criteria for Junior, Senior, Staff, and Principal AI roles
  • How to use this book for structured 4-week, 8-week, and 12-week preparation
CH 02

Probability & Mathematical Statistics

149 Questions
  • Discrete and Continuous Probability Distributions (Gaussian, Poisson, Beta, Dirichlet)
  • Hypothesis Testing, p-values, Type I/II errors, and Multiple Testing Corrections (FDR/Bonferroni)
  • Bayesian Inference, Conjugate Priors, Maximum Likelihood (MLE) vs MAP
  • Markov Chains, Random Walks, MCMC, and Metropolis-Hastings Sampling
  • Central Limit Theorem, Law of Large Numbers, and Chebyshev/Hoeffding Inequalities
CH 03

Classical Machine Learning & Optimization

162 Questions
  • Linear & Logistic Regression: Loss derivations, convexity, and regularization (L1/L2/ElasticNet)
  • Tree Ensembles: Random Forest, Gradient Boosted Trees (XGBoost, LightGBM, CatBoost)
  • Support Vector Machines (SVM), Kernel Trick, and Dual Optimization Formulation
  • Unsupervised Learning: K-Means, PCA, t-SNE, UMAP, and Gaussian Mixture Models (EM algorithm)
  • Evaluation Metrics: ROC-AUC, PR-AUC, F1-score, NDCG, Calibration curves, and Brier Score
CH 04

Deep Learning & Sequence Models

103 Questions
  • Attention Mechanisms: Multi-Head Attention (MHA), Multi-Query (MQA), Grouped-Query (GQA)
  • Positional Encodings: Rotary Position Embeddings (RoPE), ALiBi, and Learned Encodings
  • Memory & Speed Optimizations: FlashAttention, KV Cache sizing ($O(N)$ vs $O(1)$), TurboQuant
  • Sub-Quadratic Architectures: State Space Models (Mamba/SSM), Gated DeltaNet, Kimi Linear (KDA)
  • LLM Alignment: SFT, RLHF with PPO, Direct Preference Optimization (DPO), and GRPO
  • Distributed Training: Tensor Parallelism, Pipeline Parallelism, ZeRO / FSDP memory math
CH 05

Generative AI & Agentic Systems

128 Questions
  • Tokenization: Byte-Pair Encoding (BPE), WordPiece, SentencePiece, and vocabulary trade-offs
  • Retrieval-Augmented Generation (RAG): Hierarchical chunking, HNSW/IVFFlat, Hybrid BM25+Dense search, RRF
  • Fine-Tuning: Parameter-Efficient Fine-Tuning (LoRA rank math, QLoRA NF4 double quantization)
  • Autonomous Agents: ReAct loops, JSON Schema tool calling, short/long-term memory, LangGraph
  • AI Safety & Guardrails: Prompt injection defenses, constrained grammar decoding, watermarking
  • GenAI Evaluation: Ragas (Faithfulness, Relevance), LLM-as-a-judge, Latency vs Quality Pareto
CH 06

Data Modeling, SQL & Feature Systems

114 Questions
  • Dimensional Modeling: Star schema, Snowflake schema, Slowly Changing Dimensions (SCD Type 1/2/3)
  • Advanced SQL: Analytical window functions, recursive CTEs, sessionization, rolling aggregations
  • Feature Stores & Pipelines: Real-time vs batch features, point-in-time correctness, data leakage prevention
  • Data Quality & Drift: Population Stability Index (PSI), Wasserstein distance, anomaly detection
CH 07

Experiment Design & Online A/B Testing

86 Questions
  • Online Experimentation: Minimum Detectable Effect (MDE), sample size calculation, statistical power
  • Variance Reduction: CUPED (Controlled-experiment Using Pre-Experiment Data) mathematical derivation
  • Network Interference & Spillover: Cluster randomization, graph partitioning, switchback designs
  • Adaptive Experimentation: Multi-Armed Bandits ($\epsilon$-greedy, Upper Confidence Bound, Thompson Sampling)
  • Evaluating GenAI Features: Time-To-First-Token (TTFT) vs Model Quality trade-off experiments
CH 08

Distributed Computing & Big Data Infrastructure

94 Questions
  • PySpark Architecture: Catalyst optimizer, Tungsten execution, Narrow vs Wide transformations, broadcast joins
  • Data Skew Resolution: Salting keys, broadcast hash join thresholding, AQE (Adaptive Query Execution)
  • Distributed ML: Ray Core / Ray Train, distributed data loading, actor lifecycle
  • Distributed LLM Serving: vLLM PagedAttention, KV cache sharing, continuous batching
CH 09

Computer Science Fundamentals & Python Algorithms

139 Questions
  • Data Structures: Hash maps, Heaps/Priority Queues, Trie, Segment Trees, Graph representations
  • Algorithm Design: Dynamic Programming ($O(n)$ decoding), Two Pointers, Sliding Window, Monotonic Stacks
  • Graph Algorithms: BFS, DFS, Dijkstra, Topological Sort, Connected Components
  • Time & Space Complexity: Big-O analysis, amortized complexity, cache locality
CH 10

Behavioral, Leadership & AI Safety

50 Questions
  • STAR Method responses tailored to technical leadership and production AI incidents
  • Managing non-deterministic output behavior in Generative AI SLAs
  • AI Safety, hallucination mitigation, guardrails, and customer trust
  • Stakeholder management, trade-off communication, and cross-functional alignment
CH 11

Candidate-to-Interviewer Questions

40 Questions
  • Evaluating team engineering maturity, data governance, and compute budget
  • Probing model deployment velocity and production observability practices
  • Uncovering organizational AI strategy, research freedom, and product impact

A Preview of the Technical Depth

See how answers are structured with step-by-step mathematical reasoning, visual intuition, and production Python/PyTorch code.

Generative AI & PEFT Question 5.48 / Answer 5.48

What is Low-Rank Adaptation (LoRA)? How does parameter decomposition work mathematically, and what are the memory and inference advantages?

💡 Executive Technical Answer:

Low-Rank Adaptation (LoRA) freezes pre-trained model weights $W_0 \in \mathbb{R}^{d \times k}$ and injects trainable rank decomposition matrices into each layer of the Transformer architecture:

$$W = W_0 + \Delta W = W_0 + \frac{\alpha}{r} (B \cdot A)$$ $$\text{where } B \in \mathbb{R}^{d \times r}, \quad A \in \mathbb{R}^{r \times k}, \quad r \ll \min(d, k)$$

Key Architectural Properties:

  • Initialization: Matrix $A$ is initialized from a Gaussian distribution $\mathcal{N}(0, \sigma^2)$, while matrix $B$ is initialized to 0. Consequently, $\Delta W = B \cdot A = 0$ at the start of training, preserving the exact original model behavior.
  • Scaling Factor $\alpha$: The constant hyperparameter $\alpha$ stabilizes training when varying the rank $r$.
  • Zero Inference Latency: For production deployment, weights can be merged directly into the base weights prior to serving: $W_{\text{merged}} = W_0 + \frac{\alpha}{r}(BA)$.

PyTorch LoRA Implementation:

import torch
import torch.nn as nn

class LoRALinear(nn.Module):
    def __init__(self, in_features: int, out_features: int, rank: int = 8, alpha: float = 16.0):
        super().__init__()
        self.linear = nn.Linear(in_features, out_features, bias=False)
        self.linear.weight.requires_grad = False  # Freeze base weights
        
        self.rank = rank
        self.scaling = alpha / rank
        self.lora_A = nn.Parameter(torch.randn(rank, in_features) * 0.02)
        self.lora_B = nn.Parameter(torch.zeros(out_features, rank))  # Zero init

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        base_out = self.linear(x)
        lora_out = (x @ self.lora_A.T @ self.lora_B.T) * self.scaling
        return base_out + lora_out
Deep Learning Question 4.12 / Answer 4.12

Explain Rotary Position Embeddings (RoPE). Why is RoPE widely adopted in modern LLMs (LLaMA, Mistral, Qwen) over additive sinusoidal embeddings?

💡 Executive Technical Answer:

Rotary Position Embedding (RoPE) encodes relative positional information directly into attention query and key representations by rotating 2D feature pairs in the complex plane:

$$\mathbf{q}_m = \mathbf{R}_{\Theta, m}^d \, \mathbf{W}_q \mathbf{x}_m, \quad \mathbf{k}_n = \mathbf{R}_{\Theta, n}^d \, \mathbf{W}_k \mathbf{x}_n$$ $$\mathbf{q}_m^\top \mathbf{k}_n = \left(\mathbf{R}_{\Theta, m}^d \mathbf{q}\right)^\top \left(\mathbf{R}_{\Theta, n}^d \mathbf{k}\right) = \mathbf{q}^\top \mathbf{R}_{\Theta, n - m}^d \mathbf{k}$$

Because $\mathbf{R}_{\Theta, m}^\top \mathbf{R}_{\Theta, n} = \mathbf{R}_{\Theta, n-m}$, the inner product depends strictly on the relative distance $(m - n)$ rather than absolute positions $m$ and $n$.

Core Advantages:

  • Natural sequence length generalization via position interpolation / NTK-aware scaling.
  • Preserves vector norm while decay naturally dampens attention weights between distant tokens.
  • Zero additional parameters introduced.
Experiment Design & A/B Testing Question 7.18 / Answer 7.18

Derive the CUPED (Controlled-experiment Using Pre-Experiment Data) variance reduction estimator and the optimal covariate coefficient $\theta^*$.

💡 Executive Technical Answer:

Given an experimental metric $Y$ and a pre-experiment covariate $X$ (unaffected by treatment), the CUPED adjusted metric is:

$$Y_{\text{cuped}} = Y - \theta (X - \mathbb{E}[X])$$

Taking the variance:

$$\text{Var}(Y_{\text{cuped}}) = \text{Var}(Y) + \theta^2 \text{Var}(X) - 2\theta \text{Cov}(Y, X)$$

Setting the first derivative with respect to $\theta$ to zero yields the optimal coefficient $\theta^*$:

$$\theta^* = \frac{\text{Cov}(Y, X)}{\text{Var}(X)}$$ $$\text{Var}(Y_{\text{cuped}}^*) = \text{Var}(Y) \cdot (1 - \rho^2)$$

When correlation $\rho = 0.7$, the variance is reduced by **$49\%$**, effectively cutting required sample size (and experiment duration) in half.

System Design & Infrastructure Question 4.41 / Answer 4.41

How do you calculate the exact GPU VRAM required for KV Cache during LLM inference? Compare Multi-Head Attention (MHA) vs Grouped-Query Attention (GQA).

💡 Executive Technical Answer:

During autoregressive generation, each token stores Key and Value activation vectors for every layer:

$$\text{KV Cache Size (Bytes)} = 2 \times n_{\text{layers}} \times n_{\text{kv\_heads}} \times d_{\text{head}} \times s_{\text{seq}} \times b_{\text{bytes\_per\_elem}} \times B_{\text{batch}}$$

For a 70B model ($n_{\text{layers}}=80, d_{\text{head}}=128$, FP16 $b=2$ bytes) with context length $s=4096$ and batch size $B=16$:

  • Standard MHA ($n_{\text{kv\_heads}}=64$): $\approx \mathbf{42.95\text{ GB}}$ of pure KV Cache VRAM.
  • Grouped-Query GQA-8 ($n_{\text{kv\_heads}}=8$): $\approx \mathbf{5.37\text{ GB}}$ (an **$8\times$ memory reduction**), enabling significantly larger concurrency.

Who Is This Book For?

Designed specifically for technical practitioners aiming for top-tier roles across Big Tech, high-growth startups, quantitative hedge funds, and AI research labs.

🔬

Data Scientists & Senior Data Scientists

Master statistics, hypothesis testing, causal inference, dimensional data modeling, and predictive modeling algorithms.

🧠

Machine Learning & LLM Engineers

Ace deep learning systems, PyTorch implementation rounds, transformer optimizations, PEFT, and inference serving architectures.

🚀

Applied AI Scientists & Researchers

Connect theoretical mathematical derivations with practical production constraints, RAG evaluation, and alignment strategies.

Dr. Kalanand Mishra

Kalanand Mishra, Ph.D.

AI Scientist & Researcher • San Francisco Bay Area

Dr. Kalanand Mishra is an AI scientist and researcher with over two decades of experience bridging scientific discovery with modern machine learning. He specializes in translating cutting-edge research into mission-critical personalization, recommendation, and generative AI systems deployed at massive scale.

20+ Years AI / ML Experience Ph.D. Researcher GenAI & LLM Architecture Bay Area Tech Veteran

Publication & Catalog Details

Title Heard In Data Science Interviews
Subtitle Over 650 Most Commonly Asked Interview Questions & Answers
Edition 2nd Edition (Enhanced & Expanded, 2026)
Author Kalanand Mishra, Ph.D.
Inventory Count 1,009 Questions • 969 Detailed Answers • 40 Reverse-Interview Questions
Print Length 380+ Pages (6" x 9" Trim Size)
Code Environment Python 3.10+, NumPy, PyTorch, PySpark 3.x
Visual Figures 17 High-Resolution Architectural Vector Diagrams
Formats Available Paperback, Hardcover, Kindle / Digital eBook
Official Errata kmishra.net/books/HDSI/errata.html
Order on Amazon →