Home/Machine Learning/Research Paper Depth
Back
๐Ÿ“„

Research Scientist

Research Paper Depth

Research Scientists are evaluated on their ability to engage critically with literature โ€” not just summarize papers but critique them, identify limitations, and propose extensions. You must know the landmark papers deeply (Transformer, BERT, GPT, LoRA, InstructGPT, Chinchilla, FlashAttention) and be able to discuss what problems each solved and what remains open.

Deep learning fundamentalsTransformer architectureBasic research experiencePaper ReadingCritical AnalysisTransformersLoRALiterature ReviewReproducibility

Core Theory

  • 1How to read a paper (Keshav 3-pass method): Pass 1 (5 min) โ€” title, abstract, conclusions, figure captions. Decide if worth reading further. Pass 2 (1 hr) โ€” read carefully but skip math. Understand main contributions, key experiments, and whether claims are supported. Pass 3 (4-5 hrs) โ€” understand every detail: every assumption, every derivation, every experimental choice. Can you reimplement this?
  • 2Critical analysis framework: (1) What problem does this solve? Is the problem well-motivated? (2) What is the key technical insight? Could this have been done another way? (3) Are the experiments compelling? Are baselines fair? Is the evaluation metric appropriate? (4) What are the limitations? What does this NOT solve? (5) What would you do next? What are the natural extensions?
  • 3Must-know papers for research roles: 'Attention Is All You Need' (Vaswani et al. 2017) โ€” transformer architecture. BERT (Devlin et al. 2019) โ€” bidirectional masked language modeling. GPT-3 (Brown et al. 2020) โ€” in-context learning. LoRA (Hu et al. 2021) โ€” parameter-efficient fine-tuning. InstructGPT (Ouyang et al. 2022) โ€” RLHF. Chinchilla (Hoffmann et al. 2022) โ€” compute-optimal training. FlashAttention (Dao et al. 2022) โ€” IO-efficient attention.
  • 4Attention Is All You Need โ€” key insights: (1) eliminate recurrence entirely, use only attention and feed-forward layers. (2) Scaled dot-product attention: QK^T/โˆšd_k prevents vanishing softmax gradients. (3) Multi-head attention: different heads attend to different representation subspaces. (4) Positional encoding: sine/cosine allows the model to generalize to longer sequences than seen in training. (5) The original Transformer uses post-norm (LN after residual), but pre-norm is now standard for stability.
  • 5BERT vs GPT pre-training: BERT: bidirectional โ€” mask random tokens, predict them using both left and right context. Good for understanding tasks (classification, NER, QA). GPT: unidirectional โ€” predict next token given left context only. Good for generation tasks. BERT uses [CLS] token embedding for classification. GPT uses the last token. T5 (text-to-text) frames all tasks as text generation, bridging the gap.
  • 6LoRA โ€” Low-Rank Adaptation: instead of fine-tuning all W โˆˆ R^{dร—k}, freeze W and add a low-rank bypass: W' = W + BA where B โˆˆ R^{dร—r}, A โˆˆ R^{rร—k}, r << min(d,k). Training only BA (2rk parameters vs dk). Key insight: the fine-tuning updates tend to be low-rank in practice โ€” the hypothesis is that the 'task-relevant' directions are few. Initialize B=0 so W'=W at the start. Apply to Q and V attention matrices typically. 7B model: fine-tune 37M parameters instead of 7B.
  • 7Reproducibility crisis in ML: many published results don't replicate. Reasons: (1) cherry-picked hyperparameters not reported, (2) evaluation on hand-selected test sets, (3) unpublished tricks (gradient clipping, learning rate schedule) that are critical for performance, (4) hardware/software differences (cuDNN versions affect results). Best practice: report all hyperparameters, use multiple random seeds, report mean ยฑ std, use held-out test sets.
  • 8Tracking current research: arXiv (cs.LG, cs.CL, cs.AI) for preprints. Papers with Code (paperswithcode.com) for state-of-the-art tracking with code. Hugging Face Daily Papers for curated highlights. Twitter/X ML community for immediate reactions. Semantic Scholar for citation graphs (find what papers cite a key work). ICLR/NeurIPS/ICML proceedings for peer-reviewed work.

Key Formulas

