Level 5 — MasteryResearch Frontiers & Practice

Research Frontiers & Practice

90 minutes60 marksprintable — key stays hidden on paper

Level: 5 — Mastery (cross-domain: math + coding + systems reasoning) Time limit: 90 minutes Total marks: 60

Instructions: Answer all three questions. Show full derivations. Where code is requested, pseudocode with correct tensor shapes and complexity annotations is acceptable. Use ...... / ...... for mathematics.


Question 1 — Contrastive Learning: Deriving and Implementing InfoNCE (22 marks)

SimCLR trains an encoder using the normalized temperature-scaled cross-entropy (NT-Xent) loss. For a batch of NN images, each is augmented twice to form 2N2N views. Let ziz_i be the 2\ell_2-normalized embedding of view ii, and sim(u,v)=uv\mathrm{sim}(u,v)=u^\top v (cosine similarity since normalized). 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(\mathrm{sim}(z_i,z_j)/\tau)}{\sum_{k=1}^{2N}\mathbf{1}_{[k\neq i]}\exp(\mathrm{sim}(z_i,z_k)/\tau)}

(a) Prove that i,j\ell_{i,j} is a lower bound related to mutual information; specifically, show that the expected InfoNCE loss satisfies E[]log(K)I(zi;zj),\mathbb{E}[\ell] \geq \log(K) - I(z_i; z_j), where KK is the number of terms in the denominator, and hence minimizing InfoNCE maximizes a lower bound on mutual information. State each assumption used. (7)

(b) Show that the gradient of i,j\ell_{i,j} with respect to the positive logit and the temperature τ\tau behaves as follows: as τ0+\tau \to 0^+, the loss becomes dominated by the single hardest negative. Derive i,jsim(zi,zk)\frac{\partial \ell_{i,j}}{\partial \,\mathrm{sim}(z_i,z_k)} for a negative kk and interpret the τ\tau dependence. (7)

(c) Write vectorized pseudocode (batch of 2N2N embeddings) computing the full NT-Xent loss. State the time and memory complexity in terms of NN and embedding dim dd, and explain why the diagonal must be masked. (8)


Question 2 — Federated Learning: Convergence & Privacy Accounting (20 marks)

Consider FedAvg over MM clients, each with local objective Fm(w)F_m(w) and global objective F(w)=m=1MpmFm(w)F(w)=\sum_{m=1}^{M}p_m F_m(w) with pm=1\sum p_m = 1. Each round runs EE local SGD steps with learning rate η\eta.

(a) Assume each FmF_m is LL-smooth and μ\mu-strongly convex, and define data heterogeneity Γ=FmpmFm0\Gamma = F^\star - \sum_m p_m F_m^\star \geq 0. Explain analytically why increasing EE (more local steps) can increase the gap to the global optimum, and identify the term in the FedAvg convergence bound responsible ("client drift"). Derive the expression for the drift of a single client's weights after EE steps relative to the global model, to first order. (8)

(b) A federated system adds Gaussian noise N(0,σ2C2I)\mathcal{N}(0,\sigma^2 C^2 I) to clipped per-client updates (clip norm CC) for (ε,δ)(\varepsilon,\delta)-differential privacy. Using the Gaussian mechanism bound σC2ln(1.25/δ)ε\sigma \geq \frac{C\sqrt{2\ln(1.25/\delta)}}{\varepsilon}, compute the minimum σ\sigma for ε=1.0\varepsilon=1.0, δ=105\delta=10^{-5}, C=1.0C=1.0. Then state how the noise scales the variance term in the convergence bound and the resulting privacy–utility tradeoff. (7)

(c) Contrast FedAvg with a neuro-symbolic federated design where clients share symbolic rules rather than gradients. Give one concrete advantage for communication cost and one hard open problem (e.g., rule conflict resolution). (5)


Question 3 — Reproducibility & Benchmark Rigor (18 marks)

You are reviewing a paper claiming a new self-supervised vision-language model (CLIP-style) beats the prior SOTA by "+2.1% zero-shot ImageNet accuracy."

(a) The paper reports a single run. Given a test set of n=50000n=50000 images and observed accuracy p^=0.751\hat{p}=0.751, compute the 95% Wald confidence interval half-width and judge whether a +2.1%+2.1\% claim is statistically distinguishable from noise on this test set. (6)

(b) Design a rigorous reproduction protocol. List five distinct controls (seeds, compute-matched baselines, data leakage checks between pretraining corpus and eval set, hyperparameter search parity, reporting variance). For each, state the failure it prevents. (7)

(c) The authors trained on a web-scraped corpus that may contain ImageNet test images (contrastive-language duplicates). Propose a quantitative deduplication + leakage-audit method and explain how leakage would inflate the reported metric. (5)

Answer keyMark scheme & solutions

Question 1

(a) InfoNCE mutual information bound (7)

Setup (1): Treat the positive as a classification-over-KK problem: the numerator is the true (positive) density, the denominator sums KK terms drawn as 1 positive + (K1)(K-1) negatives.

