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.

06. Multimodal AI, Graph Neural Networks & Production MLOps14 min read

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.

Pedagogical StandardCourse Capstone
100% Zero-Dependency

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 DomainData CharacteristicsRecommended ModelWhy Selection WinsKey Trade-offs & Failure Modes
Tabular Regression / ClassificationMedium size (N<100kN < 100\text{k}), heterogeneous numerical & categorical featuresXGBoost / LightGBM / CatBoostHandles missing values, non-linear feature interactions, and feature scaling automatically; state-of-the-art accuracy on tabular dataWeak on unstructured raw pixel/text data; sensitive to extreme hyperparameter misconfiguration
High-Dimensional Linear DataLarge feature count (d>Nd > N), sparse text term countsLogistic Regression / ElasticNetFast training/inference; linear decision boundaries; regularized weights (L1/L2L_1 / L_2) prevent overfittingCannot capture non-linear feature interactions without explicit polynomial feature engineering
Ultra-Fast Baseline / Text FilteringDiscrete word counts, spam classificationMultinomial Naive BayesO(N⋅d)O(N \cdot d) single-pass training; requires minimal sample size; fast prediction speedsConditional independence assumption fails if features are strongly correlated
Auditable Interpretable Decision RulesSmall dataset, strict compliance/regulatory auditingCART Decision Tree (Pruned)Highly interpretable tree splits; clear IF-THEN rule structuresHigh variance; unstable split trees prone to overfitting without depth constraints
Dense Metric RetrievalLow-dimensional continuous vectors (d<20d < 20)k-NN with KD-Tree / Ball TreeNon-parametric lazy learning; adapts instantly to evolving distributionsSuffer from Curse of Dimensionality (d>20d > 20 degrades to brute-force O(N⋅d)O(N \cdot d))
Small Sample Size, Complex BoundaryComplex continuous features (N<10kN < 10\text{k})Support Vector Machine (RBF Kernel)Maximizes geometric margin; robust against overfitting via kernel trickQuadratic programming complexity O(N2⋅d)O(N^2 \cdot d) to O(N3)O(N^3) makes it unscalable for large NN

2. Deep Learning & Perception Architecture Selection Guide#

Task DomainInput ModalityRecommended ArchitectureCore MechanismPrimary Alternative & Trade-off
Image Classification / Feature ExtractionHigh-resolution 2D ImagesResNet / ConvNeXtSpatial convolutions with residual skip connections (F(x)+x\mathcal{F}(x) + x) eliminating vanishing gradientsVision Transformer (ViT): Requires massive pre-training datasets due to lack of spatial inductive bias
Sequence Encoding & Bi-directional ContextText, code tokens, molecular stringsBERT (Encoder-Only)Masked Language Modeling (MLM) with bidirectional self-attentionDecoder-Only (GPT): Sub-optimal for sentence similarity due to causal triangular attention masking
Auto-Regressive Generation & DialogueFree-form natural language textDecoder-Only Transformer (LLaMA, GPT)Causal masked self-attention predicting next-token probabilities auto-regressivelyEncoder-Decoder (T5): Effective for translation/summarization but higher serving complexity
Non-Euclidean Relational DataKnowledge graphs, citation networks, moleculesGraphSAGE / GATInductive neighborhood sampling / Dynamic self-attention weightsGCN: Transductive requirement limits execution to fixed static full adjacency matrices
Multimodal Vision-Language AlignmentPaired images and text captionsCLIP (Dual-Encoder)Contrastive InfoNCE alignment projecting vision and text to shared unit hypersphereLLaVA (Adapter): Greater conversational depth but cannot pre-compute fast vector indices

3. Generative AI, Serving & Production MLOps Matrix#

Operational GoalConstraintsOptimal Technical StackKey Architectural Mechanism
Custom Enterprise Knowledge RetrievalConstantly evolving corporate docs, zero retraining budgetHybrid RAG (Dense + BM25 + Cross-Encoder)HNSW vector index + BM25 lexical search combined via Reciprocal Rank Fusion (RRF)
Domain Adaptation & Style AlignmentSpecialized corpus, limited GPU memory budgetQLoRA (4-bit NormalFloat)Low-rank adapter matrices (ΔW=B⋅A\Delta W = B \cdot A) attached to frozen quantized base weights
Human Preference AlignmentPaired feedback dataset (yw≻yl)(y_w \succ y_l)Direct Preference Optimization (DPO)Closed-form implicit reward loss derived directly from policy ratio without training reward models
High-Throughput LLM ServingMulti-tenant GPU cluster, constrained VRAMvLLM with PagedAttentionNon-contiguous virtual memory block paging eliminating KV cache physical fragmentation
Multi-Step Tool-Using Autonomous TasksUnpredictable environment, external APIsReAct Agent with Reflexion LoopInterleaved Thought-Action-Observation loops with verbal episodic self-correction memory
Ultra-Low Latency Mobile/Edge DeploymentEmbedded devices, strict memory limitsAWQ / GPTQ INT4 + ONNX RuntimeSalient channel protection / Hessian error compensation with fused integer kernels

