Level 3 — ProductionResearch Frontiers & Practice

Research Frontiers & Practice

45 minutes60 marksprintable — key stays hidden on paper

Level: 3 (Production: from-scratch derivations, code-from-memory, explain-out-loud) Time Limit: 45 minutes Total Marks: 60

Instructions: Answer all questions. Show full derivations. Where code is requested, pseudo-code or framework-agnostic Python is acceptable but must be complete and runnable in spirit. Use ...... for math.


Question 1 — Contrastive Loss From Scratch (12 marks)

The SimCLR framework uses the NT-Xent (normalized temperature-scaled cross-entropy) loss. For a batch of NN images, two augmentations produce 2N2N views. For a positive pair (i,j)(i,j):

i,j=logexp(sim(zi,zj)/τ)k=12N1[ki]exp(sim(zi,zk)/τ)\ell_{i,j} = -\log \frac{\exp(\text{sim}(z_i, z_j)/\tau)}{\sum_{k=1}^{2N} \mathbb{1}_{[k \neq i]} \exp(\text{sim}(z_i, z_k)/\tau)}

where sim(u,v)=uvuv\text{sim}(u,v) = \frac{u^\top v}{\|u\|\|v\|}.

(a) Explain why the indicator 1[ki]\mathbb{1}_{[k \neq i]} excludes k=ik=i but NOT k=jk=j. (3 marks)

(b) Compute i,j\ell_{i,j} numerically for a toy case: N=2N=2 (so 2N=42N=4 views). Assume all embeddings are unit-normalized and the cosine similarities of view i=1i=1 against views {1,2,3,4}\{1,2,3,4\} are {1.0, 0.8, 0.1, 0.0}\{1.0,\ 0.8,\ 0.1,\ 0.0\} where j=2j=2 is the positive. Use τ=0.5\tau = 0.5. Give the value to 3 decimals. (6 marks)

(c) State how the total batch loss is formed from the per-pair losses. (3 marks)


Question 2 — Implementing Layer Normalization From Memory (10 marks)

(a) Write from-scratch code (NumPy) for the forward pass of LayerNorm over the last dimension, including learnable γ,β\gamma, \beta and epsilon ϵ\epsilon. (5 marks)

(b) Derive the gradient x^ixj\frac{\partial \hat{x}_i}{\partial x_j} where x^i=xiμσ2+ϵ\hat{x}_i = \frac{x_i - \mu}{\sqrt{\sigma^2 + \epsilon}} (ignore ϵ\epsilon in the derivative for simplicity), μ=1Hkxk\mu = \frac{1}{H}\sum_k x_k, σ2=1Hk(xkμ)2\sigma^2 = \frac{1}{H}\sum_k (x_k-\mu)^2. Express in terms of x^i,x^j,H,σ\hat{x}_i,\hat{x}_j,H,\sigma. (5 marks)


Question 3 — Benchmark Design & Evaluation Rigor (10 marks)

You are reviewing a paper claiming SOTA on a new benchmark.

(a) List and justify four distinct methodological red flags you would check for that threaten the validity of a SOTA claim. (4 marks)

(b) A paper reports accuracy 91.2% vs. baseline 90.8% on a test set of 2000 samples. Using the standard error of a proportion, compute the approximate 95% confidence interval half-width for a proportion near p=0.91p=0.91, and state whether the 0.4% gap is likely significant. (6 marks)


Question 4 — Federated Averaging (FedAvg) Derivation (10 marks)

(a) Given KK clients with local dataset sizes nkn_k and total n=knkn=\sum_k n_k, write the FedAvg global update rule that aggregates client weights wkt+1w_k^{t+1} into wt+1w^{t+1}. (3 marks)

(b) Show that when every client performs exactly one full-batch gradient step, FedAvg is equivalent to one step of centralized full-batch gradient descent. State the assumption required. (5 marks)

(c) Name one reason this equivalence breaks with multiple local epochs. (2 marks)