Derivation (4): The optimal InfoNCE critic satisfies f(zi,zj)p(zizj)p(zi)f(z_i,z_j)\propto \frac{p(z_i|z_j)}{p(z_i)}. Substituting the optimal critic: E[]=E ⁣[logp(zizj)/p(zi)p(zizj)/p(zi)+negp(zizj)/p(zi)].\mathbb{E}[\ell] = -\mathbb{E}\!\left[\log \frac{p(z_i|z_j)/p(z_i)}{p(z_i|z_j)/p(z_i)+\sum_{neg}p(z_i|z_j')/p(z_i)}\right]. Bounding the negative sum by its expectation ((K1)\approx (K-1)) and using Jensen: E[]logKI(zi;zj).\mathbb{E}[\ell] \geq \log K - I(z_i;z_j). Hence I(zi;zj)logKE[]I(z_i;z_j) \geq \log K - \mathbb{E}[\ell]: minimizing \ell raises the MI lower bound. (2 for final inequality direction)

Assumptions (2): (i) negatives are i.i.d. from the marginal p(z)p(z); (ii) critic is expressive enough to reach the optimum; (iii) large-batch approximation for the expectation of the negative sum. The bound is tighter as KK (batch size) grows — motivating SimCLR's large batches.

(b) Gradients & temperature (7)

Let sk=sim(zi,zk)/τs_k=\mathrm{sim}(z_i,z_k)/\tau and softmax pk=expskmiexpsmp_k = \frac{\exp s_k}{\sum_{m\neq i}\exp s_m}. Then: i,jsim(zi,zk)=1τ(pk1[k=j]).\frac{\partial \ell_{i,j}}{\partial\, \mathrm{sim}(z_i,z_k)} = \frac{1}{\tau}\big(p_k - \mathbf{1}_{[k=j]}\big).

  • For a negative kk: gradient =1τpk>0=\frac{1}{\tau}p_k>0 → loss pushes similarity down, weighted by softmax probability. (3)
  • For the positive jj: gradient =1τ(pj1)<0=\frac{1}{\tau}(p_j-1)<0 → pulls positive similarity up. (2)

Temperature interpretation (2): As τ0+\tau\to 0^+, sks_k blows up; softmax pkp_k concentrates on the largest sks_k (the hardest negative, highest cosine sim). Thus the gradient mass focuses on the single hardest negative — sharp, hard-negative-mining behaviour. Large τ\tau → uniform pkp_k → all negatives weighted equally (soft). The 1/τ1/\tau prefactor amplifies gradient magnitude at small τ\tau.

(c) Vectorized NT-Xent pseudocode + complexity (8)

# Z: (2N, d), already L2-normalized
S = Z @ Z.T / tau          # (2N, 2N) similarity/temperature
S.fill_diagonal_(-inf)     # mask self-similarity (i != k)
# positive index for row i: its paired augmentation j
targets = pairing_indices  # length 2N, maps i -> j
loss = cross_entropy(S, targets)   # softmax over rows, pick target col
return loss.mean()

Marks: correct sim matrix (2), diagonal masking (2), positive targeting via cross-entropy (2).

Complexity (2): Matrix ZZZZ^\top: time O((2N)2d)=O(N2d)O((2N)^2 d)=O(N^2 d), memory O(N2)O(N^2) for the similarity matrix. Diagonal mask explanation: term k=ik=i (self-similarity =1=1 after norm) is excluded by the indicator 1[ki]\mathbf 1_{[k\neq i]}; leaving it in would place a trivial maximal logit on the self entry, corrupting the softmax normalization.


Question 2

(a) Client drift & effect of EE (8)

Convergence intuition (3): FedAvg bound (Li et al. 2020) has form E[F(wT)F]κT+γ(Bvariance+CΓheterogeneity+),\mathbb{E}[F(w_T)-F^\star] \leq \frac{\kappa}{T+\gamma}\Big(\underbrace{B}_{\text{variance}} + \underbrace{C\Gamma}_{\text{heterogeneity}} + \dots\Big), where terms multiplying EE and Γ\Gamma grow with more local steps. Larger EE lets each client descend toward its own FmF_m^\star, which differs from FF^\star by heterogeneity Γ\Gamma → the averaged model sits between local optima, not at the global one ("client drift").

Drift derivation (5): After EE local steps from shared wtw^t, client mm's weight is wmt,E=wtηe=0E1Fm(wmt,e).w_m^{t,E} = w^t - \eta\sum_{e=0}^{E-1}\nabla F_m(w_m^{t,e}). To first order (freeze gradient at wtw^t): wmt,EwtηEFm(wt)w_m^{t,E} \approx w^t - \eta E\,\nabla F_m(w^t). Drift relative to a global SGD step wtηEF(wt)w^t-\eta E\nabla F(w^t): δm=wmt,E(wtηEF(wt))=ηE(Fm(wt)F(wt)).\delta_m = w_m^{t,E} - \big(w^t-\eta E \nabla F(w^t)\big) = -\eta E\big(\nabla F_m(w^t) - \nabla F(w^t)\big). Its magnitude scales with ηEFmF\eta E \cdot \|\nabla F_m - \nabla F\| — proportional to EE and to gradient dissimilarity (heterogeneity). Hence large EE + high Γ\Gamma → large drift → biased average.

(b) DP noise computation (7)

σC2ln(1.25/δ)ε=1.02ln(125000)1.0.\sigma \geq \frac{C\sqrt{2\ln(1.25/\delta)}}{\varepsilon} = \frac{1.0\cdot\sqrt{2\ln(125000)}}{1.0}. ln(1.25/105)=ln(125000)11.7361\ln(1.25/10^{-5}) = \ln(125000) \approx 11.7361. 2×11.7361=23.4722\times 11.7361 = 23.472; 23.4724.845\sqrt{23.472}\approx 4.845. σ4.85\boxed{\sigma \approx 4.85} (4 for value + method)

Effect (3): Added noise variance σ2C2\propto \sigma^2 C^2 enters the convergence variance term additively (scaled by 1/M1/M if noise averages across MM clients: variance term σ2C2d/M\sim \sigma^2 C^2 d / M). Tradeoff: smaller ε\varepsilon (stronger privacy) → larger σ\sigma → larger variance floor → higher final loss / slower convergence. Averaging over many clients mitigates it (1/M1/M).

(c) Neuro-symbolic federated (5)

Advantage (2): Symbolic rules (e.g., logical predicates / decision rules) are tiny compared to full gradient/weight tensors → drastically lower communication bandwidth and no per-round dense transmission. Open problem (2): Rule conflict resolution — clients may learn contradictory rules; merging requires a sound aggregation logic (truth maintenance, weighted voting, consistency checking) with no established, differentiable-friendly solution. (+1 for coherent framing.)


Question 3

(a) Confidence interval (6)

Wald 95% half-width: zp^(1p^)/nz\sqrt{\hat p(1-\hat p)/n} with z=1.96z=1.96. p^(1p^)=0.751×0.249=0.186999\hat p(1-\hat p)=0.751\times0.249=0.186999. Divide by nn: 0.186999/50000=3.740×1060.186999/50000=3.740\times10^{-6}. Sqrt =1.9339×103=1.9339\times10^{-3}. Times 1.961.96: half-width0.003790.38%.\text{half-width} \approx 0.00379 \approx 0.38\%. (4)

Judgement (2): 95% CI 75.1%±0.38%\approx 75.1\%\pm0.38\%. A +2.1%+2.1\% gap (5.5×\approx 5.5\times the half-width) exceeds the sampling noise on this test set, so it is statistically distinguishable from test-set sampling noise alone. BUT with a single run, the claim ignores training-seed/optimization variance, which is typically larger than test-sampling noise — so the claim is not established without multiple runs.

(b) Reproduction controls (7) — 5 × ~1.4 marks

  1. Multiple seeds + report mean±std — prevents mistaking a lucky run for real improvement (training variance).
  2. Compute/FLOP-matched baseline — prevents attributing gains to more compute/params rather than the method.
  3. Pretraining–eval data leakage audit — prevents inflated zero-shot scores from test images in the pretrain corpus.
  4. Hyperparameter search parity — equal tuning budget for baseline and new method; prevents unfair under-tuned baselines.
  5. Fixed data splits + preprocessing release — prevents evaluation-protocol drift and cherry-picked splits. (Accept: released code/checkpoints, ablations isolating the claimed component.)

(c) Deduplication + leakage audit (5)

Method (3): Embed all pretraining images and all ImageNet test images with a frozen, independent perceptual hasher or embedding model; compute nearest-neighbour cosine similarity; flag pairs above a threshold (or exact/near-dup via perceptual hashing like pHash). Also match on caption text for CLIP-style duplicates. Report the % of test images with a near-duplicate in pretraining and re-evaluate on the deduplicated subset. Why leakage inflates (2): If test images (or their captions) appear in pretraining, the model has effectively memorized the label association, so "zero-shot" accuracy measures memorization, not generalization — biasing the metric upward and voiding the SOTA comparison.

[
{"claim":"InfoNCE negative-logit gradient prefactor is 1/tau, positive is (p-1)/tau; sign of negative gradient positive","code":"tau=Rational(1,2); s0,s1,s2=symbols('s0 s1 s2'); den=exp(s0/tau)+exp(s1/tau)+exp(s2/tau); ell=-log(exp(s0/tau)/den); g_neg=diff(ell,s1); val=g_neg.subs({s0:0,s1:0,s2:0}); result=(simplify(val)>0)==True","comment":"positive gradient on a negative logit"},
{"claim":"DP sigma for eps=1, delta=1e-5, C=1 is approx 4.845","code":"sig=1.0*sqrt(2*ln(1.25/Rational(1,100000)))/1.0; result=abs(float(sig)-4.845)<0.01"},
{"claim":"Wald 95% half-width for p=0.751,n=50000 is approx 0.00379","code":"p=Rational(751,1000); n=50000; hw=1.96*sqrt(p*(1-p)/n); result=abs(float(hw)-0.00379)<0.0001"},
{"claim":"2.1% gap exceeds Wald half-width (distinguishable from sampling noise)","code":"p=Rational(751,1000); n=50000; hw=float(1.96*sqrt(p*(1-p)/n)); result=(0.021>hw)==True"}
]