2. Master Mathematical Equation Reference#

1. Classification & Information Theory#

  • Sigmoid Logistic Function:
σ(z)=11+e−z,dσ(z)dz=σ(z)(1−σ(z))\sigma(z) = \frac{1}{1 + e^{-z}}, \quad \frac{d\sigma(z)}{dz} = \sigma(z)(1 - \sigma(z))
  • Softmax Categorical Function:
Softmax(zi)=ezi∑j=1Kezj,∂Softmax(zi)∂zj=Softmax(zi)(δij−Softmax(zj))\text{Softmax}(z_i) = \frac{e^{z_i}}{\sum_{j=1}^K e^{z_j}}, \quad \frac{\partial \text{Softmax}(z_i)}{\partial z_j} = \text{Softmax}(z_i)(\delta_{ij} - \text{Softmax}(z_j))
  • Cross-Entropy / Negative Log-Likelihood Loss:
LCE=−∑k=1Kyklog⁡(y^k)\mathcal{L}_{\text{CE}} = -\sum_{k=1}^K y_k \log(\hat{y}_k)
  • Shannon Entropy:
H(X)=−∑i=1np(xi)log⁡2p(xi)H(X) = -\sum_{i=1}^n p(x_i) \log_2 p(x_i)
  • Gini Impurity:
Gini(S)=1−∑k=1Cpk2\text{Gini}(S) = 1 - \sum_{k=1}^C p_k^2

2. Deep Learning Initialization & Normalization#

  • Xavier / Glorot Initialization Variance:
Var(W)=2nin+nout\text{Var}(W) = \frac{2}{n_{\text{in}} + n_{\text{out}}}
  • He / Kaiming Initialization Variance (for ReLU):
Var(W)=2nin\text{Var}(W) = \frac{2}{n_{\text{in}}}
  • Scaled Dot-Product Attention:
Attention(Q,K,V)=softmax(QKTdk)V\text{Attention}(Q, K, V) = \text{softmax}\left( \frac{Q K^T}{\sqrt{d_k}} \right) V
  • RMSNorm (Root Mean Square Normalization):
RMS(x)=1d∑i=1dxi2+ϵ,RMSNorm(x)=xRMS(x)⊙γ\text{RMS}(x) = \sqrt{\frac{1}{d} \sum_{i=1}^d x_i^2 + \epsilon}, \quad \text{RMSNorm}(x) = \frac{x}{\text{RMS}(x)} \odot \gamma

3. Reinforcement Learning & Bellman Equations#

  • Bellman Expectation Equation for Vπ(s)V^\pi(s):