01Attention: Attention(Q,K,V)=softmax(QKT/dk)VAttention(Q,K,V) = softmax(QK^T/\sqrt{d_k})V
02BERT MLM loss: L=โˆ’โˆ‘iโˆˆmaskedlogโกP(xiโˆฃxโˆ–i)L = -\sum_{i \in masked} \log P(x_i | x_{\setminus i})
03LoRA: Wโ€ฒ=W+ฮ”W=W+BAW' = W + \Delta W = W + BA, BโˆˆRdร—rB \in \mathbb{R}^{d \times r}, AโˆˆRrร—kA \in \mathbb{R}^{r \times k}
04LoRA parameters: 2rk2rk instead of dkdk; typical r=4,8,16r = 4, 8, 16
05Perplexity: PPL=expโก(โˆ’1Tโˆ‘tlogโกP(xtโˆฃx<t))PPL = \exp(-\frac{1}{T}\sum_t \log P(x_t|x_{<t}))
python
1import torch
2import torch.nn as nn
3import torch.nn.functional as F
4import math
5
6class LoRALinear(nn.Module):
7 """
8 LoRA (Low-Rank Adaptation) applied to a linear layer.
9 Instead of fine-tuning W โˆˆ R^{d x k}, we train A โˆˆ R^{r x k} and B โˆˆ R^{d x r}
10 such that the adapted weight is W + B @ A.
11
12 B is initialized to zero so the adaptation starts as the original model.
13 A is initialized randomly (Kaiming uniform is the LoRA default).
14 """
15 def __init__(self, in_features: int, out_features: int,
16 rank: int = 4, alpha: float = 1.0,
17 dropout: float = 0.0):
18 super().__init__()
19 self.rank = rank
20 self.scaling = alpha / rank # LoRA scaling factor
21
22 # Frozen pre-trained weight
23 self.weight = nn.Parameter(
24 torch.empty(out_features, in_features), requires_grad=False
25 )
26 nn.init.kaiming_uniform_(self.weight, a=math.sqrt(5))
27
28 # Trainable LoRA matrices
29 self.lora_A = nn.Parameter(torch.empty(rank, in_features))
30 self.lora_B = nn.Parameter(torch.zeros(out_features, rank)) # B=0 initially
31 self.dropout = nn.Dropout(dropout)
32
33 # Initialize A with Kaiming uniform (as per LoRA paper)
34 nn.init.kaiming_uniform_(self.lora_A, a=math.sqrt(5))
35
36 def forward(self, x: torch.Tensor) -> torch.Tensor:
37 # Base forward: frozen weight
38 base = F.linear(x, self.weight)
39
40 # LoRA forward: x @ A^T @ B^T ร— scaling
41 lora = F.linear(self.dropout(x), self.lora_A) # (batch, rank)
42 lora = F.linear(lora, self.lora_B) # (batch, out_features)
43 return base + self.scaling * lora
44
45 def merge_weights(self) -> nn.Linear:
46 """Merge LoRA into base weight for efficient inference."""
47 merged = nn.Linear(self.weight.shape[1], self.weight.shape[0], bias=False)
48 merged.weight.data = self.weight + self.scaling * (self.lora_B @ self.lora_A)
49 return merged
50
51# โ”€โ”€โ”€ Test โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
52d_in, d_out, r = 512, 512, 8
53lora_layer = LoRALinear(d_in, d_out, rank=r, alpha=16.0)
54
55# Count parameters
56total_params = sum(p.numel() for p in lora_layer.parameters())
57lora_params = sum(p.numel() for p in lora_layer.parameters() if p.requires_grad)
58base_params = sum(p.numel() for p in lora_layer.parameters() if not p.requires_grad)
59
60print(f"Base weight params: {base_params:,} (frozen)")
61print(f"LoRA trainable params: {lora_params:,} (= 2 ร— {r} ร— {d_in})")
62print(f"Parameter reduction: {base_params/lora_params:.0f}x ({lora_params/total_params*100:.1f}% of total)")
63
64x = torch.randn(4, d_in)
65out = lora_layer(x)
66print(f"\nInput: {x.shape}")
67print(f"Output: {out.shape}")
68
69# Merge for inference
70merged = lora_layer.merge_weights()
71out_merged = merged(x)
72print(f"Merge error: {(out - out_merged).abs().max().item():.2e} (should be ~0)")