Question 5 — Neuro-Symbolic & World Models (Explain-Out-Loud) (10 marks)

(a) In two–three sentences each, explain out loud (as if to a peer) the core distinction between a neuro-symbolic system and a purely neural one, giving one concrete architectural example. (5 marks)

(b) A world model typically decomposes into an encoder, a latent dynamics/transition model, and a decoder/reward head. Explain what each component learns and why learning dynamics in latent space (rather than pixel space) is preferred. (5 marks)


Question 6 — Reproducibility & Portfolio Roadmap (8 marks)

(a) You attempt to reproduce a paper and get 87% where the paper reports 92%. List three systematic checks (beyond "check for bugs") you would perform to close the gap. (3 marks)

(b) Describe how you would structure a 6-month research portfolio to move from reproducing papers to an original contribution, naming concrete milestones. (5 marks)


Answer keyMark scheme & solutions

Question 1 (12 marks)

(a) (3 marks)

  • The loss is a softmax over similarities where ziz_i is the anchor. Including k=ik=i would put sim(zi,zi)=1\text{sim}(z_i,z_i)=1 (self-similarity, trivially maximal) in the denominator, which is meaningless as a "negative" and would dominate — hence excluded. (2)
  • k=jk=j is kept because zjz_j is the positive whose similarity forms the numerator; it must also appear in the denominator so the expression is a proper normalized probability (numerator ⊆ denominator terms). (1)

(b) (6 marks) Similarities: s={1.0,0.8,0.1,0.0}s = \{1.0, 0.8, 0.1, 0.0\}, positive j=2sij=0.8j=2 \Rightarrow s_{ij}=0.8. Exclude k=i=1k=i=1. Scale by 1/τ=21/\tau = 2:

  • numerator: exp(0.8/0.5)=exp(1.6)=4.9530\exp(0.8/0.5)=\exp(1.6)=4.9530 (2)
  • denominator (exclude k=1k=1): exp(1.6)+exp(0.2)+exp(0.0)=4.9530+1.2214+1.0000=7.1744\exp(1.6)+\exp(0.2)+\exp(0.0) = 4.9530 + 1.2214 + 1.0000 = 7.1744 (2)
  • =log(4.9530/7.1744)=log(0.69051)=0.3705\ell = -\log(4.9530/7.1744) = -\log(0.69051) = 0.3705 (2)

Answer: 1,20.370\ell_{1,2} \approx 0.370

(c) (3 marks) Sum over all 2N2N views, each acting as anchor with its own positive, and average: L=12Nk=1N[2k1,2k+2k,2k1]\mathcal{L} = \frac{1}{2N}\sum_{k=1}^{N}\big[\ell_{2k-1,2k} + \ell_{2k,2k-1}\big] Both directions of each positive pair are counted; loss is symmetric per pair but computed with each view as anchor. (3)


Question 2 (10 marks)

(a) (5 marks)

import numpy as np
def layernorm(x, gamma, beta, eps=1e-5):
    # x shape (..., H), normalize over last axis
    mu = x.mean(axis=-1, keepdims=True)
    var = x.var(axis=-1, keepdims=True)
    xhat = (x - mu) / np.sqrt(var + eps)
    return gamma * xhat + beta

Marks: mean (1), var over last axis (1), normalize (1), affine γ,β\gamma,\beta (1), eps inside sqrt (1).

