LLGA · Course notes

Advanced Topics in Large Language Models

M2 · P2 (announced) · Year 2 · Period 2

Contents

Introduction and overview

Module Advanced Topics in Large Language Models
Code M2 · P2 (announced) — official code not published (course description not published)
Team and workload Instructor: master’s team · ~24 h · research seminar: reasoning (CoT, RLVR), long context, memory, MoE, alternative architectures (Mamba), efficiency, the LLMs × graphs crossroads, agents, evaluation, open problems — each chapter organizes the critical reading of a pivot paper.
Status in the program M2Graph × LLM route · preselected by the Graph × LLM route of the home page · M2 program being finalized

Audience: an engineer or researcher who already reads LLM papers and wants a critical filter. Empirical first: we start from claims that do not survive a closer look — a “magic” chain-of-thought that fails out of distribution, a million-token context in which information gets lost in the middle — and only then study the work behind them: RLVR, MoE, Mamba, agents, contamination-aware evaluation.

The module is a reading seminar on the current research fronts of LLMs: evaluation, reasoning, long context and memory, architectures, efficiency, graphs, agents and open problems.

What you will be able to do

Official objectives and syllabus

Official course description not published (S3/S4 catalog empty): as of the start of the 2026 academic year, the “LLGA 2 – Semestre 3” and “LLGA 2 – Semestre 4” tracks of the 2026-2027 SynapseS catalog still list no courses, and the master’s wiki indicates that the detailed M2 program is “under development” (period 2: “to be completed soon”).

The program below therefore reflects the master’s brochure (period 2), which announces a research seminar, with an indicative volume of ~24 h; these course materials are calibrated to that volume (see the session plan below).

The instructors of this proposed course are not confirmed; the cited papers and standards form the foundation, and the LLGA (LLMs & Graphs) group of École Polytechnique will provide the guest sessions when relevant.

The following table maps each brochure theme to the course sections; the materials’ own additions are marked “going beyond the syllabus”.

Brochure theme Course section covering it
Seminar format: critical reading of a pivot paper per chapter ch. 0 (recap of the LLM foundation and how to use the seminar)
Evaluation (contamination, judge bias) ch. 1
Reasoning (chain-of-thought, RLVR) ch. 2
Long context ch. 3 (RoPE, ring attention, RAG or LC arbitrage)
Memory ch. 4 (episodic, vector stores, GraphRAG)
Mixture-of-Experts ch. 5
Alternative architectures (SSM, Mamba, RWKV) ch. 6
Efficiency (speculative decoding, quantization) ch. 7
LLMs × graphs crossroads ch. 8 (the master’s signature)
Agents (planning, tools, multi-agents) ch. 9
Open problems ch. 10 (the map of research fronts)
Going beyond the syllabus — minimal reproductions (RoPE, speculative decoding, contamination-free evaluation) Exercises / Labs

Where this course fits in the program

An M2 module offered in period 2 and preselected by the Graph × LLM route of the home page: a research seminar, it assumes the foundations are laid and works through readings and discussions rather than ex cathedra lectures.

Prerequisites: Large Language Models, the mandatory foundation that every chapter goes beyond (architecture and mixture-of-experts in ch. 2, training, alignment, inference); and one Deep Learning course, Deep Learning (P1) or Deep Learning P2, for attention, recurrent networks and training costs. Advanced Deep Learning is not assumed: the few tools used from outside these courses (FFT convolution, prefix scan, Optimal Brain Surgeon) are defined where they are needed.

Downstream: it is the direct preparation for the research internship and the PhD — each chapter ends with open questions that are as many internship topics — and for R&D jobs, where the competitive edge is played on a six-month head start in reading the literature.

Course outline

Session plan

24 h in class (announced) = 8 sessions of 3 h. The volume is the indicative ~24 h given by the master’s brochure for this research seminar (the SynapseS 2026–2027 sheet is not yet published); no session-by-session programme is published, so the split below is our proposal for covering these notes in that time. Since the module is a reading seminar, every chapter, open problems included, is discussed in class.

Level 1 = foundations (reviews, definitions, first worked examples), 2 = core methods, 3 = advanced theory and open problems; the level never goes down from one session to the next.

Session Hours Level Content Practice
1 3 h 1 ch. 0 Seminar method and reading grid; ch. 1 Evaluation: contamination, LLM judges, holistic evaluation Ex. 1 (start), 4
2 3 h 2 ch. 2 Reasoning: chain-of-thought, self-consistency, process rewards, RLVR and DeepSeek-R1 Ex. 2, 5
3 3 h 2 ch. 3 Long context: RoPE (recalled), interpolation and the YaRN formula, ring attention and its online softmax, RAG or long context Ex. 6, 7
4 3 h 2 ch. 4 Memory: episodic memory, vector stores, MemGPT, GraphRAG; ch. 5 Mixture-of-Experts: routing and load balancing Ex. 8, 9
5 3 h 2 ch. 6 Alternative architectures: SSMs and FFT convolution, Mamba and the prefix scan, RWKV, hybrids Ex. 10
6 3 h 2 ch. 7 Efficiency: speculative decoding, GPTQ, AWQ Ex. 3
7 3 h 2 ch. 8 LLMs × graphs: serialized graphs, G-Retriever, graph instruction tuning (GraphGPT, LLaGA), map of the field, LLM-based KG completion Ex. 12, 14
8 3 h 3 ch. 9 Agents: ReAct, Toolformer, Reflexion, multi-agent systems; ch. 10 Open problems: data exhaustion, continual learning Ex. 11, 13

Self-study, outside the 24 h: none — the preparatory reading of each session’s pivot papers (about 1 h per session) is part of the seminar format.

How to study this module

The LLGA perspective Chapter 8 is called “LLMs × graphs: the LLGA crossroads”: this module is the place in the master where the motto becomes a research object. The fronts it covers — reasoning, memory, agents, evaluation — are exactly those where the crossroads of language models with relational data produces the most open questions. If you are aiming for a PhD, an R&D internship or a startup at the frontier, this is where you will learn the rarest gesture: read fast, judge surely, and identify the problem that no one has yet posed well.

Independent note The reading filter that this module adds to the two-year path is simple: look at protocols and failure modes before believing slogans.

0. Recap and how to use the seminar

This chapter states what the seminar assumes from earlier modules and explains how a session works: one pivot paper, read before class, dissected and then criticized with a common grid.

Prerequisites (M1/M2 modules)

  • LLMs module (M2): architecture (ch. 2), pre-training and scaling laws (ch. 3), SFT/RLHF/DPO/GRPO (ch. 4-5), inference (ch. 6), RAG (ch. 7), agents (ch. 8), evaluation (ch. 9) — this seminar assumes all of this acquired and pushes each subject one notch further;
  • Deep Learning (M1, P1 or P2): attention and the transformer block (DL P1 ch. 6, DL P2 ch. 0), recurrent networks (DL P1 ch. 5, DL P2 ch. 1) — the baseline that ch. 3, 6 and 7 modify;
  • RL (M1): policy gradients and PPO (ch. 5), deep RL (ch. 6), agents in the era of LLMs (ch. 7) — the engine of reasoning by RLVR (ch. 2);
  • Graph ML (M1): message passing (ch. 5), GraphRAG (ch. 10) — the crossroads of ch. 8;
  • RLHF and theory: rewards, optimization (ML / Optimization); Hoeffding’s inequality (Machine Learning ch. 0, Theorem 0.3) for ch. 1.

Definition 0.1 — Seminar format One session = one pivot paper (read by everyone before), dissected in class (method, equations, experiments), then subjected to a structured critical analysis: what exact question? what method? what evidence (and counter-evidence)? what do the figures say in detail? what limits — theoretical, experimental, operational? what remains to be done? The reading note (lab 1) is the module’s permanent deliverable.

Common reading grid For each paper:

  1. central claim in one sentence;
  2. evidence: benchmarks, baselines, ablations, significance;
  3. costs — compute, data, energy (cf. ML Ops module ch. 4 and 10);
  4. reproducibility — code, data, seeds, potential contamination (ch. 1);
  5. LLGA positioning: what link to graphs, RAG, agents?

This grid is also that of your M2 internship report.

Ch. Topic Pivot paper(s) Module links
1 Evaluation Contamination survey (2024); MT-Bench (2023); HELM (2022) LLMs ch. 9, ML Ops ch. 2
2 Reasoning DeepSeek-R1 (2025); Wei et al. (2022); Lightman et al. (2023) RL ch. 5-6, LLMs ch. 5
3 Long context RoPE (2021); YaRN (2023); Ring Attention (2023); Li et al. (2024) LLMs ch. 2, ML Ops ch. 3
4 Memory Memorizing Transformers (2022); Generative Agents (2023); GraphRAG (2024) LLMs ch. 7-8, Graph ML ch. 10
5 MoE Shazeer et al. (2017); Switch (2021); Mixtral (2024); DeepSeek-V3 (2024) LLMs ch. 2-3
6 SSM/Mamba/RWKV S4 (2022); Mamba (2023); RWKV (2023); Jamba (2024) DL ch. 5 (RNN), FFT box
7 Efficiency Speculative decoding (2023); GPTQ (2022); AWQ (2023) LLMs ch. 6, ML Ops ch. 4
8 LLMs × graphs NLGraph (2023); Talk like a Graph (2024); G-Retriever (2024); LLaGA (2024) Graph ML ch. 10, Adv. GNN 8.3
9 Agents ReAct (2023); Toolformer (2023); Reflexion (2023); AutoGen (2023) LLMs ch. 8, RL ch. 7
10 Open Villalobos et al. (2024); continual learning survey (2024) LLMs ch. 3

1. Evaluation: contamination, judge bias