Full LoRA implementation showing: (1) frozen base weight (requires_grad=False) โ€” never updated during training; (2) trainable B and A matrices โ€” B initialized to zero (ensures adaptation starts as identity), A initialized randomly; (3) scaling factor ฮฑ/r โ€” controls the magnitude of the adaptation; (4) merge_weights() computes W + (ฮฑ/r) ร— BA for efficient inference (no separate LoRA computation needed). For a 512ร—512 layer with r=8: 262k parameters โ†’ 8k parameters (33ร— reduction).

Worked Interview Problems

3 problems

Problem

Walk through the key contributions of the Transformer paper (Vaswani et al. 2017), its limitations, and what it left open.

Solution

1

Key contributions: (1) Eliminated recurrence โ€” enables parallelization during training. (2) Self-attention computes pairwise relationships between all positions in O(nยฒ) โ€” compared to O(n) for RNNs but with global receptive field vs. local. (3) Scaled dot-product attention: division by โˆšd_k prevents softmax saturation with high-dimensional keys. (4) Multi-head attention: h parallel attention heads allow attending to different subspaces simultaneously. (5) Positional encoding: fixed sine/cosine patterns allow extrapolation to longer sequences.

2

What the paper got right: the architecture proved extraordinarily general โ€” it's the backbone of every frontier AI system 8 years later. The scalability of self-attention (easily parallelized on GPUs) enabled training on massive data.

3

What the paper got wrong or left open: (1) Quadratic complexity O(nยฒ) in sequence length limits context length โ€” addressed by linear attention, sparse attention, FlashAttention. (2) Post-norm (LN after residual) โ€” empirically worse than pre-norm for deep models. GPT-2/3/LLaMA all use pre-norm. (3) Fixed sinusoidal positional encoding โ€” poor extrapolation to longer sequences. Replaced by learned positions (GPT), RoPE (LLaMA), ALiBi. (4) No explanation for why the architecture works โ€” theory followed practice.

4

Extensions that became important: Sparse attention (Longformer, BigBird) for long sequences. Flash Attention for memory-efficient attention. Rotary position embeddings (RoPE) for better length generalization. Pre-norm architecture for training stability.

5

How to evaluate this paper: was the problem well-motivated? Yes โ€” RNNs were slow to train and hard to parallelize. Were the experiments convincing? Yes โ€” BLEU score improvements on WMT translation were large and reproducible. Were the baselines fair? Mostly โ€” though the RNN baselines weren't the most competitive at the time.

Answer

Key contributions: parallelizable self-attention, scaled dot-product, multi-head, positional encoding. Limitations: O(nยฒ) complexity, post-norm instability, fixed positional encoding. Natural extensions: FlashAttention, RoPE, sparse attention, pre-norm. The architecture was generative โ€” it defined the field for a decade.

Common Mistakes

!

Summarizing a paper without critiquing it. Research Scientist interviews test whether you can identify what's WRONG with a paper, not just what it does. Every paper has limitations โ€” if you can't name them, you haven't read it critically.

!

Not knowing the experimental details. 'The model was fine-tuned on GLUE' is insufficient. Know: what datasets, what baselines, what metrics, what the reported numbers are. Interviewers will probe these details.

!

Confusing BERT and GPT pre-training objectives. BERT: Masked Language Modeling (bidirectional, predict masked tokens). GPT: Causal Language Modeling (unidirectional, predict next token). BERT is better for understanding tasks; GPT is better for generation. T5 treats everything as text generation.

!

Not understanding why LoRA initializes B=0. If B were initialized randomly, W' = W + BA would immediately change the model's behavior before any training. B=0 ensures that at initialization, W' = W (same as the original model), and training starts from the pre-trained checkpoint.

!

Saying a paper 'proves' something when it only empirically demonstrates it. Neural network papers almost never prove things in the mathematical sense โ€” they show empirical evidence. Use language like 'the paper demonstrates,' 'the authors show empirically,' 'the results suggest.' Saying 'the paper proves' to a research scientist is a credibility hit.

Only works in the Electron app

<webview> is an Electron-only tag. Run npm run electron:dev to use this.

25:00Focus
0

25 min focus ยท 5 min break ยท long break every 4 sessions

The Ultimate Grind