(b) (5 marks) With x^i=(xiμ)/σ\hat{x}_i = (x_i-\mu)/\sigma, σ=σ2\sigma=\sqrt{\sigma^2}:

  • μxj=1H\frac{\partial \mu}{\partial x_j} = \frac{1}{H} (1)
  • σ2xj=2H(xjμ)=2Hσx^j\frac{\partial \sigma^2}{\partial x_j} = \frac{2}{H}(x_j-\mu) = \frac{2}{H}\sigma\hat{x}_j, so σxj=1Hx^j\frac{\partial \sigma}{\partial x_j} = \frac{1}{H}\hat{x}_j (1)
  • Quotient rule: x^ixj=(δij1H)σ(xiμ)1Hx^jσ2\frac{\partial \hat{x}_i}{\partial x_j} = \frac{(\delta_{ij}-\tfrac1H)\sigma - (x_i-\mu)\tfrac1H\hat{x}_j}{\sigma^2} (1)
  • Substitute xiμ=σx^ix_i-\mu = \sigma\hat{x}_i: =δij1Hσx^ix^jHσ=1σ(δij1Hx^ix^jH)= \frac{\delta_{ij}-\tfrac1H}{\sigma} - \frac{\hat{x}_i\hat{x}_j}{H\sigma} = \frac{1}{\sigma}\left(\delta_{ij} - \frac{1}{H} - \frac{\hat{x}_i\hat{x}_j}{H}\right) (2)

Question 3 (10 marks)

(a) (4 marks, 1 each)

  1. Tuning on the test set / no held-out validation — hyperparameters chosen using test data inflate results.
  2. Unfair baselines — baselines under-tuned or run with fewer epochs/compute than the proposed method.
  3. No variance reporting / single seed — no error bars; gap could be within run-to-run noise.
  4. Data leakage / contamination — train-test overlap, or pretraining data covering the benchmark. (Also accept: cherry-picked metrics, non-standard splits, missing ablations.)

(b) (6 marks)

  • Standard error of a proportion: SE=p(1p)/nSE = \sqrt{p(1-p)/n} with p=0.91p=0.91, n=2000n=2000. (1)
  • p(1p)=0.91×0.09=0.0819p(1-p)=0.91\times0.09=0.0819; /2000=4.095×105/2000 = 4.095\times10^{-5}; =0.006399\sqrt{} = 0.006399. (2)
  • 95% half-width =1.96×SE=1.96×0.006399=0.012541.25%= 1.96 \times SE = 1.96 \times 0.006399 = 0.01254 \approx 1.25\%. (2)
  • The observed gap is 0.4%0.4\%, which is smaller than the ~1.25% CI half-width of a single system (and a difference test on two proportions would give a comparable-or-larger threshold). The 0.4% gap is NOT likely statistically significant with only 2000 samples/one seed. (1)

Question 4 (10 marks)

(a) (3 marks) wt+1=k=1Knknwkt+1w^{t+1} = \sum_{k=1}^{K} \frac{n_k}{n}\, w_k^{t+1} Weighted average by local dataset size. (3)

(b) (5 marks) Assumption: all clients start the round from the same global weights wtw^t and each does one full-batch step with learning rate η\eta. (1) Local update: wkt+1=wtηgkw_k^{t+1} = w^t - \eta g_k where gk=Fk(wt)=1nkxDk(wt,x)g_k = \nabla F_k(w^t) = \frac{1}{n_k}\sum_{x\in D_k}\nabla \ell(w^t,x). (1) Aggregate: wt+1=knkn(wtηgk)=wtηknkngkw^{t+1} = \sum_k \frac{n_k}{n}(w^t - \eta g_k) = w^t - \eta \sum_k \frac{n_k}{n} g_k (1) The weighted gradient equals the global gradient: knkngk=knkn1nkxDk=1nxD=F(wt)\sum_k \frac{n_k}{n} g_k = \sum_k \frac{n_k}{n}\cdot\frac{1}{n_k}\sum_{x\in D_k}\nabla\ell = \frac{1}{n}\sum_{x\in D}\nabla\ell = \nabla F(w^t) (1) Thus wt+1=wtηF(wt)w^{t+1} = w^t - \eta\nabla F(w^t) = one centralized full-batch GD step. (1)

(c) (2 marks) With multiple local epochs, clients diverge from wtw^t (client drift): their gradients are evaluated at different points wkwtw_k \neq w^t, so the average of local updates no longer equals a single gradient at wtw^t — the equivalence breaks (worse under non-IID data).