Every later session asks whether a paper’s numbers can be trusted, so the seminar starts with the tools to answer that question: how test data leaks into training, how biased LLM judges are, and how to report a score honestly. A concrete scene: a state-of-the-art benchmark score that turns out to be inflated because the test set was in the training data.

What breaks Three classic reading mistakes: reading the abstract without the protocol; confusing the advertised context length with what the model really uses; and taking a contaminated score for a capability.

Today’s readings C. Xu, S. Guan, D. Greene, M.-T. Kechadi, Benchmark Data Contamination of Large Language Models: A Survey, 2024 (arXiv:2406.04244); L. Zheng et al., Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena, NeurIPS 2023 (arXiv:2306.05685); P. Wang et al., Large Language Models are not Fair Evaluators, ACL 2024 (arXiv:2305.17926); P. Liang et al., Holistic Evaluation of Language Models (HELM), TMLR 2023 (arXiv:2211.09110).

1.1. Contamination: when the test leaks into training

Definition 1.1 — Benchmark data contamination (BDC) The pollution of a benchmark when its data (questions and/or answers) have been seen during pre-training — accidental (the web contains the solutions), or even deliberate (training on the test’s variant). Signals: n-gram overlaps with the corpus, embedding similarity, abnormally low test perplexity, the ability to complete the items without their instruction, “random” performance on renamed variants (changing the figures of a math problem).

Responses: canaries (“do not train on this string”), dynamic benchmarks refreshed (e.g. LiveBench), private sets, kept-current evaluations (challenges with a cutoff date).

Proposition 1.2 — What a contaminated score estimates (and what it does not) A benchmark measures performance on a task distribution P_{\text{test}}. If the model has seen n examples of P_{\text{test}} during training, the score observes a mixture \rho \cdot \text{memory} + (1-\rho) \cdot \text{generalization} : the estimand has shifted — the score overestimates and distorts comparisons (the models trained more recently, on larger corpora, are more contaminated: the bias advances with time).

The methodological remedy: report jointly (i) the raw score, (ii) the score on re-generated variants, (iii) an overlap measure — and treat the (i)-(ii) gap as an interval, not as noise.

1.2. LLM judges: useful, biased, calibratable

MT-Bench (Zheng et al., 2023) validates the LLM judge: GPT-4 agrees with expert human verdicts more than 80% of the time, the same level as the agreement between two humans (about 81%, ties excluded). This legitimizes its industrial use (ML Ops module ch. 5), but the biases are systematic.

Recall — LLMs module 9.2

The three biases of LLM judges and their fixes are in LLMs 9.2: position (judge in both orders), verbosity (rubrics, constrained format) and self-preference (judge ensembles).

Wang et al. (ACL 2024) show that a simple order swap flips a substantial share of verdicts — “not fair evaluators”.

HELM (Liang et al.) answers with the holistic: same models, dozens of scenarios, multiple metrics (accuracy, calibration, robustness, bias, toxicity…), published protocol — evaluation as a slow science versus the leaderboard as a fast sport.

Critical analysis — the “methods” session

  1. Goodhart: every public benchmark becomes a training objective — the value of a score decays with its popularity;
  2. Variance: a leaderboard at ±0.5 points with 500 questions ranks nothing. By Hoeffding (Machine Learning ch. 0, Theorem 0.3), the 95% half-width of an accuracy on 500 questions is about 6 points;
  3. Judge the judge: calibrate each judge on a human golden set before using it (measured biases, alternating orders, rubrics);
  4. Saturation: when everyone exceeds 90% accuracy, the benchmark measures noise — move to the dynamic/adversarial evaluations (red teaming in Explainability, Security and Privacy of LLMs ch. 10, agents of ch. 9).

LLGA rule: no evaluation number without its protocol — neither in the papers you read, nor in your own.

# N-gram contamination detection (sketch, thresholds to calibrate)
def ngrams(s, n=13):  return {" ".join(s.split()[i:i+n]) for i in range(len(s.split())-n+1)}

def overlap(test_item, pretrain_index):     # pretrain_index: set of shingles
    q = ngrams(test_item.question) | ngrams(test_item.answer)
    return len(q & pretrain_index) / max(len(q), 1)

# measurement: overlap distribution per benchmark -- a non-negligible mass
# above 0.8 on "public" items (GSM8K-like) = contamination signal

2. Reasoning: chain-of-thought, RLVR

Can a language model be made to reason better, either by letting it write intermediate steps or by training it on problems whose answers can be checked? This session reads the papers that introduced chain-of-thought and self-consistency, compared process and outcome rewards, and showed with DeepSeek-R1 that reinforcement learning on verifiable rewards makes long reasoning emerge.

Today’s readings J. Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, NeurIPS 2022 (arXiv:2201.11903); X. Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models, ICLR 2023 (arXiv:2203.11171); H. Lightman et al., Let’s Verify Step by Step, ICLR 2024 (arXiv:2305.20050); DeepSeek-AI, DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning, 2025 (arXiv:2501.12948); N. Lambert et al., Tulu 3, 2024 (arXiv:2411.15124) — which names RLVR (reinforcement learning with verifiable rewards).

2.1. Chain-of-thought and self-consistency

The prompt “let’s think step by step” triggers the generation of an intermediate reasoning chain z before the answer y — and the gains emerge with scale (clear from ~1011 parameters in the original study): the model allocates compute tokens to the problem. The formal reading:

Proposition 2.1 — Self-consistency = marginalization (Wang et al., 2023) Generating a chain z then an answer y realizes a joint model p(y, z \mid x) = p(z\mid x)\,p(y \mid x, z). The probability of the correct answer under the full model is the margin p(y \mid x) \;=\; \sum_{z} p(y, z \mid x).

Self-consistency approximates \arg\max_y p(y\mid x) by majority vote over k sampled chains z_1, \dots, z_k \sim p(\cdot \mid x): a Monte Carlo of “latent reasoning”. Typical gains: +10 to +20 points on GSM8K compared to greedy decoding — for an inference cost of ×k.

Proof. Sampling z_i \sim p(z\mid x) then y_i \sim p(y \mid x, z_i) produces pairs (y_i, z_i) distributed according to the joint; the count \frac1k \sum_i \mathbf{1}[y_i = y] is an unbiased estimator of \sum_z p(z \mid x)\,p(y \mid x, z) = p(y\mid x) (the two successive samplings compose exactly the joint).

The empirical argmax converges to the true argmax as k \to \infty (concentration of frequencies) — it is Monte Carlo estimation justified by the law of large numbers (Refresher in Statistics ch. 4), with the particularity that the latent space is text. ∎

2.2. Process vs outcome rewards

Training a reward model on the final answer (ORM, outcome) is noisy: an answer that is right by chance receives the same reward as a clean reasoning. Lightman et al. build PRM800K (800,000 step-by-step labels given by humans) and train a PRM (process reward model): at equal labeling budget, the PRM selects better solutions on MATH than the ORM — supervision of the process is more informative than that of the outcome.

Immediate limit: step-by-step labeling is expensive and subjective; hence the idea of automating verification…

2.3. RLVR: verifiable rewards and the emergence of reasoning

Definition 2.2 — RLVR Instead of a learned reward model (subject to reward hacking), the reward is a verifiable rule: does the mathematical answer match the ground truth? does the code pass the tests? is the format correct? Training (GRPO — cf. LLMs module ch. 5; PPO — cf. RL module ch. 5) maximizes \mathcal{J}(\theta) = \mathbb{E}_{(x, y)\sim \pi_\theta} \bigl[\, r_{\text{verif}}(x, y) \,\bigr] over domains where truth is decidable. Tulu 3 (Lambert et al., 2024) makes it the third stage of open post-training (SFT → DPO → RLVR).

Pivot result — DeepSeek-R1 (2025) R1-Zero: purely RL (no initial SFT) with rule-based rewards on math/code/format; the model develops by itself reasoning behaviors — verification, backtracking, reflection (“aha moment”), lengthening chains — measurable by the growing generation length over the course of training.

R1: adding cold-start data + multiple stages (SFT → RL → re-SFT) stabilizes and aligns, up to rivaling the best closed reasoning models on math/code benchmarks. Associated publication in Nature (2025) — read both: the technical account and the scientific letter do not tell exactly the same story.

Critical analysis (a whole session)

  1. Generalization: RLVR only improves domains close to pre-training + verifiable; transfer to “general” reasoning is debated.
  2. Benchmarks: MATH/AIME are saturated and contaminable (ch. 1); are the advances measured on the scale of their own pollution?
  3. Residual reward hacking: even “hard” rules are bypassable (misleading format, weak tests);
  4. Costs: chains of tens of thousands of tokens — reasoning is a product that is compute-bound at inference (cf. ML Ops module ch. 4, green ops ch. 10);
  5. Alternative reading: does R1-Zero select capabilities already present (pre-training) rather than create them? The distillation experiments (small models trained on R1’s traces outperforming their direct RL cousins) lean toward the first reading.

Exercise: defend both theses with the figures of the paper.

3. Long context: RoPE, ring attention, RAG or LC?

A model trained on short sequences must be made to read much longer ones, and one must decide whether to give it everything or only retrieved excerpts. This session reads how rotary positions are extended, how exact attention is distributed over GPUs, and what the comparisons between long context and RAG really show.

Today’s readings J. Su et al., RoFormer: Enhanced Transformer with Rotary Position Embedding (RoPE), 2021 (arXiv:2104.09864); S. Chen et al., Extending Context Window via Positional Interpolation, 2023 (arXiv:2306.15595); B. Peng et al., YaRN, 2023 (arXiv:2309.00071); H. Liu et al., Ring Attention with Blockwise Transformers for Near-Infinite Context, NeurIPS 2023 (arXiv:2310.01889); N. Liu et al., Lost in the Middle, 2023 (arXiv:2307.03172); Z. Li et al., Retrieval Augmented Generation or Long-Context LLMs?, EMNLP 2024 industry (arXiv:2407.16833); P. Xu et al., Retrieval meets Long Context LLMs, ICLR 2024 (arXiv:2310.03025).