Vπ(s)=∑a∈Aπ(a∣s)[R(s,a)+γ∑s′∈SP(s′∣s,a)Vπ(s′)]V^\pi(s) = \sum_{a \in \mathcal{A}} \pi(a \mid s) \left[ R(s, a) + \gamma \sum_{s' \in \mathcal{S}} P(s' \mid s, a) V^\pi(s') \right]
  • Bellman Optimality Equation for Q∗(s,a)Q^*(s, a):
Q∗(s,a)=R(s,a)+γ∑s′∈SP(s′∣s,a)max⁡a′∈AQ∗(s′,a′)Q^*(s, a) = R(s, a) + \gamma \sum_{s' \in \mathcal{S}} P(s' \mid s, a) \max_{a' \in \mathcal{A}} Q^*(s', a')
  • Policy Gradient Theorem:
∇θJ(θ)=Eτ∼πθ[∑t=0T∇θlog⁡πθ(at∣st)Gt]\nabla_\theta J(\theta) = \mathbb{E}_{\tau \sim \pi_\theta} \left[ \sum_{t=0}^T \nabla_\theta \log \pi_\theta(a_t \mid s_t) G_t \right]
  • PPO Clipped Surrogate Objective:
LCLIP(θ)=E^t[min⁡(rt(θ)A^t, clip(rt(θ),1−ϵ,1+ϵ)A^t)]L^{\text{CLIP}}(\theta) = \hat{\mathbb{E}}_t \left[ \min\left( r_t(\theta)\hat{A}_t, \, \text{clip}(r_t(\theta), 1 - \epsilon, 1 + \epsilon)\hat{A}_t \right) \right]

4. Multimodal, GNNs & Systems Optimization#

  • Symmetric InfoNCE Contrastive Loss (CLIP):
LCLIP=−12N∑i=1N[log⁡exp⁡(sii/τ)∑kexp⁡(sik/τ)+log⁡exp⁡(sii/τ)∑kexp⁡(ski/τ)]\mathcal{L}_{\text{CLIP}} = -\frac{1}{2N} \sum_{i=1}^N \left[ \log \frac{\exp(s_{ii}/\tau)}{\sum_k \exp(s_{ik}/\tau)} + \log \frac{\exp(s_{ii}/\tau)}{\sum_k \exp(s_{ki}/\tau)} \right]
  • GCN Renormalized Layer:
H(l+1)=σ(D~−1/2A~D~−1/2H(l)W(l)),A~=A+INH^{(l+1)} = \sigma \left( \tilde{D}^{-1/2} \tilde{A} \tilde{D}^{-1/2} H^{(l)} W^{(l)} \right), \quad \tilde{A} = A + I_N
  • KV Cache VRAM Consumption:
Bytes per Token=2×nlayers×nkv_heads×dhead×Pbytes\text{Bytes per Token} = 2 \times n_{\text{layers}} \times n_{\text{kv\_heads}} \times d_{\text{head}} \times P_{\text{bytes}}
  • Uniform Affine Quantization:
q=clamp(round(xS)+Z, qmin⁡, qmax⁡),S=xmax⁡−xmin⁡qmax⁡−qmin⁡q = \text{clamp}\left( \text{round}\left( \frac{x}{S} \right) + Z, \, q_{\min}, \, q_{\max} \right), \quad S = \frac{x_{\max} - x_{\min}}{q_{\max} - q_{\min}}

3. High-Frequency Technical Interview Scenarios & Master Responses#

Architecture Diagram
Rendering diagram...

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:

  1. 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.
  2. Mitigation 1 (Parameter Isolation): Employ LoRA (Low-Rank Adaptation). Freezing the base model parameters W0W_0 entirely guarantees that general knowledge encoded in W0W_0 remains pristine, while task adaptation is constrained to low-rank delta matrices ΔW=B⋅A\Delta W = B \cdot A.
  3. Mitigation 2 (Replay Mixture): Blend 10% to 20% of general domain pre-training data into the fine-tuning dataset to anchor the loss landscape.
  4. Mitigation 3 (KL Penalty): Add a Kullback-Leibler divergence penalty against the frozen reference model: Ltotal=Ltask+βDKL(πθ∥πref)\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{task}} + \beta D_{\text{KL}}(\pi_\theta \parallel \pi_{\text{ref}}).

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 max⁡a′Q(s′,a′)\max_{a'} Q(s', a'). Since the maximum operator g(x)=max⁡axag(x) = \max_a x_a is convex, Jensen's inequality guarantees that:
E[max⁡aQ^(s,a)]≥max⁡aE[Q^(s,a)]\mathbb{E}\left[ \max_a \hat{Q}(s, a) \right] \ge \max_a \mathbb{E}\left[ \hat{Q}(s, a) \right]

Even if the estimates Q^(s,a)\hat{Q}(s, a) 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:
YtDouble=R+γQ(S′,arg⁡max⁡a′Q(S′,a′;θ);θ−)Y_t^{\text{Double}} = R + \gamma Q\left(S', \arg\max_{a'} Q(S', a'; \theta); \theta^-\right)

The online network θ\theta selects the best action candidate, while the frozen target network θ−\theta^- evaluates its value. Overestimations in θ\theta do not correlate with overestimations in θ−\theta^-, 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 π∗\pi^* can be expressed analytically as a function of the ground-truth reward:
r(x,y)=βlog⁡π∗(y∣x)πref(y∣x)+βlog⁡Z(x)r(x, y) = \beta \log \frac{\pi^*(y \mid x)}{\pi_{\text{ref}}(y \mid x)} + \beta \log Z(x)

Substituting this identity directly into the Bradley-Terry likelihood eliminates the reward model entirely, yielding the closed-form DPO objective:

LDPO(θ)=−E(x,yw,yl)[log⁡σ(βlog⁡πθ(yw∣x)πref(yw∣x)−βlog⁡πθ(yl∣x)πref(yl∣x))]\mathcal{L}_{\text{DPO}}(\theta) = -\mathbb{E}_{(x, y_w, y_l)} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(y_w \mid x)}{\pi_{\text{ref}}(y_w \mid x)} - \beta \log \frac{\pi_\theta(y_l \mid x)}{\pi_{\text{ref}}(y_l \mid x)} \right) \right]

DPO trains stably with standard binary cross-entropy on the policy network alone, cutting GPU VRAM requirements in half.

4. Final Curriculum Knowledge Check#

Concept 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."

:::

Concept check

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."

:::

Finished reading this lesson?