Comprehensive AI Architecture Matrices & Interview Mastery
Master end-to-end algorithm decision matrices, mathematical formula cheat sheets, and high-frequency technical interview question breakdowns across all 6 course modules.
This master reference synthesizes the core mathematical derivations, algorithmic implementations, and architectural decisions across the entire AI & Machine Learning Engineering Curriculum.
Whether designing enterprise AI platforms, optimizing low-latency LLM serving runtimes, or defending design decisions in technical interviews, this guide provides the definitive comparative matrices and mathematical identity cheat sheets.
From linear classifiers to PagedAttention and PPO, every algorithm in this curriculum was derived algebraically and implemented from first principles.
1. End-to-End Algorithmic Decision Matrices ("When to Use What")#
1. Classical Machine Learning Selection Guide#
| Problem Domain | Data Characteristics | Recommended Model | Why Selection Wins | Key Trade-offs & Failure Modes |
|---|---|---|---|---|
| Tabular Regression / Classification | Medium size (), heterogeneous numerical & categorical features | XGBoost / LightGBM / CatBoost | Handles missing values, non-linear feature interactions, and feature scaling automatically; state-of-the-art accuracy on tabular data | Weak on unstructured raw pixel/text data; sensitive to extreme hyperparameter misconfiguration |
| High-Dimensional Linear Data | Large feature count (), sparse text term counts | Logistic Regression / ElasticNet | Fast training/inference; linear decision boundaries; regularized weights () prevent overfitting | Cannot capture non-linear feature interactions without explicit polynomial feature engineering |
| Ultra-Fast Baseline / Text Filtering | Discrete word counts, spam classification | Multinomial Naive Bayes | single-pass training; requires minimal sample size; fast prediction speeds | Conditional independence assumption fails if features are strongly correlated |
| Auditable Interpretable Decision Rules | Small dataset, strict compliance/regulatory auditing | CART Decision Tree (Pruned) | Highly interpretable tree splits; clear IF-THEN rule structures | High variance; unstable split trees prone to overfitting without depth constraints |
| Dense Metric Retrieval | Low-dimensional continuous vectors () | k-NN with KD-Tree / Ball Tree | Non-parametric lazy learning; adapts instantly to evolving distributions | Suffer from Curse of Dimensionality ( degrades to brute-force ) |
| Small Sample Size, Complex Boundary | Complex continuous features () | Support Vector Machine (RBF Kernel) | Maximizes geometric margin; robust against overfitting via kernel trick | Quadratic programming complexity to makes it unscalable for large |
2. Deep Learning & Perception Architecture Selection Guide#
| Task Domain | Input Modality | Recommended Architecture | Core Mechanism | Primary Alternative & Trade-off |
|---|---|---|---|---|
| Image Classification / Feature Extraction | High-resolution 2D Images | ResNet / ConvNeXt | Spatial convolutions with residual skip connections () eliminating vanishing gradients | Vision Transformer (ViT): Requires massive pre-training datasets due to lack of spatial inductive bias |
| Sequence Encoding & Bi-directional Context | Text, code tokens, molecular strings | BERT (Encoder-Only) | Masked Language Modeling (MLM) with bidirectional self-attention | Decoder-Only (GPT): Sub-optimal for sentence similarity due to causal triangular attention masking |
| Auto-Regressive Generation & Dialogue | Free-form natural language text | Decoder-Only Transformer (LLaMA, GPT) | Causal masked self-attention predicting next-token probabilities auto-regressively | Encoder-Decoder (T5): Effective for translation/summarization but higher serving complexity |
| Non-Euclidean Relational Data | Knowledge graphs, citation networks, molecules | GraphSAGE / GAT | Inductive neighborhood sampling / Dynamic self-attention weights | GCN: Transductive requirement limits execution to fixed static full adjacency matrices |
| Multimodal Vision-Language Alignment | Paired images and text captions | CLIP (Dual-Encoder) | Contrastive InfoNCE alignment projecting vision and text to shared unit hypersphere | LLaVA (Adapter): Greater conversational depth but cannot pre-compute fast vector indices |
3. Generative AI, Serving & Production MLOps Matrix#
| Operational Goal | Constraints | Optimal Technical Stack | Key Architectural Mechanism |
|---|---|---|---|
| Custom Enterprise Knowledge Retrieval | Constantly evolving corporate docs, zero retraining budget | Hybrid RAG (Dense + BM25 + Cross-Encoder) | HNSW vector index + BM25 lexical search combined via Reciprocal Rank Fusion (RRF) |
| Domain Adaptation & Style Alignment | Specialized corpus, limited GPU memory budget | QLoRA (4-bit NormalFloat) | Low-rank adapter matrices () attached to frozen quantized base weights |
| Human Preference Alignment | Paired feedback dataset | Direct Preference Optimization (DPO) | Closed-form implicit reward loss derived directly from policy ratio without training reward models |
| High-Throughput LLM Serving | Multi-tenant GPU cluster, constrained VRAM | vLLM with PagedAttention | Non-contiguous virtual memory block paging eliminating KV cache physical fragmentation |
| Multi-Step Tool-Using Autonomous Tasks | Unpredictable environment, external APIs | ReAct Agent with Reflexion Loop | Interleaved Thought-Action-Observation loops with verbal episodic self-correction memory |
| Ultra-Low Latency Mobile/Edge Deployment | Embedded devices, strict memory limits | AWQ / GPTQ INT4 + ONNX Runtime | Salient channel protection / Hessian error compensation with fused integer kernels |
2. Master Mathematical Equation Reference#
1. Classification & Information Theory#
- Sigmoid Logistic Function:
- Softmax Categorical Function:
- Cross-Entropy / Negative Log-Likelihood Loss:
- Shannon Entropy:
- Gini Impurity:
2. Deep Learning Initialization & Normalization#
- Xavier / Glorot Initialization Variance:
- He / Kaiming Initialization Variance (for ReLU):
- Scaled Dot-Product Attention:
- RMSNorm (Root Mean Square Normalization):
3. Reinforcement Learning & Bellman Equations#
- Bellman Expectation Equation for :
- Bellman Optimality Equation for :
- Policy Gradient Theorem:
- PPO Clipped Surrogate Objective:
4. Multimodal, GNNs & Systems Optimization#
- Symmetric InfoNCE Contrastive Loss (CLIP):
- GCN Renormalized Layer:
- KV Cache VRAM Consumption:
- Uniform Affine Quantization:
3. High-Frequency Technical Interview Scenarios & Master Responses#
Scenario 1: Mitigating Catastrophic Forgetting in LLMs#
Question: "When fine-tuning a foundation model on proprietary legal documents, performance on general reasoning collapses. How do you detect and mitigate this?"
Master Response:
- Diagnosis: Measure downstream performance on standard general benchmarks (MMLU, GSM8k) concurrently with legal task evaluation. The degradation stems from large unconstrained weight updates that disrupt pre-trained representations.
- Mitigation 1 (Parameter Isolation): Employ LoRA (Low-Rank Adaptation). Freezing the base model parameters entirely guarantees that general knowledge encoded in remains pristine, while task adaptation is constrained to low-rank delta matrices .
- Mitigation 2 (Replay Mixture): Blend 10% to 20% of general domain pre-training data into the fine-tuning dataset to anchor the loss landscape.
- Mitigation 3 (KL Penalty): Add a Kullback-Leibler divergence penalty against the frozen reference model: .
Scenario 2: Double Q-Learning vs Standard Q-Learning#
Question: "Prove why Q-learning overestimates action values, and explain how Double DQN resolves this mathematically."
Master Response:
- Mechanism: The target in Q-learning contains the term . Since the maximum operator is convex, Jensen's inequality guarantees that:
Even if the estimates have zero-mean unbiased noise, the expected value of their maximum is strictly greater than the maximum of their true expectations.
- Resolution: Double DQN decouples action selection from action evaluation:
The online network selects the best action candidate, while the frozen target network evaluates its value. Overestimations in do not correlate with overestimations in , eliminating the systematic positive bias.
Scenario 3: DPO vs PPO in LLM Alignment#
Question: "Why has Direct Preference Optimization (DPO) largely replaced PPO in modern LLM alignment pipelines?"
Master Response:
- PPO Complexity: Standard RLHF with PPO requires loading four distinct large models into GPU memory simultaneously: the Actor (policy being trained), Critic (value network), Reference Model (frozen base for KL penalty), and Reward Model. It also suffers from high training instability and sensitive hyperparameter tuning.
- DPO Innovation: Rafailov et al. proved mathematically that under the Bradley-Terry preference model, the optimal policy can be expressed analytically as a function of the ground-truth reward:
Substituting this identity directly into the Bradley-Terry likelihood eliminates the reward model entirely, yielding the closed-form DPO objective:
DPO trains stably with standard binary cross-entropy on the policy network alone, cutting GPU VRAM requirements in half.
4. Final Curriculum Knowledge Check#
Question
question: "In high-throughput LLM serving, what is the primary difference between the roles of FlashAttention and PagedAttention?"
options:
- "(Recommended) FlashAttention optimizes GPU SRAM/HBM IO memory access during dense attention computation, while PagedAttention eliminates physical VRAM fragmentation of the KV cache across multi-tenant sequences"
- "FlashAttention is for text while PagedAttention is for images"
- "PagedAttention trains the model while FlashAttention only works during inference"
- "FlashAttention quantizes weights to 4 bits while PagedAttention uses 16 bits"
explanation: "FlashAttention is an exact IO-aware attention kernel that computes softmax without materializing the N x N attention matrix into slow HBM. PagedAttention is a memory management architecture for serving engines (vLLM) that allocates KV cache in non-contiguous virtual memory blocks, eliminating allocation waste."
:::
Question
question: "Under the Message Passing Neural Network (MPNN) framework, why must the neighborhood aggregation operator be permutation invariant?"
options:
- "(Recommended) Because nodes in an undirected graph have no canonical or natural ordering; swapping the arbitrary indexing of neighboring nodes must not alter the resulting representation"
- "Because permutation invariance guarantees that the adjacency matrix is invertible"
- "Because it prevents models from generating complex numbers"
- "Because gradient descent cannot optimize non-symmetric matrices"
explanation: "Graph topology is fundamentally unordered. If aggregation were sensitive to permutation (like standard sequence RNNs), relabeling the arbitrary indices of neighboring nodes would alter the node's updated representation, violating graph isomorphism."
:::