3.1. RoPE: position by rotation

Definition 3.1 — RoPE (Su et al., 2021), recalled from LLMs Theorem 2.3

Each coordinate pair (2i, 2i{+}1) of a query or key is rotated by the angle m\theta_i, where m is the position, b a base (10^4 originally) and \theta_i = b^{-2i/d}: q_m = R(m\Theta)\, q, \qquad k_n = R(n\Theta)\, k, \qquad \Theta = \mathrm{diag}(\theta_0, \dots). High frequencies resolve the local order, low ones the global order; derivation in LLMs Theorem 2.3.

Proposition 3.2 — RoPE encodes only relative position \langle R(m\Theta)\,q,\; R(n\Theta)\,k \rangle depends only on m - n (and on q, k). Per coordinate pair:

Key result — RoPE is relative \langle R(m\theta)q,\, R(n\theta)k\rangle = \langle R((m-n)\theta)\, q,\; k \rangle,

since R(m\theta)^\top R(n\theta) = R((n-m)\theta): plane rotations are orthogonal and commute (proof in LLMs Theorem 2.3). Engineering consequence: extending the context amounts to re-parameterizing the angles, not to relearning positional embeddings.

3.2. Extending the window: interpolation and YaRN

Positional interpolation (Chen et al., 2023): trained with angles up to L, one serves L' = sL by compressing the positions m \mapsto m/s — the model sees only angles already covered. Chen et al. extend LLaMA (7B to 65B) from 2,048 to 32,768 tokens within 1,000 fine-tuning steps.

The defect of PI is that it divides every frequency by s, so the high frequencies, which tell neighbouring tokens apart, are squeezed too. YaRN interpolates only the low frequencies.

Definition 3.3 — YaRN (Peng et al., 2023) Let s = L'/L be the extension factor. Pair i has wavelength \lambda_i = 2\pi/\theta_i and makes r_i = L/\lambda_i full turns over the training window.

With two thresholds \alpha < \beta (1 and 32 for LLaMA) and the ramp \gamma(r) = \begin{cases} 0 & \text{if } r < \alpha, \\[2pt] \dfrac{r-\alpha}{\beta-\alpha} & \text{if } \alpha \le r \le \beta, \\[2pt] 1 & \text{if } r > \beta, \end{cases} the “NTK-by-parts” rule replaces each frequency by \theta_i' = \bigl(1-\gamma(r_i)\bigr)\,\frac{\theta_i}{s} + \gamma(r_i)\,\theta_i . Pairs that turn less than once over L are interpolated as in PI; pairs that turn more than \beta times are kept (extrapolated), and those in between are blended. YaRN then divides the attention logits by a temperature t: \mathrm{softmax}\Bigl(\frac{q_m^\top k_n}{t\,\sqrt{d}}\Bigr), \qquad \sqrt{1/t} = 0.1\,\ln s + 1, which sharpens the attention that long contexts flatten.

Result: Llama 2 extended to 64k and 128k tokens with 10× fewer training tokens and 2.5× fewer training steps than the previous methods.

3.3. Ring attention: cutting the memory cost in a ring

Proposition 3.4 — Ring Attention (Liu et al., NeurIPS 2023) Cut a sequence of L tokens into P blocks held by P devices. Device i keeps its query block Q_i; the key/value blocks (K_j, V_j) travel around the ring, one hop per step, while the device computes — communication overlaps computation.

For each query row, the device keeps a running maximum m (started at -\infty), a running normalizer \ell and an unnormalized output O (both started at zero).