Question 5 (10 marks)

(a) (5 marks)

  • Purely neural: everything is learned distributed representations; reasoning is implicit in weights, hard to interpret, needs lots of data. (2)
  • Neuro-symbolic: combines learned perception with explicit symbolic structure (logic rules, programs, knowledge graphs) that support compositional, verifiable reasoning and data efficiency. (2)
  • Concrete example: e.g. Neural Theorem Provers, DeepProbLog, or a VQA system where a CNN extracts objects and a differentiable program executor answers logical queries. (1)

(b) (5 marks)

  • Encoder: maps high-dim observations (pixels) to compact latent state zz. (1)
  • Latent dynamics/transition: learns zt+1=f(zt,at)z_{t+1} = f(z_t, a_t) — predicting how state evolves given actions. (1)
  • Decoder/reward head: reconstructs observations and/or predicts reward, providing training signal / grounding. (1)
  • Latent-space dynamics preferred because: pixel prediction wastes capacity on irrelevant detail; latent rollouts are far cheaper/faster for planning; and imagining trajectories in a low-dim, smooth space is more stable and generalizes better (as in Dreamer). (2)

Question 6 (8 marks)

(a) (3 marks, 1 each)

  1. Verify exact hyperparameters & schedule (LR, warmup, batch size, epochs, weight decay) — often under-reported; try author configs.
  2. Match data preprocessing/augmentation and splits precisely, plus dataset version.
  3. Account for compute/precision/seed variance — run multiple seeds, check hardware (fp16 vs fp32), effective batch size differences from distributed training. (Also accept: contact authors, check released code/checkpoints, EMA of weights.)

(b) (5 marks) Example roadmap:

  • Month 1–2: reproduce 2–3 core papers end-to-end; publish clean repos + blog write-ups (milestone: matched numbers). (1)
  • Month 3: implement a key model from scratch and ablate components to build intuition. (1)
  • Month 4: identify a gap/open problem from a survey; form a concrete hypothesis and design a benchmark/experiment. (1)
  • Month 5: run experiments with rigor (baselines, seeds, error bars); iterate. (1)
  • Month 6: write up findings (workshop paper / preprint), open-source code, present. Portfolio = repos + reproductions + one original result. (1)

[
  {"claim":"NT-Xent toy loss equals ~0.370",
   "code":"import sympy as sp\nnum=sp.exp(sp.Rational(8,10)/sp.Rational(1,2))\nden=num+sp.exp(sp.Rational(1,10)/sp.Rational(1,2))+sp.exp(0)\nl=-sp.log(num/den)\nval=float(l)\nresult=abs(val-0.370)<0.002"},
  {"claim":"Proportion SE at p=0.91,n=2000 gives 95% half-width ~0.0125",
   "code":"p=sp.Rational(91,100);n=2000\nse=sp.sqrt(p*(1-p)/n)\nhw=1.96*se\nresult=abs(float(hw)-0.01254)<0.0005"},
  {"claim":"FedAvg weighted gradient equals global gradient (symbolic identity)",
   "code":"n1,n2,g1,g2=sp.symbols('n1 n2 g1 g2')\nn=n1+n2\nweighted=(n1/n)*g1+(n2/n)*g2\nglobal_grad=(n1*g1+n2*g2)/n\nresult=sp.simplify(weighted-global_grad)==0"},
  {"claim":"LayerNorm Jacobian formula reduces correctly for i=j term",
   "code":"H,sigma,xi,xj=sp.symbols('H sigma xi xj')\nexpr=(1/sigma)*(1-sp.Rational(1,1)/H - xi*xj/H)\n# check off-diagonal (delta=0) form: -(1/sigma)*(1/H)*(1+xi*xj)\noffdiag=(1/sigma)*(0-1/H-xi*xj/H)\nexpected=-(1/(sigma*H))*(1+xi*xj)\nresult=sp.simplify(offdiag-expected)==0"}
]