On receiving block j, with scores S = Q_i K_j^\top/\sqrt{d_k}, it updates, row by row, m' = \max\bigl(m,\ \mathrm{rowmax}(S)\bigr), \qquad \ell' = e^{m - m'}\,\ell + \mathrm{rowsum}\bigl(e^{S - m'}\bigr), O' = e^{m - m'}\,O + e^{S - m'}\,V_j . After the P blocks, O/\ell is exactly the softmax attention of Q_i over the whole sequence, and the activation memory per device drops from \mathcal{O}(L) to \mathcal{O}(L/P).

Proof. By induction over the blocks received: m is the largest score seen so far, \ell = \sum e^{s - m} and O = \sum e^{s - m}\, v, both sums running over the keys seen. Multiplying by e^{m - m'} only moves the reference maximum. At the end, \frac{O}{\ell} = \frac{\sum_s e^{s}\, v_s}{\sum_s e^{s}}, the softmax-weighted average of the values, since the common factor e^{-m} cancels. ∎

Scale reached: 4M-token contexts for a 7B model on 32 A100 GPUs (32× the best memory-efficient baseline), 16M tokens for a 3B model on a TPUv4-1024 pod. The same online softmax drives FlashAttention (LLMs ch. 2).

3.4. RAG or long context? Lost in the middle and the hybrid router

“Lost in the Middle” (N. Liu et al., 2023): when the information is placed in the middle of a long context, performance collapses in a U shape (beginning and end favored) — a 128k window does not “read” its 128k uniformly.

The RAG vs LC dossier: Li et al. (2024) compare systematically on long-context tasks: with sufficient resources, long context wins on average (retrieval can miss the needle).

But RAG remains much more economical — and their Self-Route (the model estimates whether the query is answerable with the retrieved excerpts; if not, the whole document is sent) stays close to LC quality at a much lower cost: 39% less with GPT-4o, 65% less with Gemini-1.5-Pro.

Xu et al. (ICLR 2024) complete the picture: retrieval improves models whatever the window (4k/16k/32k), and a 4k + retrieval approaches a 16k without retrieval — RAG is not dead, it is complementary.

Critical analysis

  1. “Needle in a haystack” (finding a sentence planted in a long text) is a retrieval test, not a long-context reasoning test — multi-document aggregation benchmarks break the scoreboard;
  2. the KV cache grows linearly with the context length L (LLMs Proposition 2.4, ML Ops module ch. 3): “free” LC at the API is an economic choice of the provider, not a physical property;
  3. RoPE extensions are measured in perplexity and in downstream tasks — YaRN shows they can diverge;
  4. Self-Route relies on the model’s self-assessment (meta-cognition): how good is it on adversarial queries?

To be related to ch. 4 (memory) and the ML Ops module ch. 6 (index cost vs context cost).

# Self-Route self-evaluation (sketch) -- RAG first, LC as fallback
def self_route(question, docs, llm, budget):
    snippets = retrieve(question, docs, k=8)          # classic RAG
    verdict = llm(f"Can you answer using ONLY these excerpts? "
                  f"(YES/NO)\n---\n{snippets}", max_tokens=2, temp=0)
    if verdict.strip().upper().startswith("YES"):
        return llm(f"Excerpts:\n{snippets}\nQuestion: {question}")
    return llm(f"Full documents:\n{concat(docs)}\nQuestion: {question}")
    # cost (Li et al. 2024): ~61% of full LC with GPT-4o, ~35% with Gemini-1.5-Pro

4. Memory: episodic, vector stores, GraphRAG

What a model sees is limited by its context window, and what it learned is frozen in its weights. This session compares the ways of giving an LLM a memory beyond both: raw key-value memories, episodic memory streams, memory paged by the model itself, and graph-structured memory.

Today’s readings Y. Wu et al., Memorizing Transformers, ICLR 2022 (arXiv:2203.08913); J. Park et al., Generative Agents: Interactive Simulacra of Human Behavior, UIST 2023 (arXiv:2304.03442); C. Packer et al., MemGPT: Towards LLMs as Operating Systems, 2023 (arXiv:2310.08560); D. Edge et al., From Local to Global: A Graph RAG Approach, 2024 (arXiv:2404.16130).

4.1. A taxonomy of memories

Type Cognitive analogue Implementation Example (paper)
Context working memory KV window — (cf. ch. 3 here, LLMs ch. 2)
Episodic event memories journal + retrieval (recency/importance/relevance) Generative Agents (2023)
External semantic knowledge vector store / index (RAG) LLMs ch. 7, ML Ops ch. 6
Structured — entity graph + summaries GraphRAG (2024)
Paged — context + external storage managed by the model MemGPT (2023)

4.2. Three papers, three ideas of memory

Proposition 4.1 — The retrieval triptych of generative agents The retrieval score of a memory s at time t for the query q reads \mathrm{score}(s; q, t) \;=\; w_r\, e^{-\Delta t/\tau} \;+\; w_i\, \mathrm{imp}(s) \;+\; w_p\, \cos\bigl(e(s), e(q)\bigr), exponential recency + importance (predicted by the LLM at writing time) + semantic relevance. This is exactly the score fusion of a search-engine reranker: a second stage that rescores the shortlist of a first retriever (BM25, NLP ch. 2) with a function of several signals — freshness, popularity, or a cross-encoder that reads the query and the document together (LLMs 7.2). “Agent memory” reinvents learning to rank; the originality lies in the reflection loop that creates new synthetic memories.

Critical analysis

  1. Evaluation: each of these papers evaluates memory differently (perplexity, simulated interviews, multi-session dialogues, global questions) — no consensus benchmark; wariness toward small-sample gains.
  2. Writing: the hard question is what one stores (everything? a summary? a graph?) and when one forgets; MemGPT delegates to the model, GraphRAG to a pipeline — two philosophies (agency vs infrastructure).
  3. The return of context: with windows of a million tokens (ch. 3), “keep everything in the context” becomes credible again — until the next “lost in the middle”.
  4. LLGA position: graph-structured memory is the exact place where the master crosses its two legs (LLMs + graphs); ch. 8 comes back to it.

5. Mixture-of-Experts

A larger model is usually better but costs more per token. Mixture-of-experts layers break this link by activating only a few sub-networks per token; this session reads how the routing works, how the load is balanced, and what the experts actually learn.

Today’s readings N. Shazeer et al., Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer, ICLR 2017 (arXiv:1701.06538); W. Fedus, B. Zoph, N. Shazeer, Switch Transformers, JMLR 2022 (arXiv:2101.03961); A. Jiang et al., Mixtral of Experts, 2024 (arXiv:2401.04088); DeepSeek-AI, DeepSeek-V3 Technical Report, 2024 (arXiv:2412.19437).

Definition 5.1 — Sparse MoE layer, recalled from LLMs ch. 2

Each feed-forward block is replaced by n_E experts E_1, \dots, E_{n_E} and a router (LLMs ch. 2); only the k strongest experts are computed (k = 1–2 typically): y \;=\; \sum_{i \in \mathrm{TopK}(g(x))} g_i(x)\, E_i(x), \qquad g(x) = \mathrm{softmax}\bigl(W_g\,x\bigr). Capacity grows, cost per token does not: Mixtral 8×7B has ~47B parameters, ~13B active; DeepSeek-V3 has 671B, ~37B active.

5.1. Balancing the experts: the auxiliary loss

Proposition 5.2 — Auxiliary load-balancing loss (Switch) With f_i = fraction of the k \cdot T routing slots of a batch of T tokens sent to expert i, and P_i = average router probability mass on i:

Key result — load-balancing loss \mathcal{L}_{\text{aux}} \;=\; \alpha_{\text{aux}}\, n_E \sum_{i=1}^{n_E} f_i\, P_i, \qquad \sum_i f_i = \sum_i P_i = 1,

whose minimum \mathcal{L}_{\text{aux}} = \alpha_{\text{aux}} is reached at uniform routing f = P = \mathbf{1}/n_E.

The loss penalizes the degenerate routing where a few experts capture everything — otherwise the router gradient collapses (the unpicked experts receive no gradient: the rich get richer).

Proof. At the uniform point, \sum_i f_iP_i = n_E \cdot \frac{1}{n_E} \cdot \frac{1}{n_E} = \frac{1}{n_E}, \quad \text{so} \quad \mathcal{L}_{\text{aux}} = \alpha_{\text{aux}}\, n_E \cdot \frac{1}{n_E} = \alpha_{\text{aux}}.

To show that this is indeed a minimum in the targeted regime, we use Chebyshev’s sum inequality: if the sequences (f_i) and (P_i) are similarly ordered (co-monotone — the likely experts are also the most loaded, exactly the degenerate regime that we want to penalize), then \frac{1}{n_E} \sum_i f_i P_i \;\geq\; \Bigl(\frac{1}{n_E} \sum_i f_i\Bigr)\Bigl(\frac{1}{n_E} \sum_i P_i\Bigr) = \frac{1}{n_E^2}, \qquad\text{i.e.}\qquad \sum_i f_i P_i \;\geq\; \frac{1}{n_E}, with equality if and only if one of the sequences is constant. Hence \mathcal{L}_{\text{aux}} \geq \alpha_{\text{aux}}, equality at uniform.

Finally, the dynamic effect: \partial (f_iP_i)/\partial P_i = f_i \geq 0 — the gradient pulls P_i down proportionally to the load f_i: a negative feedback loop against concentration. ∎

Critical analysis — read the hidden assumption The lower bound is only proved for co-monotone (f, P): an anti-monotone pair (a very likely but lightly loaded expert) could have a product below 1/n_E — the loss is not a symmetric divergence in the strict sense; it is a load proxy whose gradient dynamics does most of the work.

This is exactly the kind of detail a critical paper reading must catch: what quantity does the loss actually measure, under what assumption, and what does its gradient do?

DeepSeek-V3 goes as far as replacing the loop with auxiliary-loss-free balancing: a per-expert bias term, dynamically adjusted to the observed load — direct control rather than a differentiable penalty, with reported quality gains. Less elegant, more effective: up for debate.

5.2. What the experts learn

The Mixtral routing analysis finds no clear specialization by topic — ArXiv, biology and philosophy texts are routed alike, DM Mathematics only slightly differently — but a syntactic one: Python’s self, indentation tokens and consecutive tokens often go to the same expert. The MoE mostly democratizes capacity, not a division of labor by subject.

DeepSeek-V3 pushes two structural innovations: fine-grained experts (more numerous, smaller) + shared experts (always active, capturing cross-cutting knowledge — reducing the redundancy), and FP8 training at scale (14.8T tokens) — the technical report is a systems-engineering course in itself (expert-parallel communication, cf. Emerging ML module ch. 2 on distributed computing).

Critique in practice — what are the “active parameters” for? Comparing a 47B/13B-active MoE to a 13B dense model is misleading: the MoE keeps 47B in memory (cf. ML Ops module ch. 3: the KV cache and the weights reside in full in VRAM) but ~13B of compute per token. MoE wins provided large batches (amortizing memory through throughput): excellent for shared serving, debatable for single-user. The LLGA reading grid: every architecture must be evaluated at full cost (memory, compute, communication) — not in advertising “parameters”.

6. Alternative architectures: SSM, Mamba, RWKV

Attention costs grow with the square of the sequence length and its cache grows linearly. This session reads the architectures that replace it with a recurrent state of fixed size — state space models, Mamba, RWKV — and the hybrids that keep a little attention for exact recall.

Today’s readings A. Gu, K. Goel, C. Ré, Efficiently Modeling Long Sequences with Structured State Spaces (S4), ICLR 2022 (arXiv:2111.00396); A. Gu & T. Dao, Mamba: Linear-Time Sequence Modeling with Selective State Spaces, 2023 (arXiv:2312.00752); B. Peng et al., RWKV: Reinventing RNNs for the Transformer Era, Findings of EMNLP 2023 (arXiv:2305.13048); S. De et al., Griffin: Mixing Gated Linear Recurrences with Local Attention for Efficient Language Models (Hawk / Griffin), ICML 2024 (arXiv:2402.19427); AI21, Jamba: A Hybrid Transformer-Mamba Language Model, 2024 (arXiv:2403.19887).

6.1. From RNNs to state space models

Definition 6.1 — Discrete SSM A state space model maps the input u_t to the output y_t via a linear hidden state x_t \in \mathbb{R}^d: x_{t} = \bar A\, x_{t-1} + \bar B\, u_t, \qquad y_t = C\, x_t, where (\bar A, \bar B) come from the (zero-order) discretization of the continuous system \dot x = A x + B u with step \Delta: \bar A = \exp(\Delta A), \qquad \bar B = (\Delta A)^{-1}\bigl(\exp(\Delta A) - I\bigr)\,\Delta B. The classic RNN reappears with a structured state matrix (S4: diagonal + low-rank terms, inherited from HiPPO to memorize the long history).

Proposition 6.2 — LTI ⇒ convolution (S4) If (\bar A, \bar B, C) are constant (independent of time and input — LTI), then the system is a convolution product: y_t = \sum_{s=0}^{t} \overline{K}_s\, u_{t-s}, \qquad \overline{K} = \bigl(C\bar B,\; C\bar A \bar B,\; C\bar A^2 \bar B,\; \dots\bigr), computable in \mathcal{O}(L \log L) by the FFT (box below): parallel training over the whole sequence, like a transformer.

Proof. Let us unroll the recurrence from x_{-1} = 0 (zero initial state): x_0 = \bar B u_0; \qquad x_1 = \bar A \bar B u_0 + \bar B u_1; by immediate induction, x_t = \sum_{s=0}^{t} \bar A^{\,t-s}\, \bar B\, u_s. Then y_t = C x_t = \sum_{s=0}^{t} (C \bar A^{\,t-s} \bar B)\, u_s = \sum_{s=0}^{t} \overline K_{t-s}\, u_s , a discrete convolution with kernel \overline K_s = C \bar A^s \bar B, where the structure of \bar A (diagonal) makes each term computable in \mathcal{O}(d). ∎

FFT convolution in three steps To compute the causal convolution y = \overline K * u over L steps: zero-pad the kernel and the input to twice that length, so that the circular convolution computed by the FFT does not wrap around; multiply their two FFTs entrywise; invert, and keep the first L entries. Three FFTs of size 2L cost \mathcal{O}(L \log L), against \mathcal{O}(L^2) for the direct sum.

6.2. Mamba: making the state selective

The LTI SSM is a fixed filter: it cannot choose to memorize or forget depending on the content. Mamba (Gu & Dao, 2023) makes \Delta_t, B_t, C_t functions of the input (linear projections of u_t, through a softplus for \Delta_t), hence \bar A_t, \bar B_t too: the selection.

Cascade consequence: the convolution (prop. 6.2) is destroyed (the kernel depends on position) → back to a recurrence, but parallelizable via the prefix scan (box below) with fused GPU kernels (“hardware-aware”): \mathcal{O}(L) training, \mathcal{O}(1) inference per token and constant state memory — the selling point against the transformer’s KV cache (cf. ML Ops module ch. 3).

Prefix scan (Blelloch, 1990) Given an associative operation \circ, a scan returns all the prefixes a_1 \circ \dots \circ a_t. A balanced tree computes them in \mathcal{O}(\log L) parallel steps and \mathcal{O}(L) work: an up-sweep combines neighbouring pairs, a down-sweep hands each prefix back. For the selective SSM, the elements are the pairs (\bar A_t, \bar B_t u_t), combined by (A, b) \circ (A', b') = (A'A,\; A'b + b'), which composes two steps of x_t = \bar A_t x_{t-1} + \bar B_t u_t.

Finally, Mamba embeds the SSM inside a gated MLP-style block. Mamba-2 (SSD) will reformulate the SSM as a form of linear attention — the loop with attention comes full circle.

6.3. RWKV and the hybrids

Proposition 6.3 — RWKV: attention linearized into an RNN (Peng et al., 2023) At each step, RWKV-4 computes from the current token, mixed with the previous one (token shift), a receptance r_t, a key k_t and a value v_t (linear projections, used channel by channel). Its time-mixing operator “WKV” is a softmax-like average of the past values, with weights e^{k_i} that decay by a factor e^{-w} per step: \mathrm{wkv}_t = \frac{\sum_{i<t} e^{-(t-1-i)w + k_i}\, v_i \;+\; e^{u + k_t}\, v_t}{\sum_{i<t} e^{-(t-1-i)w + k_i} \;+\; e^{u + k_t}} , where w \geq 0 is a learned per-channel decay and u a per-channel bonus for the current token. The block outputs \sigma(r_t) \odot \mathrm{wkv}_t, followed by an output projection.

The two sums obey a recurrence on two state vectors: a_t = e^{-w} \odot a_{t-1} + e^{k_t} \odot v_t, \qquad b_t = e^{-w} \odot b_{t-1} + e^{k_t}, \mathrm{wkv}_t = \frac{a_{t-1} + e^{u+k_t} \odot v_t}{b_{t-1} + e^{u+k_t}} . This is a linear attention normalized over time: trainable in parallel like a transformer, executable as an RNN with a state of constant size.

At scale: models up to 14B — the largest dense RNNs ever trained at its publication.

Hybrids: pure SSMs lose on exact recall tasks (copying an association seen a long time ago: the compressed state has no room to keep everything — a recurring critique, cf. the associative recall studies).

Hence mixed architectures: Jamba (AI21, 2024) interleaves attention and Mamba layers at a 1:7 ratio — one attention layer in each block of eight — with an MoE replacing the MLP every other layer, and shows that this one attention layer in eight suffices to restore recall and in-context learning; Griffin/De et al. (2024) alternate recurrence (RG-LRU) and local attention.

The 2024-2026 consensus: attention is irreplaceable for precise retrieval; the SSM excels at long context on a constant memory budget; the hybrid beats both.

Critical analysis

  1. The “Mamba matches transformers at X times less memory” curves are established at calibrated data and compute sizes; transformers have an ecosystem (serving, quantization, ch. 7) that SSMs lack — the real adoption cost exceeds the paper.
  2. Exact recall is a limit case (one key among millions): needle-in-a-haystack-style benchmarks are highly sensitive to it, comprehension tasks far less so.
  3. RWKV illustrates the virtue of deployable simplicity (keys and values, but no growing KV cache: the state has a fixed size); Mamba that of algorithmic design (the scan).
  4. A favorite exam question: “why is the transformer KV cache a feature and not just a cost?” — because it stores the history exactly (perfect recall), where the SSM state summarizes it.

7. Efficiency: speculative decoding, quantization

Serving a large model is limited by latency and memory. This session proves why speculative decoding speeds up generation without changing its distribution, and how GPTQ and AWQ quantize weights to 4 bits with little loss.

Recap — LLMs module ch. 6

Inference: memory-bound at decoding, KV cache, quantization of weights (INT8/4). Here we demonstrate the two star test-time mechanisms: speculative decoding (which buys latency with a small model) and weight-only post-training quantization (GPTQ, and AWQ, whose scales are chosen from the activations). For costs and green ops: cf. ML Ops module ch. 4 and 10.

Today’s readings Y. Leviathan, M. Kalman, Y. Matias, Fast Inference from Transformers via Speculative Decoding, ICML 2023 (arXiv:2211.17192); C. Chen et al., Accelerating Large Language Model Decoding with Speculative Sampling, 2023 (arXiv:2302.01318); E. Frantar et al., GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers, ICLR 2023 (arXiv:2210.17323); J. Lin et al., AWQ: Activation-aware Weight Quantization, MLSys 2024 (arXiv:2306.00978).

7.1. Speculative decoding: the small proposes, the large disposes

Definition 7.1 — Speculative decoding (Leviathan et al., 2023), recalled from LLMs Theorem 6.3

A small draft model q proposes \gamma tokens; the large target p checks them in one parallel pass. Each proposal is kept with probability \min(1, p/q) at that token; the first rejected one is replaced by a sample from \mathrm{norm}(\max(0, p - q)).

The output is distributed exactly as p (LLMs Theorem 6.3); typical speedups ×2–3.

Theorem 7.2 — Expected number of tokens per iteration If \alpha is the (average) probability that a token of q is accepted by p, the expected number of tokens generated per full iteration (verification + correction) is

Key result — speculative decoding \mathbb{E}[\#\text{tokens}] \;=\; \frac{1 - \alpha^{\gamma + 1}}{1 - \alpha}.

With \alpha = 0.8 and \gamma = 4: ≈ 3.36 tokens per target pass instead of 1.

Proof. Let A be the number of tokens accepted before the first rejection. The acceptance of each token is modeled as independent with probability \alpha; then A \sim \mathrm{Geo}(\alpha) truncated at \gamma:

  • in case of rejection at position j < \gamma, the iteration produces j tokens accepted plus the corrected token, i.e. j+1 tokens;
  • if all \gamma are accepted, the pass produces \gamma tokens plus one bonus token sampled from p (position \gamma{+}1 is directly generated by the target in the same pass).

In both cases: j+1 tokens for all j \leq \gamma. Hence \mathbb{E} = \sum_{j=0}^{\gamma-1} (1-\alpha)\,\alpha^{j}\,(j+1) \;+\; \alpha^{\gamma}\,(\gamma + 1). We recognize the truncated series of the geometric expectation: by using \sum_{j=0}^{m} \alpha^j = \frac{1-\alpha^{m+1}}{1-\alpha} and its derivative for the (j+1) factor, the sum reduces exactly to \frac{1-\alpha^{\gamma+1}}{1-\alpha}. ∎

Critical analysis The gain depends on three clocks: \alpha (small/large agreement — high on ordinary text, low on tricky code or creative outputs); the cost ratio c of one draft step to one target step (an iteration costs about \gamma c + 1 target steps); \gamma (too large = many rejections at the last rank).

Leviathan et al. give the optimal \gamma as a function of (\alpha, c) — a lab exercise. Descendants: self-speculation (the model verifies itself via skipped layers), multiple heads (Medusa), trees — to be documented in your tech watch.

7.2. Quantization: GPTQ and AWQ

Proposition 7.3 — GPTQ (Frantar et al., 2023): layer by layer, Hessian in hand Quantize W into \hat W (e.g. 4 bits, with an error \Delta = W - \hat W) by minimizing the error on the outputs actually produced: \min_{\hat W}\; \bigl\| W X - \hat W X \bigr\|_F^2 \;=\; \min_{\Delta}\; \mathrm{tr}\bigl(\Delta\, X X^\top\, \Delta^\top\bigr), \qquad H = 2 X X^\top, where X is a sample of calibration activations.

The algorithm proceeds column by column (greedy): quantize a block of weights, compute the error on the outputs, propagate it onto the remaining columns via the Cholesky factor of H^{-1} — the Optimal Brain Surgeon update (box below), made GPU-friendly.

Models with billions of parameters are quantized to ~4 bits in a few GPU-hours, with low perplexity losses.

Optimal Brain Damage and Surgeon, in three lines OBD (LeCun et al., 1990, diagonal Hessian) and OBS (Hassibi & Stork, 1993, full Hessian) prune a trained network with the second-order expansion of its loss, of Hessian H. Removing weight w_q increases the loss by \frac{w_q^2}{2\,[H^{-1}]_{qq}}, once the other weights receive the best correction \delta w = -\frac{w_q}{[H^{-1}]_{qq}}\, H^{-1} e_q . GPTQ rounds instead of removing: w_q becomes the rounding error w_q - \mathrm{quant}(w_q), spread by the same update over the columns not yet quantized.

Proposition 7.4 — AWQ (Lin et al., 2024): protecting the salient channels Observation: about 1% of the weight channels are salient — those that multiply the input channels of largest activation magnitude; rounding them naively costs most of the quality.

AWQ does not keep them in higher precision — it rescales: multiplying a salient weight column by s > 1 and dividing the matching input channel by s leaves the layer’s output unchanged, while shrinking the relative rounding error of the salient weights. The per-channel scales are found by a grid search on calibration activations, without backpropagation.

Result: robust 4 bits, no mixed-precision format, commodity deployment.

Method Idea Cost/advantage Limitation
Speculative small proposes, large verifies ×2-3 latency, exact distribution needs a good draft; gain varies by domain
GPTQ Hessian-guided quantization ~4 bits, a few hours of calibration long-context degradation; tune the groups
AWQ scaling of salient channels robust 4 bits, no backprop same low-end limits (3 bits and below)
(recap) Prefix caching shared KV nearly free prefilling prefixes actually shared (ML Ops ch. 4)

Critical analysis Perplexity is a poor downstream proxy: a 4-bit model nearly identical in PPL can lose points on long reasoning or safety (learned refusals are subtle — cf. Explainability, Security and Privacy of LLMs ch. 6); always re-evaluate after quantization on the golden set (ML Ops module ch. 2). Energy: quantization is the #2 green ops lever (ML Ops ch. 10), after functional sobriety.

8. LLMs × graphs: the LLGA crossroads

Can an LLM reason about a graph, and what is the best way to give it one? This session reads the benchmarks that test LLMs on serialized graphs, the study showing how much the serialization matters, and the hybrid that feeds a GNN encoding of a retrieved subgraph to the LLM.

Today’s readings H. Wang et al., Can Language Models Solve Graph Problems in Natural Language? (NLGraph), NeurIPS 2023 spotlight (arXiv:2305.10037); B. Fatemi, J. Halcrow, B. Perozzi, Talk like a Graph: Encoding Graphs for Large Language Models, ICLR 2024 (arXiv:2310.04560); X. He et al., G-Retriever: Retrieval-Augmented Generation for Textual Graph Understanding and Question Answering, NeurIPS 2024 (arXiv:2402.07630).

Graph tokens and KG completion: J. Tang et al., GraphGPT: Graph Instruction Tuning for Large Language Models, SIGIR 2024 (arXiv:2310.13023); R. Chen et al., LLaGA: Large Language and Graph Assistant, ICML 2024 (arXiv:2402.08170); Y. Wei et al., KICGPT: Large Language Model with Knowledge in Context for Knowledge Graph Completion, Findings of EMNLP 2023 (arXiv:2402.02389); S. Pan et al., Unifying Large Language Models and Knowledge Graphs: A Roadmap, IEEE TKDE 2024 (arXiv:2306.08302).

8.1. The “bare” LLM facing serialized graphs

Pivotal result — NLGraph (Wang et al., 2023) 29,370 problems in natural language covering 8 tasks — connectivity, cycle, topological sort, shortest path, maximum flow, bipartite matching, Hamilton path and simulating a GNN — at increasing difficulty (graph size, number of steps). GPT-3/GPT-4 clearly beat chance on the easy tasks… and collapse on the hard ones.

The authors propose two prompting methods: Build-a-Graph (the model first restates the graph) and Algorithmic prompting (the model first recalls the algorithm). Both help on the easier tasks, without closing the gap with a few-line algorithm.

Measured conclusion: LLMs have a preliminary graphical intuition, not an algorithmic skill.

Proposition 8.1 — Encoding is a first-order variable (Fatemi et al., 2024) “Talk like a Graph” systematically studies how to serialize a graph: nine encodings (edge lists, incidence lists, named people as friends or co-authors…), several question phrasings and graph generators, on PaLM 62B and PaLM 2. Findings:

  1. the right encoding raises accuracy by 4.8% to 61.8% depending on the task — e.g. listing each node with its neighbours (incident encoding) gives 53.8% on “connected nodes”, against 19.8% for an edge list;
  2. integer node names help counting tasks (degree, numbers of nodes and edges); asking an application question (“are these two people friends?”) often beats the graph phrasing;
  3. the structure of the graph matters: cycle check reaches 91.7% on complete graphs but 5.9% on path graphs.

Takeaway: serializing a graph is a design act, not a formality.

8.2. Hybridizing: GNN encoders and graph tokens

Definition 8.2 — G-Retriever (He et al., NeurIPS 2024) To answer questions over a large textual graph (scenes, knowledge maps):

  1. retrieve the relevant subgraph by formulating retrieval as a prize-collecting Steiner tree (PCST — “relevant” nodes carry prizes, edges carry costs: maximize prize − cost of the connected subtree);
  2. encode the subgraph with a GNN (message passing — Graph ML module ch. 5);
  3. mean-pool and project its output into one soft token (the graph token), placed before the textualized subgraph and the question;
  4. train the GNN and the projector with the LLM frozen (prompt tuning), or with LoRA on the LLM as well.

Reported on ExplaGraphs/SceneGraphs/WebQSP: better answers and fewer hallucinations (SceneGraphs: 62% of answers cite only existing nodes and edges, against 8% for prompt tuning). On WebQSP, retrieval keeps about 18 of 1,371 nodes and cuts the prompt from about 100k to 600 tokens.

A second family, graph instruction tuning, teaches a frozen LLM to read graph tokens, as LLaVA teaches it to read image tokens.

Definition 8.3 — Graph instruction tuning: GraphGPT and LLaGA A node’s neighbourhood is turned into a short sequence of embeddings, and a small projector maps them into the LLM’s token space; only the projector is trained.

  • GraphGPT (Tang et al., 2024): a graph transformer, aligned with node texts by a contrastive loss, encodes the subgraph. Stage 1 tunes the projector on graph matching (reorder shuffled node texts to match their graph tokens); stage 2 on node classification and link prediction, with chain-of-thought rationales from GPT-3.5.
  • LLaGA (Chen et al., 2024) uses no GNN: a template samples a fixed-shape 2-hop tree (10 neighbours per hop, padded) and flattens it in level order, each node carrying its text embedding and a Laplacian positional encoding; a second template averages each hop instead.

Both keep a Vicuna-7B frozen and report zero-shot transfer to unseen graphs; GraphGPT, for instance, is tuned on ogbn-arxiv and tested on PubMed and Cora.

8.3. Map of the field (the “roadmap”)

The last column uses the taxonomy of Graph ML 10.2, shared with Advanced GNN 8.3.

Paradigm Who does what Examples Graph ML 10.2 category
LLM-centric the LLM reasons; the graph is serialized NLGraph, Talk like a Graph serialization and pseudo-code prompting (no GNN)
GNN-centric the GNN or a template encodes; the LLM reads soft tokens G-Retriever, GraphGPT, LLaGA (a) soft tokens
KG-enhanced LLM the graph feeds the prompt/retrieval GraphRAG (ch. 4), G-Retriever’s PCST step (b) structural recall
LLM-augmented KG the LLM builds/completes the graph entity extraction, KG completion (8.4) (c) cross-distillation, LLM → graph direction
Systems hybrid industrial pipelines Microsoft GraphRAG (ML Ops module ch. 6) (a)–(c) combined

8.4. LLMs that complete knowledge graphs

Many true triples (h, r, t) are missing from any knowledge graph. KG completion ranks candidate tails t for a query (h, r, ?). Embeddings such as TransE (Graph ML ch. 6) or its rotation variant RotatE score triples by geometry alone; an LLM adds the entities’ text and its pre-training knowledge.

Evaluation: filtered MRR and Hits@k on FB15k-237 and WN18RR. A caution from ch. 1: Freebase facts are largely on Wikipedia, so an LLM may remember a “missing” triple rather than infer it.

Critical analysis — the LLGA session par excellence

  1. Benchmarks: NLGraph and friends are small and synthetic; real “enterprise graphs” are noisy, attributed, dynamic — the gulf is wide.
  2. Prompt cost: serializing G=(V,E) costs \mathcal{O}(|V| + |E|) tokens — a modest 105-edge graph saturates any window (ch. 3): compression (summaries, subgraphs, PCST) is not optional.
  3. Circular evaluation: judging graph answers with an LLM-judge (ch. 1) — is an LLM fit to judge what it can barely do?
  4. Open LLGA question: what share of the “LLM × graph” tasks will reduce to long context + good data (ch. 3-4), and what share will require a real structural component (a GNN, or graph tokens)?

This is the research question of the master. The Year 2 transverse project Y2.1 tests it on biomedical question answering: GraphRAG, a GNN retriever or graph tokens, per query type.

# Same task, three encodings: a "talk like a graph" experiment in 10 lines
# (enc_degree, a degree-sorted edge list, is our variant, not one of the paper's nine)
def enc_edges(G):     return "\n".join(f"{u} -- {v}" for u, v in G.edges())
def enc_degree(G):    # edges sorted by decreasing endpoint degree
    d = dict(G.degree())
    es = sorted(G.edges(), key=lambda e: -(d[e[0]] + d[e[1]]))
    return "\n".join(f"{u} -- {v}" for u, v in es)
def enc_incident(G):
    return "\n".join(f"{u} : " + ", ".join(map(str, G[u])) for u in G)

for enc in (enc_edges, enc_degree, enc_incident):
    acc = run_gpt(enc(G), task="connectivity", n=100)
    print(f"{enc.__name__:14s} acc={acc:.2f}  tokens~{len(enc(G))//4}")

9. Agents: planning, tools, multi-agents

An agent is an LLM that acts in a loop: it reasons, calls a tool, reads the result and continues. This session reads the papers that defined this loop, taught models when to call tools, let them learn from their failures in context, and organized several agents together — and asks how reliable long chains of actions can be.

Today’s readings S. Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models, ICLR 2023 (arXiv:2210.03629); T. Schick et al., Toolformer: Language Models Can Teach Themselves to Use Tools, NeurIPS 2023 (arXiv:2302.04761); N. Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning, NeurIPS 2023 (arXiv:2303.11366); Q. Wu et al., AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation, 2023 (arXiv:2308.08155); G. Li et al., CAMEL: Communicative Agents for Mind Exploration, NeurIPS 2023 (arXiv:2303.17760).

9.1. ReAct: reasoning and acting

The ReAct prompt alternates reasoning traces (Thought) and actions (Action / Observation) within a single trajectory: the model unrolls “thought → action → observation → thought → …”. On FEVER (fact checking), ReAct beats pure chain-of-thought (accuracy 60.9 against 56.3): the world answers, so it hallucinates fewer facts. On HotpotQA it stays below CoT (exact match 27.4 against 29.4) because uninformative search results derail its reasoning; the best scores (35.1) come from combining ReAct with self-consistent CoT.

On ALFWorld and WebShop the comparison is with acting alone and with imitation or RL agents, and ReAct wins clearly: 71% success on ALFWorld against 45% for Act-only and 37% for BUTLER — the observations are interpreted.

It becomes the default grammar of agents — that of the native “function calls” of current LLMs. RL link ch. 7: ReAct is a policy over an interaction tree; the chain-of-thought, its narrative value function.

9.2. Toolformer: learning where to call the tools

Proposition 9.1 — Toolformer’s self-training criterion For each candidate position t, insert an API call annotated c(t) (the call and its result); compare the next-token prediction loss without the call vs with its result provided: I_t \;=\; -\log p_\theta\bigl(x_t \mid x_{<t}\bigr) \;+\; \log p_\theta\bigl(x_t \mid x_{<t}, c(t)\bigr), (schematic form): I_t > 0 — the call reduces the loss — flags a useful call.

The model itself filters its own retained calls, trains on them, and learns to decide when to compute (calculator, retrieval, translation, calendar…) — the direct precursor of the native tool-calls of current LLMs (LLMs module ch. 8).

9.3. Reflection, multi-agent, and the question of emergence

Proposition 9.2 — The unforgiving arithmetic of chains A k-step task with per-step success p succeeds with p^k (independence): p = 0.98, \quad k = 50 \quad\to\quad 36\%. For a reliable agent, three levers: shorten the chains (composite tools), make each step reliable (Reflexion, retries, deterministic tools), and avoid long chains where an algorithm exists — an agent that plans a topological sort step by step is an architecture mistake (ch. 8: NLGraph).

Critical analysis

  1. Evaluation: agent gains are measured on environments (ALFWorld, HumanEval, SWE-bench-like) whose fidelity to the real world is debated — unmodeled costs (ML Ops ch. 4/8), noisy environment, absent adversary.
  2. Multi-agent emergence: when “several agents” beat “one agent”, is it emergence — or the effect of a better prompt / more compute? Several ablation studies suggest the second reading: demand honest ablations (a single agent, same token budget).
  3. Safety: every tool is an injection surface (LLMs 9.4; in depth in Explainability, Security and Privacy of LLMs ch. 5–6); multi-agent environments multiply implicit trusts — the least-privilege pattern (ML Ops ch. 8-9) remains the only serious defense.
  4. RL link: the LLM agent as a policy — agentic “behaviors” are now trained by RLVR on trajectories (ch. 2): the prompt/training boundary is shifting under our eyes.

10. Open problems

The seminar ends with problems that no one has solved yet: the finite stock of human text, the risk of training on generated data, and updating a model without retraining it. Each is a source of internship and thesis topics.

Today’s readings P. Villalobos, A. Ho, J. Sevilla, et al., Will we run out of data? Limits of LLM scaling based on human-generated data, ICML 2024 (arXiv:2211.04325, revised 2024; first version 2022); I. Shumailov et al., AI models collapse when trained on recursively generated data (the “curse of recursion”), Nature 2024; H. Yu et al., Continual Learning of Large Language Models: A Comprehensive Survey, 2024 (arXiv:2402.01344).

10.1. Data exhaustion

Proposition 10.1 — The Villalobos et al. (2024) window The stock of public text produced by humans is finite: about 3 × 1014 tokens (300 trillion) once quality and repetition are accounted for, while the training sets of frontier models grow exponentially.

By extrapolating the two curves, the 2024 version of the study (ICML 2024) concludes that models will be trained on the whole stock between 2026 and 2032, earlier if they are heavily over-trained. Its 2022 first version predicted that high-quality language data would run out before 2026. This is not a prediction of progress stopping but a regime change: the constraint shifts to the data side.

The answers in progress:

10.2. Continual learning

LLMs are frozen at publication: any change requires a new training run or a fine-tune (with its train: catastrophic forgetting of earlier capabilities, safety regression — ML Ops module ch. 2 and 7).

Continual learning targets incremental updating: replay of a core of experiences, regularization toward the previous weights, additive modules (successive LoRAs — LLMs 4.3, versioned in ML Ops ch. 7), model merging (combining the weights of specialists — simple averages, TIES: surprising and under-theorized results).

The Yu et al. (2024) survey maps the field; the honest assessment: no scheme dominates yet, and the success criterion itself is blurry (remember what, from how many versions back?).

10.3. Other fronts — and conclusion of the seminar

Module conclusion The seminar had you read ten families of papers with a single grid: claim, evidence, costs, reproducibility, LLGA link. This is the skill the master wants to install: quickly read the essentials, doubt methodically, and connect every advance to the complete system (data → training → serving → evaluation → safety) described by the LLMs, ML Ops and Explainability/Security/Privacy modules.

Exercises / Labs

  1. ★ Reading notes (running thread). One sheet per session (claim / evidence / costs / reproducibility / LLGA link) on the pivotal paper; two sheets graded in depth: DeepSeek-R1 (ch. 2) and G-Retriever (ch. 8).
  2. ★ Self-consistency (ch. 2). On a GSM8K sample: greedy vs self-consistency (k = 5, 20); plot accuracy vs k and accuracy vs cost (tokens); check that voting on the final answer extracted beats voting on the raw chain — why?
  3. ★ Speculative decoding (ch. 7). Code the draft/verify scheme with residual re-sampling; verify empirically thm. 7.2 (count the tokens/iteration for measured \alpha); find the optimal \gamma for (\alpha, c) measured on your machine.
  4. ★ Contamination (ch. 1). The ch. 1 n-gram detector on a small corpus; build 20 re-generated variants of a toy benchmark; measure the raw/variant gap for two models — and the judges’ asymmetry (alternating order) on MT-Bench-like setups.
  5. ★★ Toy RLVR (ch. 2). Implement a mini-GRPO (cf. LLMs module ch. 5) with a binary format reward on a small model; observe the lengthening of the generations — a domestic “aha moment”; discuss reward hacking (does the model cheat the format?).
  6. ★★ RoPE and extension (ch. 3). Numerically verify prop. 3.2 (dot products invariant under translation); extend a small model 512 → 2048 by interpolation then by YaRN (Definition 3.3); compare perplexity and a recall task (needle) before/after.
  7. ★★ Simulated ring attention (ch. 3). Implement blockwise attention with ring passing over 4 simulated “GPUs” (processes), with the online-softmax recurrence of Proposition 3.4; verify exactness vs dense attention; measure communication vs compute (overlap).
  8. ★★ Agent memory (ch. 4). Build a memory stream with the recency/importance/relevance triptych (prop. 4.1); add the reflection loop; test on 20 simulated sessions; ablation of each component of the score.
  9. ★★ MoE routing (ch. 5). Load Mixtral (open weights) and instrument the router; measure the load distribution per expert over 3 corpora (code, math, prose); reproduce the specialization figure — and its variability; implement the auxiliary loss of Switch on a toy MoE and show the balancing.
  10. ★★ SSM scan (ch. 6). Implement the SSM recurrence then the prefix scan (prop. 6.2 for the LTI case; selective version for Mamba); compare the GPU memory of the three modes (recurrence / FFT convolution / scan) on L = 8k; test the exact recall of a distant association — transformer vs SSM (the ch. 6 critique).
  11. ★★ Agents (ch. 9). A ReAct agent with 3 tools, one of them unreliable (bad output); measure per-step p and the p^k law (prop. 9.2); add Reflexion and measure gain vs cost; multi-agent ablation: 2 “specialized” agents vs 1 agent with the same token budget.
  12. ★★★ Graph encodings (ch. 8). Reproduce “Talk like a Graph” on 3 NLGraph tasks × the 3 encodings of the ch. 8 code, plus one of the paper’s nine encodings that the code does not cover (friendship, for instance); test the hypothesis “it is the structure, not the length” by matching lengths; a light G-Retriever: replace the PCST with a weighted shortest path and compare.
  13. ★★★ Mini-review (ch. 10). Write a 4-page “position paper”: “In 2030, will knowledge live in the weights, the context or the index?” — drawing on at least six chapters of the seminar and two modules of the master.
  14. ★★★ Graph tokens and LLM knowledge-graph completion (ch. 8). A reading half and a reproduction half.
    • Reading: compare GraphGPT and LLaGA (Definition 8.3) with the grid of ch. 0 — what is trained, what is frozen, and what the zero-shot transfer tables really support.
    • Reproduction, a simplified KICGPT: on 500 test queries of FB15k-237, rank the gold tail among the top 20 candidates of a RotatE model (PyKEEN). Compare RotatE alone with an open 7–8B instruction model that reranks the 20 candidates, with and without KG triples as demonstrations; report filtered MRR and Hits@1.
    • Check with the tools of ch. 1 whether the LLM’s gain comes from memorized Wikipedia facts: rerun on queries whose entity names are replaced by codes.

Projects and assessment

The fiche of this module displays no assessment: the SynapseS 2026–2027 sheet is not published and the wiki gives no modality for the M2 courses (see the introduction), so the official assessment is “not displayed”. Everything below is a proposal. It keeps the seminar’s running deliverable, the reading-note portfolio of Ex. 1, adds one project (solo or in a group) and a mock written exam.

The projects exercise objectives O3 (large language models) and O5 (graphs × LLMs) at their core, with O7 (hands-on practice: budgets, reproducible harnesses) and O8 (trustworthy evaluation: contamination, judges, hallucinations). The graph and agent subjects prepare the Year 2 transverse projects Y2.1 (graph-based question answering), Y2.2 (verifiable rewards) and Y2.4 (agent reliability).

Solo projects

  1. [Solo · ≈ 20 h] An honest leaderboard: contamination and judge calibration. Question: how much of a benchmark score survives a contamination check, and how far can an LLM judge be trusted? Chapters used: ch. 1, 2.
    • Implement a reusable harness: the 13-gram overlap detector of ch. 1 run against a public pre-training sample (a shard of Dolma, Soldaini et al., 2024), and 20 or more regenerated variants of GSM8K items (Cobbe et al., 2021) with new numbers and names. Report each score as the raw / variant / overlap triple of Proposition 1.2.
    • Calibrate an open LLM judge on the 3.3k expert votes of the MT-Bench human judgments (Zheng et al., 2023), in both answer orders; measure agreement, the position-flip rate and a verbosity bias (pad correct answers).
    • Models: two or three open instruction models of 1–8B parameters, on a free GPU tier.
    • Deliverables: code, a 4–6 page report, a 10-minute talk. Success: every score given with a 95% interval and its variant gap; the judge’s agreement with humans, with an interval, set against the 81% human–human level (ties excluded).
  2. [Solo · ≈ 20 h] Paper study: speculative decoding meets 4-bit quantization (Leviathan, Kalman and Matias, 2023). Question: does Theorem 7.2 predict the measured speedup, and what does quantizing the target cost in acceptance and quality? Chapters used: ch. 7, 1.
    • Implement speculative sampling with residual resampling (Definition 7.1) for a pair that shares a tokenizer, such as Qwen2.5-0.5B-Instruct as draft and Qwen2.5-3B-Instruct as target, on a free T4 GPU.
    • Measure the acceptance rate per domain — prose (WikiText-103), code (HumanEval prompts), math (GSM8K) — the tokens per target pass, and the best draft length from the speedup formula of exam question 2.
    • Quantize the target with GPTQ and with AWQ (7.2). Re-measure acceptance, latency, memory, GSM8K accuracy and the refusal rate on 100 AdvBench prompts (Zou et al., 2023), not only perplexity.
    • Deliverables: code, a 4–6 page report, a 10-minute talk. Success: measured tokens per pass within 10% of the theorem at the measured acceptance rate, or the gap explained (acceptances are correlated); a speed–memory–quality table with intervals.

Group projects

  1. [Group of 4 · ≈ 30 h each] Paper study: serialize, retrieve or encode? A KG-QA bake-off around G-Retriever (He et al., 2024). Question: under a fixed token budget, when does a structural component beat serialization or long context — the open question of ch. 8? The subject connects this module to Graph ML ch. 10 and Advanced GNN 8.3, and is a light version of Y2.1. Chapters used: ch. 3, 4, 8.
    • Data: the WebQSP and SceneGraphs splits released with G-Retriever; one open LLM of 1–8B parameters for all systems.
    • Member 1: serialization — Talk-like-a-Graph encodings of the 2-hop subgraph (Proposition 8.1), and a long-context baseline that stuffs the graph up to the budget (ch. 3).
    • Member 2: GraphRAG — Leiden communities, their summaries, local and global search (ch. 4; Graph ML 10.1).
    • Member 3: a light G-Retriever — PCST or shortest-path subgraph, a GNN and one graph token, frozen LLM (Definition 8.2).
    • Member 4: the harness — Hit@1, a hallucination rate (answers naming entities absent from the graph), tokens and cost per query, an LLM judge calibrated as in ch. 1.
    • Deliverables: code, a 6–8 page report, a 15-minute talk. Success: the four systems at the same budget, Hit@1 with intervals per question type, and a reasoned answer to the open question of ch. 8 for these data.
  2. [Group of 3 · ≈ 30 h each] Does RLVR teach graph algorithms or just select them? Question: the “select or create” debate of ch. 2, on the master’s own domain. The subject connects this module to LLMs ch. 5 (GRPO) and Reinforcement Learning ch. 5. Chapters used: ch. 2, 8.
    • Tasks: NLGraph-style connectivity, shortest path and topological sort on random NetworkX graphs, with rewards checked exactly by NetworkX (Definition 2.2). Train on 5–15 nodes; test on 20–40 nodes and on an unseen encoding (Proposition 8.1).
    • Member 1: mini-GRPO with LoRA on Qwen2.5-0.5B- or 1.5B-Instruct (TRL library), logging accuracy and generation length (2.3).
    • Member 2: the distillation baseline — supervised fine-tuning on verifier-filtered traces of a larger open model, at equal compute.
    • Member 3: the test of Yue et al. (2025) — pass@k of the base and trained models for k up to 256. If RLVR only selects, the base model catches up at large k.
    • Deliverables: code, a 6–8 page report, a 15-minute talk. Success: in- and out-of-distribution accuracy with intervals for the base, RLVR and distilled models, and pass@k curves that decide between the two readings on this domain.
  3. [Group of 4 · ≈ 30 h each] A long-lived agent with structured memory. Question: which memory design keeps an agent reliable over many sessions, and at what token cost? The subject uses the tracing of ML Ops ch. 8. Chapters used: ch. 3, 4, 9.
    • Data: the very long conversations of LoCoMo and their questions (Maharana et al., 2024), plus a multi-session task of the group’s choice (research assistant or support desk) with three or more tools.
    • Members 1–3: one memory each — a plain vector store; a Generative-Agents memory stream with reflection (Proposition 4.1); MemGPT-style paging or an entity-graph memory.
    • Member 4: the ReAct agent and the harness — per-step success, the chain law of Proposition 9.2, and the single- versus multi-agent ablation at equal token budget.
    • Deliverables: code, a 6–8 page report, a 15-minute talk. Success: LoCoMo accuracy per question category and tokens per answer for each memory, with intervals; measured task success set against the prediction of Proposition 9.2 from the measured per-step success.

Written exam (proposal)

Format: 2 hours, one handwritten A4 sheet allowed, a non-programmable calculator, four questions. The fiche displays no exam, so this is a mock.

  1. Question (5 points). (a) What does a contaminated benchmark score estimate, and which three numbers should a paper report instead of one? (b) Why is the KV cache of a transformer a feature and not only a cost, compared with the state of Mamba or RWKV? (c) Li et al. (2024) find that long context beats RAG on average. Why is RAG still deployed, and what does Self-Route do?

    Expected: (a) a mixture of memory and generalization, so the estimand shifts (Proposition 1.2); report the raw score, the score on regenerated variants and an overlap measure, and read the gap as an interval. (b) The cache stores every past key and value exactly, so any token can be recalled precisely; an SSM or RWKV compresses the history into a fixed-size state and fails exact recall, hence hybrids such as Jamba (6.3).

    1. Cost: RAG sends a few excerpts. Self-Route asks the model whether the excerpts suffice and sends the full context only when they do not: comparable quality for 39% to 65% less cost (3.4).
  2. Question (6 points). A draft model’s tokens are accepted with probability 0.8 each. (a) With a draft length of 4, compute the expected number of tokens per target pass (Theorem 7.2). (b) One draft step costs 0.1 target step, so an iteration with draft length \gamma costs 0.1\gamma + 1. Compute the speedup for draft lengths 2, 4, 6 and 7, and give the best one. (c) Two models are 0.5 points apart on a 500-question benchmark. Give the 95% Hoeffding half-width of each accuracy and conclude.

    Expected: (a) (1 - 0.8^5)/0.2 = 3.36 tokens. (b) The speedup is the expected number of tokens divided by the iteration cost: \frac{2.44}{1.2} = 2.03, \quad \frac{3.36}{1.4} = 2.40, \quad \frac{3.95}{1.6} = 2.47, \quad \frac{4.16}{1.7} = 2.45, so the best draft length is 6, and the curve is flat between 5 and 7.

    1. By Theorem 0.3 of Machine Learning, the half-width is \sqrt{\frac{\ln(2/0.05)}{2 \cdot 500}} \approx 0.061, about 6 points, twelve times the gap: the ranking says nothing.
  3. Question (5 points). For the Switch loss of Proposition 5.2: (a) with four experts, f = (0.7, 0.1, 0.1, 0.1) and P = (0.6, 0.2, 0.1, 0.1), compute the loss divided by its weight, and compare with uniform routing. (b) Prove that the loss is at least its weight when the loads and the router masses are similarly ordered. (c) Redo (a) with two experts, f = (0.9, 0.1) and P = (0.45, 0.55). What does the result say about the loss?

    Expected: (a) the sum of the products is 0.42 + 0.02 + 0.01 + 0.01 = 0.46, so the ratio is 4 \times 0.46 = 1.84, above the value 1 of uniform routing. (b) Chebyshev’s sum inequality, as in the proof of Proposition 5.2: the average of the products is at least the product of the averages, which is the square of the inverse number of experts.

    1. The sum is 0.405 + 0.055 = 0.46 and the ratio 2 \times 0.46 = 0.92 < 1: an anti-monotone pair goes below the “minimum”. The bound needs co-monotone sequences; the loss is a load proxy, whose gradient (equal to the load) still pushes the loaded experts down.
  4. Question (4 points). In ring attention (Proposition 3.4), a device receives the key/value blocks one at a time and updates its running maximum, normalizer and output. Prove by induction that after the last block, the output divided by the normalizer is the exact softmax attention over the whole sequence. Why multiply by e^{m - m'} at each update?

    Expected: invariant after the blocks seen so far: m is their largest score, \ell = \sum e^{s - m} and O = \sum e^{s - m} v. It holds at the start (empty sums, m = -\infty). At an update the old sums are moved to the new reference by the factor e^{m - m'} and the new block adds its terms.

    At the end the common factor e^{-m} cancels in O/\ell, leaving the softmax-weighted average of the values. The rescaling keeps every exponent at most 0 (no overflow) and puts old and new terms on one reference.

Grading rubric (proposal)

The rubric grades the continuous part (portfolio and project); the written exam, if an instructor uses it, is graded on its own.

Criterion Weight What earns the marks
Reading-note portfolio (Ex. 1) 20 % one sheet per session with claim, evidence, costs, reproducibility and LLGA link; two sheets in depth
Question and protocol 15 % a falsifiable question, named baselines, a fixed budget and a contamination check stated before the runs
Implementation and reproducibility 20 % code that runs from a clean clone, fixed seeds, logged costs (tokens, GPU-hours) and versions
Results and critical analysis 30 % intervals rather than points, ablations, failure cases, and the reading grid of ch. 0 applied to one’s own claims
Report and talk 15 % a 4–8 page report a peer can check, and a 10–15 minute talk defended at the board

References