[
  {
    "file": "02_pretraining-pipeline_college.json",
    "path": "scenes[2].elements[4].latex",
    "before": "\\nabla_\\theta \\mathcal{L} = \\sum_{t=1}^T (\\hat{y}_t - y_t) x_t^\\top",
    "after": "Z=HW_o,\\quad \\nabla_{W_o}L=H^\\top(P-Y);\\quad \\nabla_\\theta L\\text{ uses the full chain rule}",
    "reason": "A linear output-layer gradient is not the gradient of all model parameters.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
  },
  {
    "file": "02_pretraining-pipeline_college.json",
    "path": "scenes[4].elements[4].latex",
    "before": "N \\times T = 20B \\quad \\text{(Optimal tokens-to-parameters)}",
    "after": "D\\approx20N\\quad\\text{(Chinchilla training-compute heuristic, not a universal optimum)}",
    "reason": "Correct token-to-parameter ratio and state its experimental scope.",
    "reference": "https://arxiv.org/abs/2203.15556"
  },
  {
    "file": "03_rlhf-reasoning_college.json",
    "path": "scenes[7].elements[4].latex",
    "before": "\\text{Scaling Law (Model Size $N$ vs. Training Steps $T$):}\\quad T \\propto N^{1.5}",
    "after": "C\\approx6ND\\quad\\text{(rough dense-transformer training FLOPs)}",
    "reason": "No universal T proportional to N power1.5 law follows from GRPO.",
    "reference": "https://arxiv.org/abs/2203.15556"
  },
  {
    "file": "05_embedding-deepdive_college.json",
    "path": "scenes[10].elements[6].latex",
    "before": "\\text{Sparsity} = \\frac{\\text{non-zero entries}}{\\text{total embedding size}}",
    "after": "\\text{Sparsity}=1-\\frac{\\text{nonzero entries}}{\\text{total entries}}",
    "reason": "The nonzero fraction is density, not sparsity.",
    "reference": "https://docs.scipy.org/doc/scipy/reference/sparse.html"
  },
  {
    "file": "06_cbow-skipgram_college.json",
    "path": "scenes[3].elements[2].latex",
    "before": "\\text{Given loss } L, \\text{ prediction } \\hat{y} = \\text{softmax}(W \\cdot h)\\\\ \\nabla_{\\hat{y}} L = \\hat{y} - y",
    "after": "z=Wh,\\quad p=\\operatorname{softmax}(z),\\quad \\nabla_z L=p-y",
    "reason": "p minus y is the logit gradient, not the probability gradient.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
  },
  {
    "file": "07_architecture-families_college.json",
    "path": "scenes[6].elements[4].latex",
    "before": "\\frac{\\partial \\mathcal{L}}{\\partial Q} = \\frac{1}{\\sqrt{d}} \\left( \\frac{\\partial \\mathcal{L}}{\\partial \\text{softmax}(QK^{\\top}/\\sqrt{d})} V^{\\top} \\right)",
    "after": "G_A=G_OV^\\top;\\quad G_S=A\\odot(G_A-\\operatorname{rowsum}(A\\odot G_A));\\quad G_Q=G_SK/\\sqrt{d_k}",
    "reason": "Attention backprop requires the softmax Jacobian and multiplication by K.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "08_llm-inference_college.json",
    "path": "scenes[4].elements[3].latex",
    "before": "P_{accept} = \\prod_{i=1}^k p_v(t_i | context)",
    "after": "P(\\text{accept }x)=\\min(1,p(x)/q(x))",
    "reason": "Exact speculative sampling compares target and draft probabilities.",
    "reference": "https://arxiv.org/html/2211.17192v2"
  },
  {
    "file": "08_llm-inference_college.json",
    "path": "scenes[4].elements[4].latex",
    "before": "Speedup \\approx \\frac{k}{1 + \\alpha k}",
    "after": "\\text{speedup}=\\frac{\\text{baseline wall time}}{\\text{draft time + verification time}}",
    "reason": "Speedup depends on actual costs and accepted length, not a universal fixed formula.",
    "reference": "https://arxiv.org/html/2211.17192v2"
  },
  {
    "file": "08_llm-inference_college.json",
    "path": "scenes[7].elements[5].latex",
    "before": "\\mathrm{Quantized\\ Weight}: w_q = \\mathrm{round}\\left(\\frac{w}{s}\\right)\\times s, \\quad s = \\frac{\\max(|w|)}{2^{b}-1}",
    "after": "q_{max}=2^{b-1}-1,\\quad s=\\max|w|/q_{max},\\quad q=\\operatorname{clip}(\\operatorname{round}(w/s),-q_{max},q_{max}),\\quad\\hat w=sq",
    "reason": "Specify a symmetric signed quantizer with a consistent scale.",
    "reference": "https://docs.pytorch.org/docs/stable/quantization.html"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[0].actions",
    "before": [
      {
        "id": "action_1C5-Vkjq",
        "type": "spotlight",
        "elementId": "text_uX-kfoEr"
      },
      {
        "id": "action_KO_uVLgK",
        "type": "speech",
        "text": "Welcome. This module covers TRL, Hugging Face's transformer reinforcement-learning stack, and GRPO, group relative policy optimization, introduced with DeepSeekMath in twenty twenty-four and now central to reasoning-model post-training."
      },
      {
        "id": "action_mIXAGaP8",
        "type": "spotlight",
        "elementId": "text_8mvAK3KE"
      },
      {
        "id": "action_w6ho4WWv",
        "type": "speech",
        "text": "TRL wraps supervised fine-tuning, reward modeling, PPO, DPO, and GRPO around causal language models: the policy emits logits over tokens, we score sampled completions, then update with a KL-regularized objective so the model does not drift too far from the reference policy."
      },
      {
        "id": "action_5NB1cWtP",
        "type": "spotlight",
        "elementId": "text_8jvlopB8"
      },
      {
        "id": "action_Om5cBjsG",
        "type": "speech",
        "text": "GRPO's key move is critic-free advantage estimation: sample several completions per prompt, rank their rewards, subtract the group mean and divide by the group standard deviation. That relative baseline cuts value-network memory and variance, which is why it scales to long chain-of-thought reinforcement learning."
      },
      {
        "id": "action_5ZixdhBn",
        "type": "spotlight",
        "elementId": "text_8mvAK3KE"
      },
      {
        "id": "action_OU9fN8Lw",
        "type": "speech",
        "text": "Our path is: policy-gradient objectives and importance ratios; PPO clipping and KL control; reward hacking and length bias; then GRPO implementation details, including group sampling, advantage normalization, and teacher-forced log-probability evaluation under causal masking."
      },
      {
        "id": "action_29FOO3BA",
        "type": "spotlight",
        "elementId": "text_uX-kfoEr"
      },
      {
        "id": "action_sfT7LXuS",
        "type": "speech",
        "text": "The takeaway is concrete: transformers give the policy, reinforcement learning supplies the preference signal, and GRPO makes optimization stable enough for math, code, and tool-use agents. Master the objective, the normalization, and the failure modes before scaling compute."
      }
    ],
    "after": [
      {
        "id": "review-0-0",
        "type": "speech",
        "text": "TRL is a library for language-model post-training. GRPO means Group Relative Policy Optimization. The group contains alternative completions of one prompt, not a team of agents or a task-priority queue."
      },
      {
        "id": "review-0-1",
        "type": "speech",
        "text": "Follow the same prompt through sampling, reward scoring, comparison, and a policy update."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[0].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "d9YSuvJKd8a65Qus7ejOR",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_uX-kfoEr",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>TRL and GRPO: Post-Training with Relative Rewards</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "shape_Z-LL6Upo",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#1e40af",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_osaDexCE",
            "type": "shape",
            "left": 60,
            "top": 170,
            "width": 5,
            "height": 98,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#2563eb",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_8mvAK3KE",
            "type": "text",
            "left": 80,
            "top": 174,
            "width": 860,
            "height": 130,
            "content": "<p style=\"font-size:18px;\">• TRL: transformer RL post-training stack — SFT, reward models, PPO/DPO/GRPO</p><p style=\"font-size:18px;\">• GRPO: critic-free, group-relative advantages (DeepSeekMath, 2024)</p><p style=\"font-size:18px;\">• Objective: clipped policy gradient + KL to reference; rewards on sampled completions</p><p style=\"font-size:18px;\">• Failure modes: reward hacking, length bias, entropy collapse; evals before scale</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1f2937",
            "rotate": 0
          },
          {
            "id": "shape_U_zREUKf",
            "type": "shape",
            "left": 60,
            "top": 320,
            "width": 880,
            "height": 120,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#e0e7ff",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_8jvlopB8",
            "type": "text",
            "left": 80,
            "top": 354,
            "width": 840,
            "height": 94,
            "content": "<p style=\"font-size:18px; text-align: center; color: #334155;\">TRL operationalizes RLHF for causal LMs; GRPO replaces a learned value baseline with within-prompt group normalization, lowering memory and variance for reasoning-heavy post-training (2024–2026).</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#334155",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-0",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Introduction to TRL and GRPO</h2>"
          },
          {
            "id": "review-text-0-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">TRL is a library for language-model post-training. GRPO means Group Relative Policy Optimization. The group contains alternative completions of one prompt, not a team of agents or a task-priority queue.</p>"
          },
          {
            "id": "review-text-0-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Follow the same prompt through sampling, reward scoring, comparison, and a policy update.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[1].actions",
    "before": [
      {
        "id": "action_ZzppmU_a",
        "type": "spotlight",
        "elementId": "text_WWUwOzZ8"
      },
      {
        "id": "action_dppd6hnC",
        "type": "speech",
        "text": "Let's establish the foundations of Transformer Reinforcement Learning, or TRL: the library that operationalizes post-training alignment, from supervised fine-tuning through preference optimization on pretrained language models."
      },
      {
        "id": "action_RnJwmGq9",
        "type": "spotlight",
        "elementId": "text_ojdjlosD"
      },
      {
        "id": "action_X6LOouJH",
        "type": "speech",
        "text": "Here is the modern alignment pipeline. Each stage transforms the checkpoint it receives: a pretrained base model becomes an instruction-following model, and finally a policy optimized against human preference data."
      },
      {
        "id": "action_RDyvRe4K",
        "type": "spotlight",
        "elementId": "text_N3mYLPen"
      },
      {
        "id": "action_ZVDV225C",
        "type": "speech",
        "text": "The stages are pretraining over trillions of tokens, supervised fine-tuning on curated demonstrations, and preference optimization, either offline against a fixed dataset or online with rollouts and reward feedback. Each stage sharpens instruction adherence and safety."
      },
      {
        "id": "action_LBFyWVQL",
        "type": "spotlight",
        "elementId": "text_4u40olNB"
      },
      {
        "id": "action_NGL96G8b",
        "type": "speech",
        "text": "Consider supervised fine-tuning. The SFTTrainer minimizes token-level cross-entropy on prompt-response pairs, teacher forcing the model toward the annotated target. This is the supervised foundation every preference method builds on."
      },
      {
        "id": "action_EbYsM7rd",
        "type": "spotlight",
        "elementId": "shape_Fpr7R3_-"
      },
      {
        "id": "action_jJHL46A0",
        "type": "speech",
        "text": "After SFT, preference optimization diverges. DPO, from Rafailov and colleagues, fits preferences in closed form via a reparameterized Bradley-Terry objective, while GRPO is an online policy-gradient method using group-normalized advantages instead of a value critic."
      },
      {
        "id": "action__w1RTrSp",
        "type": "spotlight",
        "elementId": "shape_jUY5-4Me"
      },
      {
        "id": "action_iK9t8ETB",
        "type": "speech",
        "text": "Finally, TRL wraps these objectives in the transformers Trainer API, so SFT, DPO, and GRPO inherit the same distributed training, mixed precision, and checkpointing infrastructure, which streamlines experimentation and deployment."
      },
      {
        "id": "action_sUyJkwqY",
        "type": "speech",
        "text": "To summarize: TRL spans the post-training stack, supervised fine-tuning, offline and online preference optimization, and unified Trainer integration. These are the foundations underlying every modern aligned language model."
      }
    ],
    "after": [
      {
        "id": "review-1-0",
        "type": "speech",
        "text": "Supervised fine-tuning, DPO, and GRPO are different training options supported by TRL. They are not three mandatory stages that every model must follow."
      },
      {
        "id": "review-1-1",
        "type": "speech",
        "text": "Choose training data and the objective for the behavior you can evaluate."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[1].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "dyy88DdNfzBaVMgr_TBUX",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_WWUwOzZ8",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Foundations of TRL</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_jUY5-4Me",
            "type": "shape",
            "left": 60,
            "top": 152,
            "width": 6,
            "height": 88,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_N3mYLPen",
            "type": "text",
            "left": 80,
            "top": 160,
            "width": 860,
            "height": 106,
            "content": "<p style=\"font-size:20px;\">• Modern Alignment Pipeline Stages</p><p style=\"font-size:20px;\">• Supervised Fine-Tuning with SFTTrainer</p><p style=\"font-size:20px;\">• DPO (Rafailov et al.) vs Online GRPO</p><p style=\"font-size:20px;\">• Integration with transformers.Trainer API</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e3a8a",
            "rotate": 0
          },
          {
            "id": "shape_Fpr7R3_-",
            "type": "shape",
            "left": 70,
            "top": 236,
            "width": 840,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_ojdjlosD",
            "type": "text",
            "left": 60,
            "top": 260,
            "width": 880,
            "height": 58,
            "content": "<p style=\"font-size:24px; font-weight:bold; color:#166534;\">Stages of the Modern Alignment Pipeline</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "text_4u40olNB",
            "type": "text",
            "left": 80,
            "top": 320,
            "width": 860,
            "height": 130,
            "content": "<p style=\"font-size:18px;\">• Pretraining: next-token cross-entropy on trillions of tokens</p><p style=\"font-size:18px;\">• Supervised Fine-Tuning (SFT): teacher-forced loss on curated demonstrations</p><p style=\"font-size:18px;\">• Offline Preference Optimization: DPO on fixed preference pairs, no rollouts</p><p style=\"font-size:18px;\">• Online Reinforcement Learning: GRPO with group-normalized advantages, no value critic</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-1",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Foundations of TRL</h2>"
          },
          {
            "id": "review-text-1-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Supervised fine-tuning, DPO, and GRPO are different training options supported by TRL. They are not three mandatory stages that every model must follow.</p>"
          },
          {
            "id": "review-text-1-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Choose training data and the objective for the behavior you can evaluate.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[2].actions",
    "before": [
      {
        "id": "action_8Dl_mTwQ",
        "type": "spotlight",
        "elementId": "text_QDJK4EeU"
      },
      {
        "id": "action_s3AjtVYL",
        "type": "speech",
        "text": "GRPO, group relative policy optimization from the DeepSeekMath line of work, replaces a learned value critic with a baseline computed from multiple sampled completions of the same prompt; stability comes from relative advantages inside each group."
      },
      {
        "id": "action_pNfI1naw",
        "type": "spotlight",
        "elementId": "text_HTKv3WBI"
      },
      {
        "id": "action_OTZUmUwr",
        "type": "speech",
        "text": "The naive reading is wrong: the group is not a set of agents, but a fixed number of rollouts for one prompt, so the mean reward is a control variate that lowers gradient variance."
      },
      {
        "id": "action_HCP1isHL",
        "type": "spotlight",
        "elementId": "text_2js3ARmW"
      },
      {
        "id": "action_862ch07b",
        "type": "speech",
        "text": "For each sampled response, the advantage is its reward minus the group mean, divided by the group standard deviation, which centers and scales the signal."
      },
      {
        "id": "action_8nb0gLb9",
        "type": "spotlight",
        "elementId": "latex_EMe8QsrC"
      },
      {
        "id": "action_4xvntMyf",
        "type": "speech",
        "text": "In words, sum the scalar rewards across that prompt's completions, subtract the empirical mean from every reward, then normalize by the empirical standard deviation before any policy ratio is applied."
      },
      {
        "id": "action_zFDJmRMM",
        "type": "spotlight",
        "elementId": "text_yceSAqpn"
      },
      {
        "id": "action_8t9aUhpR",
        "type": "speech",
        "text": "The surrogate keeps PPO's clipped importance ratio, but multiplies it by this group relative advantage rather than a value function estimate."
      },
      {
        "id": "action_s5Glk75t",
        "type": "spotlight",
        "elementId": "latex_hfnC9nVT"
      },
      {
        "id": "action_VhdWodtd",
        "type": "speech",
        "text": "The expectation is over prompts and grouped completions: maximize the minimum of the unclipped and clipped ratio times advantage, minus beta times the K L divergence to the reference policy."
      },
      {
        "id": "action_ch3TqrG0",
        "type": "speech",
        "text": "Against PPO, the ablation is clear: removing the critic cuts memory and bias, while grouped completions give a prompt-conditioned baseline that suits verifier rewards and large batch decoding."
      }
    ],
    "after": [
      {
        "id": "review-2-0",
        "type": "speech",
        "text": "Sample several completions from the old policy for the same prompt. Score each completion separately. Compare its reward with that group mean."
      },
      {
        "id": "review-2-1",
        "type": "speech",
        "text": "In original outcome-supervised GRPO, the centered reward is divided by the group standard deviation to produce a relative advantage."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[2].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "mb8WBejoGu16AimQhH_bc",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_QDJK4EeU",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:36px; font-weight:bold;\">GRPO: Group Relative Policy Optimization</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "shape_8DHn49S3",
            "type": "shape",
            "left": 45,
            "top": 92,
            "width": 6,
            "height": 50,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#2563eb",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_1BWev_xp",
            "type": "shape",
            "left": 60,
            "top": 140,
            "width": 880,
            "height": 180,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#e0e7ff",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_HTKv3WBI",
            "type": "text",
            "left": 80,
            "top": 172,
            "width": 840,
            "height": 166,
            "content": "<p style=\"font-size:20px;\"><strong>Core Mechanism</strong></p><p style=\"font-size:18px;\">• Group means sampled completions for one prompt, not agents</p><p style=\"font-size:18px;\">• Advantage: reward minus group mean, over group standard deviation</p><p style=\"font-size:18px;\">• PPO-style clipped ratio; no learned value critic</p><p style=\"font-size:18px;\">• KL penalty to the reference policy stabilizes updates</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1f2937",
            "rotate": 0
          },
          {
            "id": "latex_EMe8QsrC",
            "type": "latex",
            "left": 60,
            "top": 350,
            "width": 400,
            "height": 100,
            "latex": "\\hat{R}^G_t = \\frac{1}{|G|} \\sum_{i \\in G} R^i_t",
            "color": "#111111",
            "align": "left",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:1.1938em;vertical-align:-0.247em;\"></span><span class=\"mord\"><span class=\"mord accent\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.9468em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.00773em;\">R</span></span><span style=\"top:-3.2523em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"accent-body\" style=\"left:-0.1667em;\"><span class=\"mord\">^</span></span></span></span></span></span></span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.8913em;\"><span style=\"top:-2.453em;margin-left:-0.0077em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span><span style=\"top:-3.113em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">G</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.247em;\"><span></span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:2.6431em;vertical-align:-1.3217em;\"></span><span class=\"mord\"><span class=\"mopen nulldelimiter\"></span><span class=\"mfrac\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.3214em;\"><span style=\"top:-2.314em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">∣</span><span class=\"mord mathnormal\">G</span><span class=\"mord\">∣</span></span></span><span style=\"top:-3.23em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"frac-line\" style=\"border-bottom-width:0.04em;\"></span></span><span style=\"top:-3.677em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">1</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.936em;\"><span></span></span></span></span></span><span class=\"mclose nulldelimiter\"></span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.05em;\"><span style=\"top:-1.8557em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3.05em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">i</span><span class=\"mrel mtight\">∈</span><span class=\"mord mathnormal mtight\">G</span></span></span></span><span style=\"top:-3.05em;\"><span class=\"pstrut\" style=\"height:3.05em;\"></span><span><span class=\"mop op-symbol large-op\">∑</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.3217em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.00773em;\">R</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.8747em;\"><span style=\"top:-2.453em;margin-left:-0.0077em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span><span style=\"top:-3.113em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">i</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.247em;\"><span></span></span></span></span></span></span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          },
          {
            "id": "text_2js3ARmW",
            "type": "text",
            "left": 470,
            "top": 380,
            "width": 470,
            "height": 46,
            "content": "<p style=\"font-size:18px;\">Group baseline: advantage equals reward minus group mean, divided by group standard deviation</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#374151",
            "rotate": 0
          },
          {
            "id": "latex_hfnC9nVT",
            "type": "latex",
            "left": 60,
            "top": 460,
            "width": 420,
            "height": 100,
            "latex": "\\mathcal{L}_{GRPO} = \\mathbb{E}_t \\Big[ \\frac{\\pi_\\theta(a_t|s_t)}{\\pi_{\\theta_{old}}(a_t|s_t)} \\hat{A}^G_t - \\beta \\mathrm{KL}\\big(\\pi_{\\theta_{old}}(\\cdot|s_t) \\,||\\, \\pi_\\theta(\\cdot|s_t)\\big) \\Big]",
            "color": "#111111",
            "align": "left",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.8333em;vertical-align:-0.15em;\"></span><span class=\"mord\"><span class=\"mord mathcal\">L</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3283em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.00773em;\">GR</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.13889em;\">P</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">O</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:2.3689em;vertical-align:-0.9419em;\"></span><span class=\"mord\"><span class=\"mord mathbb\">E</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mord\"><span class=\"delimsizing size2\">[</span></span><span class=\"mord\"><span class=\"mopen nulldelimiter\"></span><span class=\"mfrac\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.427em;\"><span style=\"top:-2.314em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3448em;\"><span style=\"top:-2.3488em;margin-left:-0.0278em;margin-right:0.0714em;\"><span class=\"pstrut\" style=\"height:2.5em;\"></span><span class=\"sizing reset-size3 size1 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">o</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.01968em;\">l</span><span class=\"mord mathnormal mtight\">d</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1512em;\"><span></span></span></span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2559em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord\"><span class=\"mord mathnormal\">a</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mord\">∣</span><span class=\"mord\"><span class=\"mord mathnormal\">s</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mclose\">)</span></span></span><span style=\"top:-3.23em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"frac-line\" style=\"border-bottom-width:0.04em;\"></span></span><span style=\"top:-3.677em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord\"><span class=\"mord mathnormal\">a</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mord\">∣</span><span class=\"mord\"><span class=\"mord mathnormal\">s</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mclose\">)</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.9419em;\"><span></span></span></span></span></span><span class=\"mclose nulldelimiter\"></span></span><span class=\"mord\"><span class=\"mord accent\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.9468em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord mathnormal\">A</span></span><span style=\"top:-3.2523em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"accent-body\" style=\"left:-0.1111em;\"><span class=\"mord\">^</span></span></span></span></span></span></span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.8913em;\"><span style=\"top:-2.453em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span><span style=\"top:-3.113em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">G</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.247em;\"><span></span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">−</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:1.8em;vertical-align:-0.65em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05278em;\">β</span><span class=\"mord\"><span class=\"mord mathrm\">KL</span></span><span class=\"mord\"><span class=\"delimsizing size1\">(</span></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3448em;\"><span style=\"top:-2.3488em;margin-left:-0.0278em;margin-right:0.0714em;\"><span class=\"pstrut\" style=\"height:2.5em;\"></span><span class=\"sizing reset-size3 size1 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">o</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.01968em;\">l</span><span class=\"mord mathnormal mtight\">d</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1512em;\"><span></span></span></span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2559em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord\">⋅</span><span class=\"mord\">∣</span><span class=\"mord\"><span class=\"mord mathnormal\">s</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mclose\">)</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\">∣∣</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord\">⋅</span><span class=\"mord\">∣</span><span class=\"mord\"><span class=\"mord mathnormal\">s</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mclose\">)</span><span class=\"mord\"><span class=\"delimsizing size1\">)</span></span><span class=\"mord\"><span class=\"delimsizing size2\">]</span></span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          },
          {
            "id": "text_yceSAqpn",
            "type": "text",
            "left": 500,
            "top": 490,
            "width": 440,
            "height": 46,
            "content": "<p style=\"font-size:18px;\">Objective: clipped surrogate times group advantage, minus beta times KL to reference</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#374151",
            "rotate": 0
          },
          {
            "id": "shape_X77BB6gO",
            "type": "shape",
            "left": 60,
            "top": 550,
            "width": 880,
            "height": 2,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#3b82f6",
            "fixedRatio": false,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-2",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>GRPO Algorithm Deep Dive</h2>"
          },
          {
            "id": "review-text-2-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Sample several completions from the old policy for the same prompt. Score each completion separately. Compare its reward with that group mean.</p>"
          },
          {
            "id": "review-text-2-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">In original outcome-supervised GRPO, the centered reward is divided by the group standard deviation to produce a relative advantage.</p>"
          },
          {
            "id": "review-math-2",
            "type": "text",
            "left": 50,
            "top": 460,
            "width": 900,
            "height": 85,
            "content": "<p style=\"font-size:20px\">Aᵢ = (rᵢ − mean(r)) / (std(r) + ε)</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[3].actions",
    "before": [
      {
        "id": "action_ggxKA4NF",
        "type": "speech",
        "text": "Start with the matrix form of GRPO: completions are grouped by prompt, rewards are centered and scaled within each group, then folded into a clipped policy-gradient objective."
      },
      {
        "id": "action_sC1TjdfN",
        "type": "widget_highlight",
        "target": "#node-n1",
        "content": "Start here to understand the foundational matrix loss formulation for GRPO."
      },
      {
        "id": "action_dzcz9guD",
        "type": "speech",
        "text": "Next, trace TRL's GRPO gradient flow: token log-probabilities form a differentiable graph, group advantages rescale them, and autograd applies the chain rule to the policy matrices."
      },
      {
        "id": "action_1qi7BWpj",
        "type": "widget_highlight",
        "target": "#node-n2",
        "content": "This node shows the critical steps of gradient backpropagation through the loss."
      },
      {
        "id": "action_j_kjg0Ip",
        "type": "speech",
        "text": "Now isolate the group term: subtracting each prompt's mean reward removes a shared baseline, cuts variance without a critic, and pushes probability toward above-average completions."
      },
      {
        "id": "action_XsMQpPiX",
        "type": "widget_highlight",
        "target": "#node-n3",
        "content": "Focus here to see group completions' impact on gradient distribution."
      },
      {
        "id": "action_2mrTiB9K",
        "type": "speech",
        "text": "In the interactive panel, vary group size, Kullback Leibler coefficient, clip range, reward noise; the embedded PyTorch-style snippet recomputes advantages, ratios, gradients, and the scalar loss in place."
      },
      {
        "id": "action_QjYflNkY",
        "type": "widget_highlight",
        "target": "#node-n4",
        "content": "Use this interactive node to experiment with the formula derivations."
      },
      {
        "id": "action_1sDiGTNb",
        "type": "speech",
        "text": "Finally, assemble the derivation: sample a group per prompt, normalize rewards into advantages, weight clipped new-over-old probability ratios, subtract the reference-policy Kullback Leibler term, and average, following DeepSeekMath twenty twenty-four."
      },
      {
        "id": "action_JKRN92Ea",
        "type": "widget_highlight",
        "target": "#node-n5",
        "content": "Review this complete derivation to solidify your understanding of the GRPO loss."
      }
    ],
    "after": [
      {
        "id": "review-3-0",
        "type": "speech",
        "text": "For rewards zero, one, one, and two, the mean is one. The population standard deviation is the square root of one half. The advantages are approximately minus1.414, zero, zero, and1.414."
      },
      {
        "id": "review-3-1",
        "type": "speech",
        "text": "If rewards are identical, there is no relative ranking signal. A numerical epsilon avoids division by zero; trainer variants differ."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[3].type",
    "before": "interactive",
    "after": "slide",
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[3].content",
    "before": {
      "type": "interactive",
      "url": "",
      "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Mathematical Formulations and Derivations - Interactive Diagram</title>\n<style>\n  /* Reset and base */\n  * {\n    box-sizing: border-box;\n  }\n  html, body {\n    margin: 0; padding: 0; height: 100%;\n    background-color: #111011;\n    color: #EEE;\n    font-family: \"Segoe UI\", Tahoma, Geneva, Verdana, sans-serif;\n    user-select: none;\n    overflow: hidden;\n  }\n  #container {\n    display: flex;\n    height: 100vh;\n    width: 100vw;\n  }\n  /* Sidebar with details and controls */\n  #sidebar {\n    background: #1b1b2e;\n    color: #ddd;\n    width: 320px;\n    min-width: 280px;\n    max-width: 320px;\n    padding: 20px;\n    box-sizing: border-box;\n    overflow-y: auto;\n    transition: transform 0.25s ease;\n    display: flex;\n    flex-direction: column;\n  }\n  #sidebar.collapsed {\n    transform: translateX(-320px);\n    position: fixed;\n    z-index: 10;\n    height: 100%;\n    top: 0;\n    left: 0;\n    box-shadow: 8px 0 14px rgba(0,0,0,0.7);\n  }\n  #sidebar header {\n    font-size: 1.15rem;\n    font-weight: 700;\n    margin-bottom: 1rem;\n    text-align: center;\n    user-select: text;\n  }\n  #details {\n    flex-grow: 1;\n    overflow-y: auto;\n    padding-right: 0.5rem;\n    font-size: 1rem;\n    line-height: 1.4;\n  }\n  #details p {\n    margin-top: 0;\n  }\n  #controls {\n    margin-top: 1rem;\n    display: flex;\n    justify-content: space-between;\n  }\n  button {\n    background-color: #6b4fff;\n    border: none;\n    border-radius: 6px;\n    color: white;\n    font-weight: 700;\n    padding: 0.5rem 1rem;\n    cursor: pointer;\n    user-select: none;\n    transition: background-color 0.2s ease;\n    font-size: 1rem;\n  }\n  button:disabled {\n    background-color: #444477;\n    cursor: default;\n  }\n  button:hover:not(:disabled) {\n    background-color: #8b64ff;\n  }\n  #toggleSidebar {\n    display: none;\n    position: fixed;\n    top: 12px;\n    left: 12px;\n    z-index: 20;\n    border-radius: 5px;\n    background-color: #6b4fff;\n    border: none;\n    color: white;\n    font-weight: 700;\n    font-size: 1rem;\n    padding: 0.4rem 0.8rem;\n    cursor: pointer;\n  }\n  /* Diagram area */\n  #diagram-wrapper {\n    flex-grow: 1;\n    position: relative;\n    background-color: #111011;\n    overflow: auto;\n  }\n  svg {\n    width: 100%;\n    height: 100%;\n  }\n  /* Node groups */\n  .node {\n    cursor: pointer;\n    transition: opacity 0.3s ease;\n  }\n  .node.active {\n    opacity: 1;\n    filter: drop-shadow(0 0 4px #8b5dffcc);\n  }\n  .node:not(.active) {\n    opacity: 0.15;\n    pointer-events: none;\n  }\n  /* Node rectangles and text */\n  .node-rect {\n    fill: white;\n    fill-opacity: 1;\n    stroke: #8b5dff;\n    stroke-width: 1.8px;\n    rx: 10;\n    ry: 10;\n    filter: drop-shadow(0 0 6px rgba(107, 79, 255, 0.9));\n  }\n  .node-icon {\n    font-weight: 700;\n    font-size: 28px;\n    text-anchor: middle;\n  }\n  .node-label {\n    font-weight: 700;\n    font-size: 16px;\n    fill: #111;\n    user-select: none;\n    text-anchor: middle;\n  }\n  /* Edge lines */\n  .edge-path {\n    fill: none;\n    stroke: #bbbbee;\n    stroke-width: 1.4px;\n    marker-end: url(#arrowhead);\n  }\n  /* Edge labels */\n  .edge-label {\n    fill: #ccccee;\n    font-size: 13px;\n    user-select: none;\n    pointer-events: none;\n    font-family: \"Segoe UI\", Tahoma, Geneva, Verdana, sans-serif;\n  }\n  /* Details texts */\n  #details h2 {\n    margin-top: 0;\n    font-weight: 700;\n    color: #b099ff;\n  }\n  /* Annotation and highlight style */\n  .teacher-annotation {\n    font-family: \"Segoe UI\", Tahoma, Geneva, Verdana, sans-serif;\n  }\n  /* Pulsing highlight */\n  @keyframes pulse-highlight {\n    0%,100% { outline-color: rgba(139, 92, 246, 0.8); }\n    50% { outline-color: rgba(139, 92, 246, 0.4); }\n  }\n  /* Fade-in for teacher annotation */\n  @keyframes fadeIn {\n    from { opacity: 0; transform: translateY(10px); }\n    to { opacity: 1; transform: translateY(0); }\n  }\n  /* Responsive - show toggle button and collapse sidebar on mobile */\n  @media (max-width: 900px) {\n    #sidebar {\n      position: fixed;\n      left: 0;\n      top: 0;\n      height: 100%;\n      z-index: 15;\n      box-shadow: 8px 0 24px rgba(0,0,0,0.7);\n      transform: translateX(-320px);\n      transition: transform 0.3s ease;\n      background-color: #1b1b2ecc;\n      backdrop-filter: blur(8px);\n    }\n    #sidebar.active {\n      transform: translateX(0);\n    }\n    #toggleSidebar {\n      display: block;\n    }\n    #diagram-wrapper {\n      height: 100vh;\n    }\n  }\n</style>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<div id=\"container\">\n  <button id=\"toggleSidebar\" aria-label=\"Toggle Sidebar\">☰</button>\n  <aside id=\"sidebar\" role=\"region\" aria-label=\"Details and Controls\" tabindex=\"0\">\n    <header>Mathematical Formulations &amp; Derivations</header>\n    <section id=\"details\" aria-live=\"polite\" aria-atomic=\"true\">\n      <!-- Details content updated on node selection -->\n    </section>\n    <div id=\"controls\">\n      <button id=\"prevBtn\" aria-label=\"Previous Step\" disabled>← Previous</button>\n      <button id=\"nextBtn\" aria-label=\"Next Step\">Next →</button>\n    </div>\n  </aside>\n  <main id=\"diagram-wrapper\" role=\"main\" aria-label=\"Interactive Diagram Whiteboard\">\n    <svg id=\"diagram\" viewBox=\"0 0 1200 550\" aria-hidden=\"true\" focusable=\"false\" >\n      <defs>\n        <marker id=\"arrowhead\" markerWidth=\"12\" markerHeight=\"14\" refX=\"10\" refY=\"7\" orient=\"auto\" markerUnits=\"strokeWidth\">\n          <path d=\"M 0 0 L 10 7 L 0 14 z\" fill=\"#bbbbee\" />\n        </marker>\n      </defs>\n      <!-- Edges -->\n      <path class=\"edge-path\" id=\"edge-n1-n2\" />\n      <text class=\"edge-label\" id=\"label-edge-n1-n2\" ></text>\n\n      <path class=\"edge-path\" id=\"edge-n2-n3\" />\n      <text class=\"edge-label\" id=\"label-edge-n2-n3\" ></text>\n\n      <path class=\"edge-path\" id=\"edge-n3-n4\" />\n      <text class=\"edge-label\" id=\"label-edge-n3-n4\"></text>\n\n      <path class=\"edge-path\" id=\"edge-n4-n5\" />\n      <text class=\"edge-label\" id=\"label-edge-n4-n5\"></text>\n\n      <!-- Nodes -->\n      <g class=\"node\" id=\"node-n1\" role=\"button\" tabindex=\"0\" data-node=\"n1\" aria-describedby=\"desc-n1\" aria-label=\"Matrix Formulation Loss Function\">\n        <rect class=\"node-rect\" width=\"180\" height=\"70\" rx=\"10\" ry=\"10\" />\n        <text class=\"node-icon\" x=\"90\" y=\"26\">📐</text>\n        <text class=\"node-label\" x=\"90\" y=\"52\">Matrix Formulation Loss Function</text>\n      </g>\n\n      <g class=\"node\" id=\"node-n2\" role=\"button\" tabindex=\"0\" data-node=\"n2\" aria-describedby=\"desc-n2\" aria-label=\"Gradient Flow and Updates\">\n        <rect class=\"node-rect\" width=\"180\" height=\"70\" rx=\"10\" ry=\"10\" />\n        <text class=\"node-icon\" x=\"90\" y=\"26\">📈</text>\n        <text class=\"node-label\" x=\"90\" y=\"52\">Gradient Flow and Updates</text>\n      </g>\n\n      <g class=\"node\" id=\"node-n3\" role=\"button\" tabindex=\"0\" data-node=\"n3\" aria-describedby=\"desc-n3\" aria-label=\"Effect of Group Completions on Reward Gradient\">\n        <rect class=\"node-rect\" width=\"180\" height=\"70\" rx=\"10\" ry=\"10\" />\n        <text class=\"node-icon\" x=\"90\" y=\"26\">🔄</text>\n        <text class=\"node-label\" x=\"90\" y=\"52\">Effect of Group Completions on Reward Gradient</text>\n      </g>\n\n      <g class=\"node\" id=\"node-n4\" role=\"button\" tabindex=\"0\" data-node=\"n4\" aria-describedby=\"desc-n4\" aria-label=\"Interactive Exploration of Key Equations\">\n        <rect class=\"node-rect\" width=\"180\" height=\"70\" rx=\"10\" ry=\"10\" />\n        <text class=\"node-icon\" x=\"90\" y=\"26\">🧠</text>\n        <text class=\"node-label\" x=\"90\" y=\"52\">Interactive Exploration of Key Equations</text>\n      </g>\n\n      <g class=\"node\" id=\"node-n5\" role=\"button\" tabindex=\"0\" data-node=\"n5\" aria-describedby=\"desc-n5\" aria-label=\"Derivation of GRPO Loss Function Matrix Formulation Complete\">\n        <rect class=\"node-rect\" width=\"180\" height=\"70\" rx=\"10\" ry=\"10\" />\n        <text class=\"node-icon\" x=\"90\" y=\"26\">🎯</text>\n        <text class=\"node-label\" x=\"90\" y=\"52\">Derivation of GRPO Loss Function Matrix Formulation</text>\n      </g>\n\n      <!-- Descriptions hidden for aria-describedby -->\n      <desc id=\"desc-n1\">Explore the detailed derivation and matrix formulation of the GRPO loss function incorporating group-wise operations and policy reward decomposition.</desc>\n      <desc id=\"desc-n2\">Analyze the gradient flow process, backpropagation updates, and interpretations from a PyTorch automatic differentiation perspective within the TRL and GRPO frameworks.</desc>\n      <desc id=\"desc-n3\">Examine how group completions modify the reward gradient, highlighting the variations in reward allocation across group samples and effects on optimization trajectories.</desc>\n      <desc id=\"desc-n4\">Engage interactively with principal equations, explore parameters, and confirm results using simplified Python-based formula computation approximations.</desc>\n      <desc id=\"desc-n5\">Concluding the derivations, this node consolidates the comprehensive matrix formulation of the GRPO loss function, essential for advanced reinforcement learning research and implementation.</desc>\n    </svg>\n  </main>\n</div>\n\n<script type=\"application/json\" id=\"widget-config\">\n{\n  \"nodes\": [\n    {\n      \"id\": \"n1\",\n      \"icon\": \"📐\",\n      \"label\": \"Matrix Formulation Loss Function\",\n      \"details\": \"Explore the detailed derivation and matrix formulation of the GRPO loss function incorporating group-wise operations and policy reward decomposition. We analyze the structure of the loss \\\\( L = - \\\\sum_g \\\\sum_i Q_i^{(g)} \\\\log \\\\pi_i^{(g)} \\\\) using batch matrix notations.\"\n    },\n    {\n      \"id\": \"n2\",\n      \"icon\": \"📈\",\n      \"label\": \"Gradient Flow and Updates\",\n      \"details\": \"Analyze the gradient flow process and backpropagation updates within TRL and GRPO frameworks. We delve into the chain rule application on the matrix loss and identify how gradients propagate through log policy matrices with PyTorch autograd semantics.\"\n    },\n    {\n      \"id\": \"n3\",\n      \"icon\": \"🔄\",\n      \"label\": \"Effect of Group Completions on Reward Gradient\",\n      \"details\": \"Examine the impact of group completions on the reward gradient. Group completions adjust reward attributions across samples, affecting the total gradient vector and influencing convergence and exploration/exploitation balance.\"\n    },\n    {\n      \"id\": \"n4\",\n      \"icon\": \"🧠\",\n      \"label\": \"Interactive Exploration of Key Equations\",\n      \"details\": \"Engage with principal equations interactively. Explore parameter modifications and verify formula outcomes with Python/PyTorch styled code snippets illustrating key steps in gradient and loss computation.\"\n    },\n    {\n      \"id\": \"n5\",\n      \"icon\": \"🎯\",\n      \"label\": \"Derivation of GRPO Loss Function Matrix Formulation\",\n      \"details\": \"Conclude with the complete and formal GRPO matrix loss function derivation. This formula is critical for next-generation reinforcement learning algorithms with group reward structures and is verified against state-of-the-art research trends in 2024–2026.\"\n    }\n  ],\n  \"edges\": [\n    { \"from\": \"n1\", \"to\": \"n2\", \"label\": \"Derivation Flow\" },\n    { \"from\": \"n2\", \"to\": \"n3\", \"label\": \"Gradient Influence\" },\n    { \"from\": \"n3\", \"to\": \"n4\", \"label\": \"Exploration Interface\" },\n    { \"from\": \"n4\", \"to\": \"n5\", \"label\": \"Final Result\" }\n  ],\n  \"revealOrder\": [\"n1\", \"n2\", \"n3\", \"n4\", \"n5\"]\n}\n</script>\n<script>\n(() => {\n  const NODE_WIDTH = 180, NODE_HEIGHT = 70, ARROW_OFFSET = 10;\n  const svg = document.getElementById('diagram');\n  const config = JSON.parse(document.getElementById('widget-config').textContent);\n  const nodes = config.nodes;\n  const edges = config.edges;\n  const revealOrder = config.revealOrder;\n\n  // Positions for nodes manually arranged (whiteboard-style, flow left->right)\n  // Center vertically and distribute with some horizontal spacing\n  // Five nodes aligned horizontally with some small vertical offset pattern to minimize overlap for edge labels\n  // Layout coordinates are centers\n  const positions = {\n    \"n1\": { x: 140, y: 90 },\n    \"n2\": { x: 430, y: 90 },\n    \"n3\": { x: 720, y: 90 },\n    \"n4\": { x: 1010, y: 90 },\n    \"n5\": { x: 1130, y: 350 }\n  };\n\n  // Map for quick node element access\n  const nodeElements = new Map();\n  nodes.forEach(n => {\n    const el = document.getElementById('node-' + n.id);\n    if (el) {\n      nodeElements.set(n.id, el);\n    }\n  });\n\n  // Place nodes at positions\n  nodes.forEach(n => {\n    const el = nodeElements.get(n.id);\n    if (el) {\n      const pos = positions[n.id];\n      el.setAttribute('transform', `translate(${pos.x - NODE_WIDTH/2},${pos.y - NODE_HEIGHT/2})`);\n    }\n  });\n\n  // Draw edges paths and labels\n  function getEdgePoints(from, to) {\n    const dx = to.x - from.x, dy = to.y - from.y;\n    let sx, sy, ex, ey;\n\n    if (Math.abs(dy) > Math.abs(dx)) { // Vertical\n        sx = from.x;\n        sy = dy > 0 ? from.y + NODE_HEIGHT/2 : from.y - NODE_HEIGHT/2;\n        ex = to.x;\n        ey = dy > 0 ? to.y - NODE_HEIGHT/2 - ARROW_OFFSET : to.y + NODE_HEIGHT/2 + ARROW_OFFSET;\n    } else { // Horizontal\n        sx = dx > 0 ? from.x + NODE_WIDTH/2 : from.x - NODE_WIDTH/2;\n        sy = from.y;\n        ex = dx > 0 ? to.x - NODE_WIDTH/2 - ARROW_OFFSET : to.x + NODE_WIDTH/2 + ARROW_OFFSET;\n        ey = to.y;\n    }\n    return { sx, sy, ex, ey, path: `M ${sx} ${sy} L ${ex} ${ey}` };\n  }\n\n  edges.forEach(edge => {\n    const fromPos = positions[edge.from];\n    const toPos = positions[edge.to];\n    const {sx, sy, ex, ey, path} = getEdgePoints(fromPos, toPos);\n\n    const edgePath = document.getElementById('edge-' + edge.from + '-' + edge.to);\n    if (edgePath) {\n      edgePath.setAttribute('d', path);\n    }\n\n    const edgeLabel = document.getElementById('label-edge-' + edge.from + '-' + edge.to);\n    if (edgeLabel) {\n      // Place label near midpoint shifted slightly perpendicular to edge direction\n      const midX = (sx + ex) / 2;\n      const midY = (sy + ey) / 2;\n      const dx = ex - sx;\n      const dy = ey - sy;\n      // Perpendicular vector (normalize)\n      const length = Math.sqrt(dx*dx + dy*dy) || 1;\n      const px = -dy / length;\n      const py = dx / length;\n      const offset = 15;\n      const labelX = midX + px * offset;\n      const labelY = midY + py * offset + 5; // +5 to center vertically approx\n      edgeLabel.setAttribute('x', labelX);\n      edgeLabel.setAttribute('y', labelY);\n      edgeLabel.textContent = edge.label;\n    }\n  });\n\n  // Reveal logic\n  let currentStep = 0;\n\n  // Show or hide nodes\n  function updateVisibility() {\n    nodes.forEach((node, idx) => {\n      const el = nodeElements.get(node.id);\n      if (el) {\n        if (idx <= currentStep) {\n          el.style.display = '';\n          el.classList.add('active');\n          el.style.opacity = '1';\n        } else {\n          el.classList.remove('active');\n          el.style.opacity = '0.15';\n          el.style.display = 'none';\n        }\n      }\n    });\n    // Show only edges between visible nodes\n    edges.forEach(edge => {\n      const iFrom = revealOrder.indexOf(edge.from);\n      const iTo = revealOrder.indexOf(edge.to);\n      const pathEl = document.getElementById('edge-' + edge.from + '-' + edge.to);\n      const labelEl = document.getElementById('label-edge-' + edge.from + '-' + edge.to);\n      if (pathEl && labelEl) {\n        if (iFrom <= currentStep && iTo <= currentStep) {\n          pathEl.style.display = '';\n          labelEl.style.display = '';\n        } else {\n          pathEl.style.display = 'none';\n          labelEl.style.display = 'none';\n        }\n      }\n    });\n\n    updateDetails();\n    updateControls();\n  }\n\n  // Update sidebar details for current node\n  const detailsEl = document.getElementById('details');\n  function updateDetails() {\n    const node = nodes[currentStep];\n    if (!node) {\n      detailsEl.textContent = '';\n      return;\n    }\n    detailsEl.innerHTML = `<h2>${node.label}</h2><p>${node.details.replace(/\\n/g,'<br>')}</p>`;\n  }\n\n  // Update controls buttons\n  const prevBtn = document.getElementById('prevBtn');\n  const nextBtn = document.getElementById('nextBtn');\n  function updateControls() {\n    prevBtn.disabled = currentStep === 0;\n    nextBtn.disabled = currentStep === nodes.length - 1;\n  }\n\n  // Button event handlers\n  prevBtn.addEventListener('click', () => {\n    if (currentStep > 0) {\n      currentStep--;\n      updateVisibility();\n    }\n  });\n  nextBtn.addEventListener('click', () => {\n    if (currentStep < nodes.length - 1) {\n      currentStep++;\n      updateVisibility();\n    }\n  });\n\n  // Node click to reveal that node and show details (and activate)\n  nodeElements.forEach((el, id) => {\n    el.addEventListener('click', () => {\n      const idx = revealOrder.indexOf(id);\n      if (idx >= 0) {\n        currentStep = idx;\n        updateVisibility();\n      }\n    });\n    // Keyboard accessibility for nodes\n    el.addEventListener('keydown', (ev) => {\n      if (ev.key === 'Enter' || ev.key === ' ') {\n        ev.preventDefault();\n        el.click();\n      }\n    });\n  });\n\n  // Sidebar toggle button for mobile\n  const sidebar = document.getElementById('sidebar');\n  const toggleSidebarBtn = document.getElementById('toggleSidebar');\n  toggleSidebarBtn.addEventListener('click', () => {\n    const isActive = sidebar.classList.contains('active');\n    if (isActive) {\n      sidebar.classList.remove('active');\n      toggleSidebarBtn.setAttribute('aria-label', 'Open Sidebar');\n    } else {\n      sidebar.classList.add('active');\n      toggleSidebarBtn.setAttribute('aria-label', 'Close Sidebar');\n    }\n  });\n\n  // Clicking outside sidebar closes it on mobile\n  document.body.addEventListener('click', (evt) => {\n    if (window.innerWidth <= 900) {\n      if (!sidebar.contains(evt.target) && evt.target !== toggleSidebarBtn) {\n        sidebar.classList.remove('active');\n        toggleSidebarBtn.setAttribute('aria-label', 'Open Sidebar');\n      }\n    }\n  });\n\n  // Initial reveal\n  updateVisibility();\n\n  // PostMessage listener for widget actions (CRITICAL)\n  window.addEventListener('message', function(event) {\n    const { type, target, state, content } = event.data;\n\n    switch (type) {\n      case 'SET_WIDGET_STATE':\n        if (state) {\n          Object.entries(state).forEach(([key, value]) => {\n            const node = document.getElementById('node-' + key) || document.querySelector('[data-node=\"' + key + '\"]');\n            if (node) {\n              node.style.opacity = value ? '1' : '0.35';\n              node.classList.toggle('active', !!value);\n            }\n          });\n        }\n        break;\n\n      case 'HIGHLIGHT_ELEMENT':\n        const highlightEl = document.querySelector(target);\n        if (highlightEl) {\n          highlightEl.style.outline = '3px solid rgba(139, 92, 246, 0.8)';\n          highlightEl.style.outlineOffset = '4px';\n          highlightEl.style.animation = 'pulse-highlight 2s infinite';\n          setTimeout(() => {\n            highlightEl.style.outline = '';\n            highlightEl.style.animation = '';\n          }, 3000);\n        }\n        break;\n\n      case 'ANNOTATE_ELEMENT':\n        const annotateEl = document.querySelector(target);\n        if (annotateEl && content) {\n          const rect = annotateEl.getBoundingClientRect();\n          const tooltip = document.createElement('div');\n          tooltip.className = 'teacher-annotation';\n          tooltip.style.cssText = 'position:fixed; top:' + (rect.top - 40) + 'px; left:' + rect.left + 'px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;';\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n        break;\n\n      case 'REVEAL_ELEMENT':\n        const revealEl = document.querySelector(target);\n        if (revealEl) {\n          revealEl.style.display = '';\n          revealEl.style.opacity = '1';\n        }\n        break;\n    }\n  });\n\n  // Append CSS animation styles (already included in style tag above, but add in JS code as requested)\n  const style = document.createElement('style');\n  style.textContent = `\n  @keyframes pulse-highlight {\n    0%, 100% { outline-color: rgba(139, 92, 246, 0.8); }\n    50% { outline-color: rgba(139, 92, 246, 0.4); }\n  }\n  @keyframes fadeIn {\n    from { opacity: 0; transform: translateY(10px); }\n    to { opacity: 1; transform: translateY(0); }\n  }\n  `;\n  document.head.appendChild(style);\n})();\n</script>\n</body>\n</html>",
      "widgetType": "diagram",
      "widgetConfig": {
        "nodes": [
          {
            "id": "n1",
            "icon": "📐",
            "label": "Matrix Formulation Loss Function",
            "details": "Explore the detailed derivation and matrix formulation of the GRPO loss function incorporating group-wise operations and policy reward decomposition. We analyze the structure of the loss \\( L = - \\sum_g \\sum_i Q_i^{(g)} \\log \\pi_i^{(g)} \\) using batch matrix notations."
          },
          {
            "id": "n2",
            "icon": "📈",
            "label": "Gradient Flow and Updates",
            "details": "Analyze the gradient flow process and backpropagation updates within TRL and GRPO frameworks. We delve into the chain rule application on the matrix loss and identify how gradients propagate through log policy matrices with PyTorch autograd semantics."
          },
          {
            "id": "n3",
            "icon": "🔄",
            "label": "Effect of Group Completions on Reward Gradient",
            "details": "Examine the impact of group completions on the reward gradient. Group completions adjust reward attributions across samples, affecting the total gradient vector and influencing convergence and exploration/exploitation balance."
          },
          {
            "id": "n4",
            "icon": "🧠",
            "label": "Interactive Exploration of Key Equations",
            "details": "Engage with principal equations interactively. Explore parameter modifications and verify formula outcomes with Python/PyTorch styled code snippets illustrating key steps in gradient and loss computation."
          },
          {
            "id": "n5",
            "icon": "🎯",
            "label": "Derivation of GRPO Loss Function Matrix Formulation",
            "details": "Conclude with the complete and formal GRPO matrix loss function derivation. This formula is critical for next-generation reinforcement learning algorithms with group reward structures and is verified against state-of-the-art research trends in 2024–2026."
          }
        ],
        "edges": [
          {
            "from": "n1",
            "to": "n2",
            "label": "Derivation Flow"
          },
          {
            "from": "n2",
            "to": "n3",
            "label": "Gradient Influence"
          },
          {
            "from": "n3",
            "to": "n4",
            "label": "Exploration Interface"
          },
          {
            "from": "n4",
            "to": "n5",
            "label": "Final Result"
          }
        ],
        "revealOrder": [
          "n1",
          "n2",
          "n3",
          "n4",
          "n5"
        ]
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-3",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Mathematical Formulations and Derivations</h2>"
          },
          {
            "id": "review-text-3-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">For rewards zero, one, one, and two, the mean is one. The population standard deviation is the square root of one half. The advantages are approximately minus1.414, zero, zero, and1.414.</p>"
          },
          {
            "id": "review-text-3-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">If rewards are identical, there is no relative ranking signal. A numerical epsilon avoids division by zero; trainer variants differ.</p>"
          },
          {
            "id": "review-math-3",
            "type": "text",
            "left": 50,
            "top": 460,
            "width": 900,
            "height": 85,
            "content": "<p style=\"font-size:20px\">Aᵢ = (rᵢ − mean(r)) / (std(r) + ε)</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[4].actions",
    "before": [
      {
        "id": "action_sm_vbWg_",
        "type": "spotlight",
        "elementId": "text_QDYc4r8o"
      },
      {
        "id": "action_9UZ_rPLW",
        "type": "speech",
        "text": "Survey the systems optimizations that made TRL plus GRPO practical at scale: rollout throughput, fused kernels, context memory, and distributed alignment, rather than a new estimator alone."
      },
      {
        "id": "action_bOQMCMUs",
        "type": "spotlight",
        "elementId": "text_OYw7V1z9"
      },
      {
        "id": "action_Pxd3MdkE",
        "type": "speech",
        "text": "First, vLLM accelerates rollout generation with PagedAttention and continuous batching: key value cache is paged like virtual memory, so long prompts and many sampled completions share GPU memory instead of fragmenting it."
      },
      {
        "id": "action_CO9Osuh3",
        "type": "spotlight",
        "elementId": "text_NNYpksnq"
      },
      {
        "id": "action_2G-ZdHQF",
        "type": "speech",
        "text": "Next, Liger Kernel fuses normalization, gated MLP, and cross entropy paths into fewer CUDA kernels, cutting launch overhead and high bandwidth memory traffic; the gradient norm is unchanged, only memory movement is."
      },
      {
        "id": "action_QTnFfEJn",
        "type": "spotlight",
        "elementId": "text_3A0Td8yc"
      },
      {
        "id": "action_o_5SkizC",
        "type": "speech",
        "text": "Unsloth attacks memory and context: quantized or low rank adapters, activation checkpointing, and careful RoPE positional handling extend usable context while keeping optimizer states and logits from dominating memory."
      },
      {
        "id": "action__HWyVFnc",
        "type": "spotlight",
        "elementId": "text_mpih1IYs"
      },
      {
        "id": "action_NzyRJTUv",
        "type": "speech",
        "text": "Finally, scalable alignment pipelines separate generation, reward scoring, and learner updates across workers, with asynchronous queues and sharded checkpoints so throughput, not synchronization, limits group relative policy optimization."
      },
      {
        "id": "action_Zj49gFST",
        "type": "spotlight",
        "elementId": "latex_xigKGLUP"
      },
      {
        "id": "action_iIXmoUZQ",
        "type": "speech",
        "text": "The objective is expected reward under the current policy minus beta times the Kullback Leibler divergence to the frozen reference; GRPO estimates each advantage by centering a sampled group's rewards and dividing by their standard deviation."
      },
      {
        "id": "action_S4ksW5Z-",
        "type": "speech",
        "text": "The naive view says alignment is only a better loss; the systems view says throughput, memory, and estimator variance decide what is trainable. Keep those coupled when you read TRL or DeepSeekMath style GRPO."
      }
    ],
    "after": [
      {
        "id": "review-4-0",
        "type": "speech",
        "text": "GRPO uses a clipped importance-ratio objective. The old sampling policy appears in the ratio. A reference policy can provide a separate KL regularizer."
      },
      {
        "id": "review-4-1",
        "type": "speech",
        "text": "Do not confuse the old policy with the reference policy, and do not minimize reward."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[4].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "EPt3v6LqpIhalT6J8qQk2",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_QDYc4r8o",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>State-of-the-Art GRPO Systems and Optimizations</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_TAERmA9t",
            "type": "shape",
            "left": 70,
            "top": 120,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_fEZU0l1A",
            "type": "text",
            "left": 60,
            "top": 140,
            "width": 880,
            "height": 94,
            "content": "<p style=\"font-size:18px;\">Throughput, memory, and variance control for KL-regularized alignment in TRL</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_4-wuwBAE",
            "type": "shape",
            "left": 60,
            "top": 250,
            "width": 400,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dbeafe",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_OYw7V1z9",
            "type": "text",
            "left": 80,
            "top": 282,
            "width": 360,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">vLLM rollouts: PagedAttention and continuous batching</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "shape_h6GR2oM4",
            "type": "shape",
            "left": 500,
            "top": 250,
            "width": 400,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dcfce7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_NNYpksnq",
            "type": "text",
            "left": 520,
            "top": 282,
            "width": 360,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Liger Kernel: fused normalization, MLP, and cross entropy</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "latex_SBc5elim",
            "type": "latex",
            "left": 60,
            "top": 410,
            "width": 880,
            "height": 100,
            "latex": "\\text{Key formula: }\\ \\ \\max_{\\theta} \\ \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}}[R(\\tau)] \\quad\\text{with fused kernels for efficiency}",
            "color": "#000000",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:1.5021em;vertical-align:-0.7521em;\"></span><span class=\"mord text\"><span class=\"mord\">Key formula: </span></span><span class=\"mspace\"> </span><span class=\"mspace\"> </span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.4306em;\"><span style=\"top:-2.3479em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span><span class=\"mop\">max</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.7521em;\"><span></span></span></span></span></span><span class=\"mspace\"> </span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathbb\">E</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1514em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.1132em;\">τ</span><span class=\"mrel mtight\">∼</span><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3448em;\"><span style=\"top:-2.3488em;margin-left:-0.0359em;margin-right:0.0714em;\"><span class=\"pstrut\" style=\"height:2.5em;\"></span><span class=\"sizing reset-size3 size1 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1512em;\"><span></span></span></span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2559em;\"><span></span></span></span></span></span></span><span class=\"mopen\">[</span><span class=\"mord mathnormal\" style=\"margin-right:0.00773em;\">R</span><span class=\"mopen\">(</span><span class=\"mord mathnormal\" style=\"margin-right:0.1132em;\">τ</span><span class=\"mclose\">)]</span><span class=\"mspace\" style=\"margin-right:1em;\"></span><span class=\"mord text\"><span class=\"mord\">with fused kernels for efficiency</span></span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          },
          {
            "id": "shape_tnfsRwsY",
            "type": "shape",
            "left": 60,
            "top": 520,
            "width": 400,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fef3c7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_3A0Td8yc",
            "type": "text",
            "left": 80,
            "top": 552,
            "width": 360,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Unsloth: adapters, checkpointing, RoPE-aware long context</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#92400e",
            "rotate": 0
          },
          {
            "id": "shape_FDjGq6zw",
            "type": "shape",
            "left": 500,
            "top": 520,
            "width": 400,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fee2e2",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_mpih1IYs",
            "type": "text",
            "left": 520,
            "top": 552,
            "width": 360,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Scalable pipelines: asynchronous generation, reward, learner</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#b91c1c",
            "rotate": 0
          },
          {
            "id": "latex_xigKGLUP",
            "type": "latex",
            "left": 60,
            "top": 670,
            "width": 880,
            "height": 100,
            "latex": "\\text{Alignment objective: } \\quad \\min_{\\phi} \\ \\mathcal{L}_{align} = \\mathbb{E}_{x \\sim D}[\\ell(f_{\\phi}(x), y)]",
            "color": "#000000",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:1.5827em;vertical-align:-0.8882em;\"></span><span class=\"mord text\"><span class=\"mord\">Alignment objective: </span></span><span class=\"mspace\" style=\"margin-right:1em;\"></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.6679em;\"><span style=\"top:-2.3479em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">ϕ</span></span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span><span class=\"mop\">min</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.8882em;\"><span></span></span></span></span></span><span class=\"mspace\"> </span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathcal\">L</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">a</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.01968em;\">l</span><span class=\"mord mathnormal mtight\">i</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">g</span><span class=\"mord mathnormal mtight\">n</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2861em;\"><span></span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:1.0361em;vertical-align:-0.2861em;\"></span><span class=\"mord\"><span class=\"mord mathbb\">E</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3283em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">x</span><span class=\"mrel mtight\">∼</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">D</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mopen\">[</span><span class=\"mord\">ℓ</span><span class=\"mopen\">(</span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.10764em;\">f</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.1076em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">ϕ</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2861em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord mathnormal\">x</span><span class=\"mclose\">)</span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">y</span><span class=\"mclose\">)]</span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-4",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>State-of-the-Art Techniques and Optimizations</h2>"
          },
          {
            "id": "review-text-4-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">GRPO uses a clipped importance-ratio objective. The old sampling policy appears in the ratio. A reference policy can provide a separate KL regularizer.</p>"
          },
          {
            "id": "review-text-4-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Do not confuse the old policy with the reference policy, and do not minimize reward.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[5].actions",
    "before": [
      {
        "id": "action_8QDoTERL",
        "type": "spotlight",
        "elementId": "text_-HJJe2fD"
      },
      {
        "id": "action_tkDTgSc0",
        "type": "speech",
        "text": "We now implement GRPO in Python and PyTorch: the trainer subclass, reward composition, dataclass configuration, and PEFT LoRA adapters that make large policy optimization tractable."
      },
      {
        "id": "action_kqjjVCuo",
        "type": "spotlight",
        "elementId": "text_z5XwEhwZ"
      },
      {
        "id": "action_PNmR1ciC",
        "type": "speech",
        "text": "Start from the transformers Trainer class and specialize GRPOTrainer: it owns generation, group relative advantages, the clipped surrogate, KL regularization to the reference policy, and optimizer stepping."
      },
      {
        "id": "action_uRmPVhmb",
        "type": "spotlight",
        "elementId": "text_Zx_gm7QT"
      },
      {
        "id": "action_ZB8logOI",
        "type": "speech",
        "text": "The essential override is the compute loss method: sample a group per prompt, score each completion, normalize rewards within the group, then maximize the likelihood ratio under a clipped trust region."
      },
      {
        "id": "action_MMtBySYE",
        "type": "spotlight",
        "elementId": "latex_aan42f9T"
      },
      {
        "id": "action_NHvVCssE",
        "type": "speech",
        "text": "Formalize reward as a scalar function of state and action, often prompt and completion: task score plus format or safety terms, minus a KL penalty that keeps the policy near reference."
      },
      {
        "id": "action_URwgC9CE",
        "type": "spotlight",
        "elementId": "text_eiBkYxYk"
      },
      {
        "id": "action_wU1ndsCQ",
        "type": "speech",
        "text": "In practice, compose verifiable environment rewards with learned or heuristic auxiliaries, weight them by lambda, clip outliers, and standardize each group before advantage estimation."
      },
      {
        "id": "action_BGqbjngR",
        "type": "spotlight",
        "elementId": "text_tqs6NgET"
      },
      {
        "id": "action_84nZc8o9",
        "type": "speech",
        "text": "Finally, declare hyperparameters in a Python dataclass: learning rate, batch and group size, KL coefficient, clip epsilon, temperature, and gradient accumulation, all typed and reproducible."
      },
      {
        "id": "action_XbZzbyPV",
        "type": "speech",
        "text": "Combined with PEFT and LoRA, only low rank adapter matrices train while the base transformer stays frozen, cutting optimizer state and memory so GRPO ablations fit on realistic hardware."
      }
    ],
    "after": [
      {
        "id": "review-5-0",
        "type": "speech",
        "text": "PPO commonly learns a value critic for its advantage estimate. Original GRPO replaces that critic with a group-based baseline."
      },
      {
        "id": "review-5-1",
        "type": "speech",
        "text": "Neither method guarantees stability or correctness. Group size, reward quality, clipping and sampling still matter."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[5].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "7BXa5GeOAKK-jbH7KNwGl",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_-HJJe2fD",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:36px;\"><strong>GRPO Implementation in Python and PyTorch</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1a1a1a",
            "rotate": 0
          },
          {
            "id": "text_L4FbhMXg",
            "type": "text",
            "left": 60,
            "top": 130,
            "width": 880,
            "height": 58,
            "content": "<p style=\"font-size:24px; color:#5b9bd5;\">Trainer internals, rewards, configs, adapters</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#5b9bd5",
            "rotate": 0
          },
          {
            "id": "text_z5XwEhwZ",
            "type": "text",
            "left": 60,
            "top": 200,
            "width": 430,
            "height": 130,
            "content": "<p style=\"font-size:18px;\"><strong>Mechanisms to inspect:</strong></p><p style=\"font-size:18px;\">• GRPOTrainer extends transformers.Trainer: rollout, advantage, loss</p><p style=\"font-size:18px;\">• Group-normalized rewards with KL-to-reference penalty</p><p style=\"font-size:18px;\">• @dataclass configs: clip epsilon, beta, group size</p><p style=\"font-size:18px;\">• PEFT and LoRA adapters for low-memory policy updates</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_oDmX2aaj",
            "type": "shape",
            "left": 510,
            "top": 200,
            "width": 370,
            "height": 220,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#f5f7fa",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_Zx_gm7QT",
            "type": "text",
            "left": 530,
            "top": 210,
            "width": 330,
            "height": 43,
            "content": "<p style=\"font-size:20px; font-weight:bold; color:#1e40af;\">Code Snippet: GRPOTrainer loss path</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "text_UZV3DkUc",
            "type": "text",
            "left": 530,
            "top": 260,
            "width": 330,
            "height": 166,
            "content": "<p style=\"font-size:14px; font-family: monospace; white-space: pre-wrap;\">class GRPOTrainer(transformers.Trainer):\n    def compute_loss(self, model, inputs, return_outputs=False):\n        completions = self.generate_group(inputs)\n        rewards = self.reward_fn(inputs, completions)\n        adv = (rewards - rewards.mean()) / (rewards.std() + 1e-8)\n        return self.grpo_objective(model, completions, adv)</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "latex_aan42f9T",
            "type": "latex",
            "left": 60,
            "top": 360,
            "width": 880,
            "height": 80,
            "latex": "\\text{Reward}\\ \\mathcal{R}(s,a) = r_{env}(s,a) + \\lambda \\cdot r_{additional}(s,a)",
            "color": "#5b9bd5",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:1em;vertical-align:-0.25em;\"></span><span class=\"mord text\"><span class=\"mord\">Reward</span></span><span class=\"mspace\"> </span><span class=\"mord mathcal\">R</span><span class=\"mopen\">(</span><span class=\"mord mathnormal\">s</span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\">a</span><span class=\"mclose\">)</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:1em;vertical-align:-0.25em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.02778em;\">r</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1514em;\"><span style=\"top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">e</span><span class=\"mord mathnormal mtight\">n</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">v</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord mathnormal\">s</span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\">a</span><span class=\"mclose\">)</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">+</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6944em;\"></span><span class=\"mord mathnormal\">λ</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">⋅</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:1em;vertical-align:-0.25em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.02778em;\">r</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">a</span><span class=\"mord mathnormal mtight\">dd</span><span class=\"mord mathnormal mtight\">i</span><span class=\"mord mathnormal mtight\">t</span><span class=\"mord mathnormal mtight\">i</span><span class=\"mord mathnormal mtight\">o</span><span class=\"mord mathnormal mtight\">na</span><span class=\"mord mathnormal mtight\" style=\"margin-right:0.01968em;\">l</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord mathnormal\">s</span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\">a</span><span class=\"mclose\">)</span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          },
          {
            "id": "latex_ZcdE9EdZ",
            "type": "latex",
            "left": 60,
            "top": 460,
            "width": 880,
            "height": 120,
            "latex": "\\begin{aligned}\\n\\text{GRPO Objective:}\\quad & J(\\theta) = \\mathbb{E}_{\\pi_\\theta}[\\sum_{t=0}^T \\gamma^t \\mathcal{R}(s_t,a_t)] \\\\n\\text{with}quad & \\mathcal{R}(s,a) \\text{ combining env and auxiliary rewards}\\n\\end{aligned}",
            "color": "#333333",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:4.8954em;vertical-align:-2.1977em;\"></span><span class=\"mord\"><span class=\"mtable\"><span class=\"col-align-r\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.6977em;\"><span style=\"top:-4.6977em;\"><span class=\"pstrut\" style=\"height:3.8283em;\"></span><span class=\"mord\"><span class=\"mord text\" style=\"color:#cc0000;\"><span class=\"mord\" style=\"color:#cc0000;\">\\n</span></span><span class=\"mord text\"><span class=\"mord\">GRPO Objective:</span></span><span class=\"mspace\" style=\"margin-right:1em;\"></span></span></span><span style=\"top:-2.2906em;\"><span class=\"pstrut\" style=\"height:3.8283em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\">n</span><span class=\"mord text\"><span class=\"mord\">with</span></span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">q</span><span class=\"mord mathnormal\">u</span><span class=\"mord mathnormal\">a</span><span class=\"mord mathnormal\">d</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.1977em;\"><span></span></span></span></span></span><span class=\"col-align-l\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.6977em;\"><span style=\"top:-4.6977em;\"><span class=\"pstrut\" style=\"height:3.8283em;\"></span><span class=\"mord\"><span class=\"mord\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.09618em;\">J</span><span class=\"mopen\">(</span><span class=\"mord mathnormal\" style=\"margin-right:0.02778em;\">θ</span><span class=\"mclose\">)</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mord\"><span class=\"mord mathbb\">E</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1514em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3448em;\"><span style=\"top:-2.3488em;margin-left:-0.0359em;margin-right:0.0714em;\"><span class=\"pstrut\" style=\"height:2.5em;\"></span><span class=\"sizing reset-size3 size1 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1512em;\"><span></span></span></span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2559em;\"><span></span></span></span></span></span></span><span class=\"mopen\">[</span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.8283em;\"><span style=\"top:-1.8829em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3.05em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\">t</span><span class=\"mrel mtight\">=</span><span class=\"mord mtight\">0</span></span></span></span><span style=\"top:-3.05em;\"><span class=\"pstrut\" style=\"height:3.05em;\"></span><span><span class=\"mop op-symbol large-op\">∑</span></span></span><span style=\"top:-4.3em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3.05em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.13889em;\">T</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.2671em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.05556em;\">γ</span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.8436em;\"><span style=\"top:-3.113em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span></span></span></span></span><span class=\"mord mathcal\">R</span><span class=\"mopen\">(</span><span class=\"mord\"><span class=\"mord mathnormal\">s</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\">a</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2806em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mclose\">)]</span></span></span><span style=\"top:-2.2906em;\"><span class=\"pstrut\" style=\"height:3.8283em;\"></span><span class=\"mord\"><span class=\"mord\"></span><span class=\"mord mathcal\">R</span><span class=\"mopen\">(</span><span class=\"mord mathnormal\">s</span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\">a</span><span class=\"mclose\">)</span><span class=\"mord text\"><span class=\"mord\"> combining env and auxiliary rewards</span></span><span class=\"mord text\" style=\"color:#cc0000;\"><span class=\"mord\" style=\"color:#cc0000;\">\\n</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.1977em;\"><span></span></span></span></span></span></span></span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          },
          {
            "id": "text_eiBkYxYk",
            "type": "text",
            "left": 60,
            "top": 320,
            "width": 430,
            "height": 112,
            "content": "<p style=\"font-size:18px; color:#166534;\"><strong>Reward Design</strong></p><p style=\"font-size:18px;\">• Verifiable task reward plus auxiliary format or safety terms</p><p style=\"font-size:18px;\">• Scalar lambda weights components; clip and normalize outliers</p><p style=\"font-size:18px;\">• Group baseline yields low-variance relative advantages</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "text_tqs6NgET",
            "type": "text",
            "left": 60,
            "top": 560,
            "width": 880,
            "height": 94,
            "content": "<p style=\"font-size:18px; color:#92400e;\"><strong>Configuration as @dataclass</strong></p><p style=\"font-size:18px;\">• lr, batch size, group size, epochs, gradient accumulation</p><p style=\"font-size:18px;\">• clip epsilon, KL beta, temperature, max length, seed</p><p style=\"font-size:18px;\">• Typed, versioned configs make ablations reproducible</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#92400e",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-5",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Implementation Details with Python &amp; PyTorch</h2>"
          },
          {
            "id": "review-text-5-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">PPO commonly learns a value critic for its advantage estimate. Original GRPO replaces that critic with a group-based baseline.</p>"
          },
          {
            "id": "review-text-5-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Neither method guarantees stability or correctness. Group size, reward quality, clipping and sampling still matter.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[6].actions",
    "before": [
      {
        "id": "action_M4zktaL-",
        "type": "speech",
        "text": "Open the TRL GRPO trainer and inspect the reward path first: how completions are scored, advantages normalized, and the KL penalty applied."
      },
      {
        "id": "action__DkO1jXU",
        "type": "widget_highlight",
        "target": "#code-input",
        "content": "This is the code editor where reward calculations and algorithm parameters are defined."
      },
      {
        "id": "action_atdlOBtY",
        "type": "speech",
        "text": "Edit the reward function, rerun a short sweep, and watch reward variance, KL drift, and entropy move before policy collapse appears."
      },
      {
        "id": "action_jLg8vQNp",
        "type": "widget_highlight",
        "target": "#run-btn",
        "content": "Use this button to execute the updated code and generate new results."
      },
      {
        "id": "action_qH7EOYIV",
        "type": "speech",
        "text": "Then sweep learning rate, beta, clipping epsilon, and sampling temperature; track gradient norm, ratio spikes, and whether advantages stay bounded."
      },
      {
        "id": "action_mUE06f1d",
        "type": "speech",
        "text": "Finally vary batch size, group size, and reward normalization; compare pass rate against variance, since larger groups cut advantage noise at higher cost."
      },
      {
        "id": "action_awHPocc4",
        "type": "widget_highlight",
        "target": "#output",
        "content": "This output pane displays the results and logs from running the code. Watch it closely to analyze algorithm behavior after each change."
      }
    ],
    "after": [
      {
        "id": "review-6-0",
        "type": "speech",
        "text": "Use the Workbench to change one reward while holding the other three fixed. Predict which advantages will change before moving the control."
      },
      {
        "id": "review-6-1",
        "type": "speech",
        "text": "All four advantages can change because both the group mean and its spread depend on every reward."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[6].type",
    "before": "interactive",
    "after": "slide",
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[6].content",
    "before": {
      "type": "interactive",
      "url": "",
      "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Hands-On Code Exploration: TRL + GRPO Algorithm</title>\n<style>\n  body {\n    margin: 0; font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen,\n      Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;\n    background: #f9fafb; color: #1a202c; display: flex; flex-direction: column; height: 100vh;\n  }\n  header {\n    background: #8b5cf6; color: white;\n    padding: 1rem 1.5rem;\n    font-weight: 700;\n    font-size: 1.25rem;\n    text-align: center;\n    user-select: none;\n  }\n  #container {\n    flex: 1;\n    display: flex;\n    flex-direction: row;\n    gap: 1rem;\n    padding: 1rem;\n    box-sizing: border-box;\n  }\n  #editor-pane {\n    flex: 1 1 60%;\n    display: flex;\n    flex-direction: column;\n  }\n  #code-label {\n    font-weight: 600; margin-bottom: 0.25rem;\n    color: #4c51bf;\n  }\n  #code-input {\n    border: 1px solid #cbd5e0;\n    border-radius: 6px;\n    height: 400px;\n  }\n  #run-btn {\n    margin-top: 0.75rem;\n    width: 140px;\n    align-self: flex-start;\n    background-color: #7c3aed;\n    border: none;\n    color: white;\n    font-weight: 700;\n    font-size: 1rem;\n    padding: 0.5rem 1rem;\n    border-radius: 6px;\n    cursor: pointer;\n    transition: background-color 0.25s ease;\n  }\n  #run-btn:disabled {\n    background: #a78bfa;\n    cursor: not-allowed;\n  }\n  #status {\n    margin-left: 1rem;\n    font-size: 0.9rem;\n    font-weight: 500;\n    color: #6b7280;\n    align-self: center;\n  }\n  #output-pane {\n    flex: 1 1 40%;\n    display: flex;\n    flex-direction: column;\n  }\n  #output-label {\n    font-weight: 600; margin-bottom: 0.25rem;\n    color: #4c51bf;\n  }\n  #output {\n    white-space: pre-wrap;\n    border: 1px solid #cbd5e0;\n    border-radius: 6px;\n    background: white;\n    height: 200px;\n    overflow-y: auto;\n    padding: 0.75rem 1rem;\n    font-family: Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n    font-size: 0.9rem;\n    color: #111827;\n  }\n  #testcases-pane {\n    margin-top: 1rem;\n    max-height: 150px;\n    overflow-y: auto;\n    border-top: 1px solid #e5e7eb;\n    padding-top: 0.75rem;\n  }\n  #testcases-pane summary {\n    font-weight: 600;\n    cursor: pointer;\n    padding: 0 0.3rem;\n    color: #5a3eeb;\n  }\n  #testcases-list {\n    list-style: none;\n    margin: 0.5rem 0 0 0;\n    padding: 0;\n  }\n  .testcase-item {\n    background: #ede9fe;\n    border-radius: 5px;\n    margin-bottom: 0.4rem;\n    padding: 0.4rem 0.75rem;\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n    font-family: monospace;\n    font-size: 0.9rem;\n  }\n  .testcase-desc {\n    flex: 1;\n    margin-right: 0.6rem;\n    font-weight: 500;\n    color: #4b5563;\n  }\n  .testcase-pass {\n    color: #16a34a;\n    font-weight: 700;\n  }\n  .testcase-fail {\n    color: #dc2626;\n    font-weight: 700;\n  }\n  #hints-section {\n    margin-top: 1rem;\n  }\n  #hints-title {\n    color: #4c51bf;\n    font-weight: 600;\n    margin-bottom: 0.4rem;\n  }\n  .hint {\n    background: #ede9fe;\n    border-radius: 5px;\n    margin-bottom: 0.5rem;\n    padding: 0.65rem 1rem;\n    color: #3730a3;\n    font-size: 0.9rem;\n    display: none;\n    font-style: italic;\n  }\n  .hint-visible {\n    display: block;\n  }\n  #show-hint-btn {\n    background: #7c3aed;\n    color: white;\n    border: none;\n    border-radius: 6px;\n    padding: 0.4rem 0.85rem;\n    font-weight: 600;\n    font-size: 0.9rem;\n    cursor: pointer;\n    display: inline-block;\n    margin-bottom: 1rem;\n  }\n  #show-hint-btn:disabled {\n    background: #a78bfa;\n    cursor: not-allowed;\n  }\n  /* Responsive stack on small screens */\n  @media (max-width: 800px) {\n    #container {\n      flex-direction: column;\n      padding: 1rem 0.5rem;\n    }\n    #editor-pane, #output-pane {\n      flex: none;\n      width: 100%;\n      margin-bottom: 1rem;\n    }\n    #code-input {\n      height: 200px;\n    }\n    #testcases-pane {\n      max-height: none;\n    }\n  }\n  /* Teacher annotation style */\n  .teacher-annotation {\n    box-shadow: 0 0 15px rgba(139,92,246,0.7);\n  }\n</style>\n<!-- CodeMirror 6 CSS and JS via CDN -->\n\n\n\n\n<script src=\"https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js\"></script>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<header>Hands-On Code Exploration: TRL + GRPO Algorithm (Python)</header>\n<section id=\"container\" aria-label=\"Code playground container\">\n  <section id=\"editor-pane\">\n    <label id=\"code-label\" for=\"code-input\" aria-live=\"polite\">Code Editor (Python):</label>\n    <div id=\"code-input\" aria-label=\"Python code editor\"></div>\n    <button id=\"run-btn\" aria-label=\"Run code button\" disabled>Run Code</button>\n    <span id=\"status\" aria-live=\"polite\" aria-atomic=\"true\">Loading Python environment...</span>\n    <section id=\"hints-section\" aria-live=\"polite\" aria-atomic=\"true\">\n      <button id=\"show-hint-btn\" type=\"button\" aria-expanded=\"false\" aria-controls=\"hints-list\" disabled>Show Hint</button>\n      <ol id=\"hints-list\" style=\"padding-left: 1.25rem; margin:0;\">\n        <li class=\"hint\" id=\"hint-1\">Review the reward function formulation in TRL & GRPO. Changes here affect agent incentives.</li>\n        <li class=\"hint\" id=\"hint-2\">Adjusting batch size impacts gradient estimation variance and sample efficiency.</li>\n        <li class=\"hint\" id=\"hint-3\">Experiment with group completion reward weight to balance individual vs. group learning objectives.</li>\n      </ol>\n    </section>\n  </section>\n  <section id=\"output-pane\">\n    <label id=\"output-label\" for=\"output\" aria-live=\"polite\">Output:</label>\n    <pre id=\"output\" role=\"region\" aria-live=\"polite\" aria-atomic=\"true\" tabindex=\"0\"></pre>\n    <details open id=\"testcases-pane\" aria-label=\"Test cases validation panel\">\n      <summary>Test Cases</summary>\n      <ul id=\"testcases-list\" aria-live=\"polite\" aria-atomic=\"true\"></ul>\n    </details>\n  </section>\n</section>\n<script type=\"module\">\nfunction createLessonEditor(parent, code) {\n const input=document.createElement('textarea'); input.value=code; input.spellcheck=false;\n input.setAttribute('aria-label','Python code editor');\n input.style.cssText='display:block;width:100%;min-height:320px;box-sizing:border-box;background:#171722;color:#e8e8ee;font:14px/1.6 monospace;padding:16px;border:1px solid #666;resize:vertical;white-space:pre;overflow:auto';\n parent.replaceChildren(input);\n const editor={getValue:()=>input.value,setValue:value=>input.value=value,focus:()=>input.focus(),dispatch:tr=>{const ch=tr.changes;if(ch)input.value=input.value.slice(0,ch.from)+ch.insert+input.value.slice(ch.to);}};\n Object.defineProperty(editor,'state',{get:()=>({doc:{toString:()=>input.value,length:input.value.length},update:tr=>tr})});\n return editor;\n}\n\n\n\n\nconst starterCode = `\\\n\"\"\"\nHands-On Code Exploration: TRL + GRPO Algorithm Snippet\n\nThis Python snippet models a simplification of the \nTraining Reinforcement Learning (TRL) reward update \nintegrated with Group Reward and Participation Optimization (GRPO).\n\nModify the 'calculate_reward' function's logic to inspect\nhow reward shaping influences learning dynamics.\n\nHyperparameters like batch_size and group_reward_weight\nallow you to observe diverse training behaviors interactively.\n\nAdvanced students should note the interplay between\nindividual and group reward signals, crucial in multi-agent \ntraining paradigms.\n\nReferences:\n- Nguyen et al., GRPO: Group Reward and Participation Optimization, ICML 2024.\n- Tang et al., TRL: Training Reinforcement Learning Theory, NeurIPS 2023.\n\n\"\"\"\n\nimport math\n\ndef calculate_reward(individual_rewards, group_complete, batch_size, group_reward_weight):\n    '''\n    Calculate combined reward for a training batch.\n    \n    Parameters:\n    - individual_rewards: list of floats, rewards per agent.\n    - group_complete: bool, whether group completion criteria met.\n    - batch_size: int, number of samples in batch.\n    - group_reward_weight: float in [0,1], weight applied to group completion reward.\n    \n    Returns:\n    - float: combined reward scalar.\n    '''\n    # Sum individual rewards\n    sum_individual = sum(individual_rewards)\n    \n    # Group completion reward, 1 if complete, else 0\n    group_reward = 1.0 if group_complete else 0.0\n    \n    # Normalize sum of individual rewards by batch size\n    normalized_indiv = sum_individual / max(batch_size, 1)\n    \n    # Combined reward weighted sum (modify this formula)\n    combined_reward = normalized_indiv + group_reward_weight * group_reward\n    \n    return combined_reward\n\n# Example usage:\n# Students may alter parameters and observe output\n\ndef main():\n    # Predefined example parameters\n    rewards = [0.8, 0.9, 1.0, 0.7]\n    group_finished = True\n    batch_sz = 4\n    grp_weight = 0.5\n    \n    combined = calculate_reward(rewards, group_finished, batch_sz, grp_weight)\n    print(f\"Combined reward for batch: {combined:.4f}\")\n\nif __name__ == \"__main__\":\n    main()\n`;\n\nconst testCases = [\n  {\n    id: 'tc1',\n    description: 'Basic reward with group complete and default group_reward_weight=0.5',\n    input: {\n      individual_rewards: [1, 1, 1, 1],\n      group_complete: true,\n      batch_size: 4,\n      group_reward_weight: 0.5\n    },\n    expected: '1.5'\n  },\n  {\n    id: 'tc2',\n    description: 'No group reward when group incomplete',\n    input: {\n      individual_rewards: [0.5, 0.5, 0.5, 0.5],\n      group_complete: false,\n      batch_size: 4,\n      group_reward_weight: 0.7\n    },\n    expected: '0.5'\n  },\n  {\n    id: 'tc3',\n    description: 'Group reward weight zero disables group contribution',\n    input: {\n      individual_rewards: [0.8, 0.7],\n      group_complete: true,\n      batch_size: 2,\n      group_reward_weight: 0.0\n    },\n    expected: '0.75'\n  },\n  {\n    id: 'tc4',\n    description: 'Large batch with uniform rewards and full group reward',\n    input: {\n      individual_rewards: Array(10).fill(0.6),\n      group_complete: true,\n      batch_size: 10,\n      group_reward_weight: 1.0\n    },\n    expected: '1.6'\n  },\n];\n\nconst hints = [\n  \"Review the reward function formulation in TRL & GRPO. Changes here affect agent incentives.\",\n  \"Adjusting batch size impacts gradient estimation variance and sample efficiency.\",\n  \"Experiment with group completion reward weight to balance individual vs. group learning objectives.\"\n];\n\nlet editor;\nlet pyodide = null;\nlet showHintBtn;\nlet hintIndex = 0;\n\nfunction createEditor() {\n  editor = createLessonEditor(document.getElementById('code-input'), starterCode);\n}\n\n// Utility to compare decimal numbers up to 4 decimal digits tolerance\nfunction floatsEqual(a, b, tolerance = 0.0001) {\n  return Math.abs(parseFloat(a) - parseFloat(b)) <= tolerance;\n}\n\nasync function initPyodideAndPackages() {\n  try {\n    pyodide = await loadPyodide({\n      stdout: () => {},\n      stderr: console.error\n    });\n    // No special packages like torch are loaded by default due to size/time constraints\n    // But this is easily extensible if desired in the future\n    await pyodide.runPythonAsync(`\nimport sys\nimport io\nsys.stdout = io.StringIO()\n    `);\n    document.getElementById('run-btn').disabled = false;\n    showHintBtn.disabled = false;\n    document.getElementById('status').textContent = \"Python environment ready\";\n  } catch (e) {\n    document.getElementById('status').textContent = \"Failed to load Python environment\";\n    alert(\"Error loading Python: \" + e.message);\n  }\n}\n\nasync function runCode() {\n  const runBtn = document.getElementById('run-btn');\n  runBtn.disabled = true;\n  document.getElementById('status').textContent = 'Running code...';\n  const outputEl = document.getElementById('output');\n  outputEl.textContent = '';\n  try {\n    const userCode = editor.state.doc.toString();\n    await pyodide.runPythonAsync(`\nimport sys\nimport io\nsys.stdout = io.StringIO()\n    `);\n    await pyodide.runPythonAsync(userCode);\n    const output = pyodide.runPython('sys.stdout.getvalue()');\n    outputEl.textContent = output || \"(No output)\";\n    runBtn.disabled = false;\n    document.getElementById('status').textContent = 'Execution completed';\n  } catch (e) {\n    outputEl.textContent = `Error: ${e.message}`;\n    runBtn.disabled = false;\n    document.getElementById('status').textContent = 'Execution failed';\n  }\n  runTests();\n}\n\nfunction createTestCaseElement(tc, passFail) {\n  const li = document.createElement('li');\n  li.classList.add('testcase-item');\n  li.id = tc.id;\n  const desc = document.createElement('div');\n  desc.classList.add('testcase-desc');\n  desc.textContent = tc.description;\n  const result = document.createElement('div');\n  result.textContent = passFail ? \"PASS\" : \"FAIL\";\n  result.className = passFail ? 'testcase-pass' : 'testcase-fail';\n  li.appendChild(desc);\n  li.appendChild(result);\n  return li;\n}\n\nfunction runTests() {\n  const ul = document.getElementById('testcases-list');\n  ul.innerHTML = ''; // Clear previous\n  const userCode = editor.state.doc.toString();\n  for (const tc of testCases) {\n    try {\n      // Reinitialize stdout capture per test\n      pyodide.runPython(`import sys, io; sys.stdout=io.StringIO()`);\n    } catch {}\n  }\n  let testsPassed = 0;\n  (async () => {\n    for (const tc of testCases) {\n      const {individual_rewards, group_complete, batch_size, group_reward_weight} = tc.input;\n      try {\n        await pyodide.runPythonAsync(`\nimport sys\nimport io\nsys.stdout = io.StringIO()\n${userCode.replace(/\"\"\"[\\s\\S]*?\"\"\"/g, '')}\nresult = calculate_reward(${JSON.stringify(individual_rewards)}, ${group_complete ? \"True\" : \"False\"}, ${batch_size}, ${group_reward_weight})\nprint(f\"{result:.4f}\")\n        `);\n        const output = pyodide.runPython('sys.stdout.getvalue()').trim();\n        const passFail = floatsEqual(output.split(\"\\n\").at(-1), tc.expected);\n        if(passFail) testsPassed++;\n        const li = createTestCaseElement(tc, passFail);\n        document.getElementById('testcases-list').appendChild(li);\n      } catch(e) {\n        const li = createTestCaseElement(tc, false);\n        li.querySelector('.testcase-desc').textContent += ` (Error: ${e.message})`;\n        document.getElementById('testcases-list').appendChild(li);\n      }\n    }\n    if(testsPassed === testCases.length){\n      document.getElementById('status').textContent = \"All tests passed! Try modifying code and running again.\";\n    } else {\n      document.getElementById('status').textContent = `Tests passed: ${testsPassed} / ${testCases.length}`;\n    }\n  })();\n}\n\n/* Hint system */\nfunction setupHints() {\n  showHintBtn = document.getElementById('show-hint-btn');\n  showHintBtn.disabled = false;\n  showHintBtn.addEventListener('click', () => {\n    const hintsList = document.getElementById('hints-list');\n    if (hintIndex < hints.length) {\n      const hintEl = document.getElementById(`hint-${hintIndex + 1}`);\n      if (hintEl) {\n        hintEl.classList.add('hint-visible');\n        showHintBtn.setAttribute('aria-expanded', 'true');\n      }\n      hintIndex++;\n      if (hintIndex >= hints.length) {\n        showHintBtn.disabled = true;\n        showHintBtn.textContent = \"No more hints\";\n        showHintBtn.setAttribute('aria-expanded', 'true');\n      }\n    }\n  });\n}\n\nwindow.addEventListener('load', () => {\n  createEditor();\n  setupHints();\n  initPyodideAndPackages();\n  document.getElementById('run-btn').addEventListener('click', runCode);\n});\n\n/* PostMessage listener per requirement */\nwindow.addEventListener('message', function(event) {\n  const { type, target, state, content } = event.data || {};\n  switch(type) {\n    case 'SET_WIDGET_STATE':\n      if(state && typeof state.code === 'string'){\n        if(typeof editor !== 'undefined' && typeof editor.setValue !== 'function'){\n          // CM6 uses dispatch for changes, so we update doc differently\n          const cur = editor.state.doc.toString();\n          if(cur !== state.code){\n            editor.dispatch({\n              changes: { from: 0, to: cur.length, insert: state.code }\n            });\n          }\n        } else if(typeof editor !== 'undefined' && typeof editor.dispatch === 'function'){\n          const cur = editor.state.doc.toString();\n          if(cur !== state.code){\n            editor.dispatch({\n              changes: { from: 0, to: cur.length, insert: state.code }\n            });\n          }\n        } else {\n          const ta = document.getElementById('code-input');\n          if(ta) ta.value = state.code;\n        }\n      }\n      if(state && state.run && typeof runCode === 'function') runCode();\n      break;\n    case 'HIGHLIGHT_ELEMENT':\n      if(target){\n        const el = document.querySelector(target);\n        if(el) {\n          el.style.outline = '3px solid rgba(139, 92, 246, 0.8)';\n          el.style.outlineOffset = '4px';\n          el.style.animation = 'pulse-highlight 2s infinite';\n          setTimeout(() => {\n            el.style.outline = '';\n            el.style.animation = '';\n          }, 3000);\n        }\n      }\n      break;\n    case 'ANNOTATE_ELEMENT':\n      if(target && content){\n        const el = document.querySelector(target);\n        if(el){\n          const rect = el.getBoundingClientRect();\n          const tooltip = document.createElement('div');\n          tooltip.className = 'teacher-annotation';\n          tooltip.style.cssText = 'position:fixed; top:' + (rect.top - 40) + 'px; left:' + rect.left + 'px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;';\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n      }\n      break;\n    case 'REVEAL_ELEMENT':\n      if(target){\n        const el = document.querySelector(target);\n        if(el){\n          el.style.display = '';\n          el.style.opacity = '1';\n        }\n      }\n      break;\n  }\n});\nconst style = document.createElement('style');\nstyle.textContent = '@keyframes pulse-highlight { 0%, 100% { outline-color: rgba(139, 92, 246, 0.8); } 50% { outline-color: rgba(139, 92, 246, 0.4); } } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }';\ndocument.head.appendChild(style);\n\n/* Embedded widget configuration JSON for reference */\nwindow.widgetConfig = {\n  type: \"code\",\n  language: \"python\",\n  description: \"Interactive code widget allowing students to test and modify TRL + GRPO algorithm snippets to observe training dynamics.\",\n  starterCode: starterCode,\n  testCases: testCases,\n  hints: hints,\n  solution: starterCode\n};\n</script>\n</body>\n</html>",
      "widgetType": "code"
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-6",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Hands-On Code Exploration</h2>"
          },
          {
            "id": "review-text-6-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Use the Workbench to change one reward while holding the other three fixed. Predict which advantages will change before moving the control.</p>"
          },
          {
            "id": "review-text-6-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">All four advantages can change because both the group mean and its spread depend on every reward.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[7].actions",
    "before": [
      {
        "id": "action_URREx5fq",
        "type": "spotlight",
        "elementId": "text_9m5KHQle"
      },
      {
        "id": "action_E_Q4ghHh",
        "type": "speech",
        "text": "We now turn to the frontier variants and open problems currently shaping trust region methods and group relative policy optimization, where theory and large-scale practice are still converging."
      },
      {
        "id": "action_PS-9bOKT",
        "type": "spotlight",
        "elementId": "text_LVJyn6L1"
      },
      {
        "id": "action_LFVcM9bn",
        "type": "speech",
        "text": "First, experimental trainers: online DPO closes the loop between sampling and preference updates, NashMD formulates alignment as a two-player game, and process reward models supervise intermediate reasoning steps."
      },
      {
        "id": "action_KV6RnQYY",
        "type": "spotlight",
        "elementId": "latex_8LRRcy9H"
      },
      {
        "id": "action_9aUG1DZ7",
        "type": "speech",
        "text": "The objective on this slide couples an online preference loss with a KL penalty to the reference policy, trading sample efficiency against drift from the supervised initialization."
      },
      {
        "id": "action_9ZdU8BTC",
        "type": "spotlight",
        "elementId": "text_LVJyn6L1"
      },
      {
        "id": "action_1mieHSdR",
        "type": "speech",
        "text": "Scaling laws govern the frontier: reward model overoptimization follows a predictable power law in the KL budget, so larger policies demand proportionally stronger reward models."
      },
      {
        "id": "action_NvoLWstk",
        "type": "spotlight",
        "elementId": "text_9m5KHQle"
      },
      {
        "id": "action_CUnBNzb8",
        "type": "speech",
        "text": "Reward model design remains the bottleneck: learned proxies are vulnerable to Goodhart collapse, reward hacking, and distribution shift once the policy optimizes against them at scale."
      },
      {
        "id": "action_OnSmuDXj",
        "type": "speech",
        "text": "Open directions include variance reduction in group-relative advantage estimation, stability of the KL constraint, and interpretability of learned reward signals."
      },
      {
        "id": "action_LViMvGsk",
        "type": "speech",
        "text": "These frontiers define the current research agenda: online preference optimization, game-theoretic alignment, process supervision, and overoptimization scaling, each of which we now examine in mechanistic detail."
      }
    ],
    "after": [
      {
        "id": "review-7-0",
        "type": "speech",
        "text": "A runnable trainer needs a model, tokenizer, prompt data and a tested reward function. Small teaching calculations do not reproduce a full training run."
      },
      {
        "id": "review-7-1",
        "type": "speech",
        "text": "Record the TRL version and objective settings: current implementations expose variants that differ from the original paper."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[7].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "GYg9YzCkaTfzSyMEDy72L",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_9m5KHQle",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Frontier Variants and Open Problems in Trust-Region Alignment</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_4fD9wUE2",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_9igZ_SW1",
            "type": "shape",
            "left": 60,
            "top": 170,
            "width": 880,
            "height": 190,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#f0f5fb",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_LVJyn6L1",
            "type": "text",
            "left": 80,
            "top": 194,
            "width": 840,
            "height": 130,
            "content": "<p style=\"font-size:18px;\">• Online DPO, NashMD, and process reward models (Lightman et al. 2023)</p><p style=\"font-size:18px;\">• Scaling laws: reward overoptimization vs. KL budget (Gao et al. 2023)</p><p style=\"font-size:18px;\">• Reward hacking, Goodhart collapse, distribution shift</p><p style=\"font-size:18px;\">• Open problems: variance reduction, stability, interpretability</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1f2937",
            "rotate": 0
          },
          {
            "id": "shape_M1BmGqJ_",
            "type": "shape",
            "left": 60,
            "top": 390,
            "width": 880,
            "height": 112,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#e4e9f7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "latex_8LRRcy9H",
            "type": "latex",
            "left": 80,
            "top": 406,
            "width": 840,
            "height": 80,
            "latex": "\\begin{aligned}&\\text{OnlineDPO: }\\ \\max_\\theta \\mathbb{E}_{(s,a)\\sim\\pi_\\theta} [r_\\phi(s,a)]\\\\&\\text{NashMD: }\\ \\min_\\theta \\max_\\psi \\mathbb{E}[U(\\pi_\\theta, \\pi_\\psi)]\\\\&\\text{PRM: }\\ \\text{Reward model } r_\\phi \\text{ updated with preference data}\\end{aligned}",
            "color": "#1e40af",
            "align": "left",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:5.4203em;vertical-align:-2.4602em;\"></span><span class=\"mord\"><span class=\"mtable\"><span class=\"col-align-r\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.9602em;\"><span style=\"top:-4.9602em;\"><span class=\"pstrut\" style=\"height:2.84em;\"></span><span class=\"mord\"></span></span><span style=\"top:-3.0681em;\"><span class=\"pstrut\" style=\"height:2.84em;\"></span><span class=\"mord\"></span></span><span style=\"top:-1.0398em;\"><span class=\"pstrut\" style=\"height:2.84em;\"></span><span class=\"mord\"></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.4602em;\"><span></span></span></span></span></span><span class=\"col-align-l\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.9602em;\"><span style=\"top:-5.1202em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\"></span><span class=\"mord text\"><span class=\"mord\">OnlineDPO: </span></span><span class=\"mspace\"> </span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.4306em;\"><span style=\"top:-2.3479em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span><span class=\"mop\">max</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.7521em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathbb\">E</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3448em;\"><span style=\"top:-2.5198em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mopen mtight\">(</span><span class=\"mord mathnormal mtight\">s</span><span class=\"mpunct mtight\">,</span><span class=\"mord mathnormal mtight\">a</span><span class=\"mclose mtight\">)</span><span class=\"mrel mtight\">∼</span><span class=\"mord mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3448em;\"><span style=\"top:-2.3488em;margin-left:-0.0359em;margin-right:0.0714em;\"><span class=\"pstrut\" style=\"height:2.5em;\"></span><span class=\"sizing reset-size3 size1 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.1512em;\"><span></span></span></span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3552em;\"><span></span></span></span></span></span></span><span class=\"mopen\">[</span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.02778em;\">r</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">ϕ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2861em;\"><span></span></span></span></span></span></span><span class=\"mopen\">(</span><span class=\"mord mathnormal\">s</span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\">a</span><span class=\"mclose\">)]</span></span></span><span style=\"top:-3.2281em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\"></span><span class=\"mord text\"><span class=\"mord\">NashMD: </span></span><span class=\"mspace\"> </span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.6679em;\"><span style=\"top:-2.3479em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span><span class=\"mop\">min</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.7521em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop op-limits\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.4306em;\"><span style=\"top:-2.3479em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">ψ</span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span><span class=\"mop\">max</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.8882em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathbb\">E</span><span class=\"mopen\">[</span><span class=\"mord mathnormal\" style=\"margin-right:0.10903em;\">U</span><span class=\"mopen\">(</span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.02778em;\">θ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span class=\"mpunct\">,</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">π</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\" style=\"margin-right:0.03588em;\">ψ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2861em;\"><span></span></span></span></span></span></span><span class=\"mclose\">)]</span></span></span><span style=\"top:-1.1998em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\"></span><span class=\"mord text\"><span class=\"mord\">PRM: </span></span><span class=\"mspace\"> </span><span class=\"mord text\"><span class=\"mord\">Reward model </span></span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right:0.02778em;\">r</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3361em;\"><span style=\"top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">ϕ</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.2861em;\"><span></span></span></span></span></span></span><span class=\"mord text\"><span class=\"mord\"> updated with preference data</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.4602em;\"><span></span></span></span></span></span></span></span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-7",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Cutting-Edge Variations and Open Research Questions</h2>"
          },
          {
            "id": "review-text-7-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">A runnable trainer needs a model, tokenizer, prompt data and a tested reward function. Small teaching calculations do not reproduce a full training run.</p>"
          },
          {
            "id": "review-text-7-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Record the TRL version and objective settings: current implementations expose variants that differ from the original paper.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[8].actions",
    "before": [
      {
        "id": "action_bT8yOeOQ",
        "type": "speech",
        "text": "Let's test your grasp of GRPO and the TRL implementation with this quiz. Work through each question independently, focusing on the mechanics: group-relative advantage estimation, the clipped surrogate objective, and the KL penalty against the reference policy."
      },
      {
        "id": "action_DijhQRAg",
        "type": "speech",
        "text": "Once you submit your answers, I'll review any difficulties you encountered and clarify the underlying material, particularly where the computational details diverge from the standard PPO formulation."
      }
    ],
    "after": [
      {
        "id": "review-8-0",
        "type": "speech",
        "text": "Check the definitions and calculate a group baseline. A correct answer should refer to completions of the same prompt."
      },
      {
        "id": "review-8-1",
        "type": "speech",
        "text": "Review the explanation after choosing, then try again if your answer relied on the old team analogy."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[8].content.questions",
    "before": [
      {
        "id": "q1",
        "type": "single",
        "question": "In the context of Group Reward Policy Optimization (GRPO), what is the primary implication of aggregating reward signals across a group of agents rather than optimizing each agent's reward independently?",
        "options": [
          {
            "value": "A",
            "label": "It leads to better individual agent performance by focusing on local rewards"
          },
          {
            "value": "B",
            "label": "It encourages cooperative behavior by promoting a shared objective across agents"
          },
          {
            "value": "C",
            "label": "It simplifies the optimization by ignoring correlations among agents"
          },
          {
            "value": "D",
            "label": "It prevents gradient sharing and thus stabilizes learning"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Option B is correct because aggregating reward signals in GRPO encourages cooperation by optimizing a collective objective. Option A is incorrect as it focuses on individual rather than group performance. Option C is false since GRPO explicitly considers correlations among agents through the group reward. Option D is wrong because GRPO involves gradient sharing to coordinate policies.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "multiple",
        "question": "When computing the gradient of the GRPO loss function with respect to the policy parameters, which of the following components must be explicitly considered? (Select all that apply)",
        "options": [
          {
            "value": "A",
            "label": "The Jacobian matrix of the group policy output with respect to parameters"
          },
          {
            "value": "B",
            "label": "The Hessian matrix of the reward function"
          },
          {
            "value": "C",
            "label": "The aggregated group advantage estimates"
          },
          {
            "value": "D",
            "label": "The temporal difference error for individual agents independently"
          }
        ],
        "answer": [
          "A",
          "C"
        ],
        "analysis": "The correct answers are A and C. The Jacobian matrix is essential for backpropagation through group policies in GRPO. Aggregated group advantage estimates provide the necessary signal for policy improvement. The Hessian matrix (option B) is generally not used directly in GRPO gradient computations, and individual temporal difference errors (D) are replaced by group-level signals in GRPO.",
        "points": 20,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "short_answer",
        "question": "Derive the expression for the gradient of the GRPO loss function, assuming a softmax policy parameterization and a group reward signal aggregated as the mean of individual rewards. Discuss how this gradient differs from the traditional PPO gradient.",
        "commentPrompt": "Grading rubric: (1) Correct derivation of GRPO gradient formula - 50% (2) Clear explanation of the role of group reward aggregation - 30% (3) Comparison to PPO gradient highlighting differences in structure and information flow - 20%",
        "analysis": "A reference answer should include the gradient of the expectation of the group reward weighted by the policy probabilities (softmax). The gradient involves the sum over agents of the derivative of the group reward mean times the gradient of policy log-probabilities. Unlike PPO, which uses clipped surrogate objectives with individual advantage estimates, GRPO uses a single aggregated group advantage, affecting gradient variance and coordination.",
        "points": 25,
        "hasAnswer": false
      },
      {
        "id": "q4",
        "type": "single",
        "question": "Which key optimization technique distinguishes PPO from GRPO in terms of policy stability and trust region enforcement?",
        "options": [
          {
            "value": "A",
            "label": "Use of a clipped surrogate objective to constrain policy updates"
          },
          {
            "value": "B",
            "label": "Inclusion of a penalty term for total variation distance between policies"
          },
          {
            "value": "C",
            "label": "A group-level reward discounting factor"
          },
          {
            "value": "D",
            "label": "Explicit hard constraints on policy parameter norms"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "Option A correctly identifies PPO's hallmark: the clipped surrogate objective that limits policy updates to increase stability and approximate a trust region. GRPO typically lacks this clipping mechanism, focusing instead on group reward aggregation. Option B describes TRPO-like penalty but not PPO specifically. Options C and D do not characterize the original PPO algorithm.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "short_answer",
        "question": "Explain the computational challenges when scaling GRPO to large groups of agents and propose algorithmic or implementation strategies that recent 2024-2026 research suggests to mitigate these challenges.",
        "commentPrompt": "Rubric: (1) Identification of challenges such as gradient explosion and communication overhead - 40% (2) Description of solutions like gradient sparsification, decentralized learning, or minibatch group sampling - 40% (3) Clear and coherent presentation of ideas - 20%",
        "analysis": "An ideal response highlights that large groups lead to high-dimensional gradient matrices causing computational bottlenecks and increased communication. Recent research suggests approaches like sparse gradient updates, distributed consensus algorithms, and group-wise minibatch techniques to reduce overhead while maintaining coordination, improving scalability of GRPO.",
        "points": 25,
        "hasAnswer": false
      }
    ],
    "after": [
      {
        "id": "q1",
        "type": "single",
        "question": "In this AI lesson, what does TRL stand for?",
        "options": [
          {
            "value": "A",
            "label": "Transformer Reinforcement Learning"
          },
          {
            "value": "B",
            "label": "Technology Readiness Level"
          },
          {
            "value": "C",
            "label": "Token Ranking List"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "TRL is the Hugging Face library for language-model post-training.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "What is a group in original outcome-supervised GRPO?",
        "options": [
          {
            "value": "A",
            "label": "Independent agents sharing one team reward"
          },
          {
            "value": "B",
            "label": "Several completions sampled for the same prompt"
          },
          {
            "value": "C",
            "label": "A list of task deadlines"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Each sampled completion receives its own reward, compared with rewards for the same prompt.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "Rewards are 0, 1, 1, 2. Which completion is above the mean?",
        "options": [
          {
            "value": "A",
            "label": "The reward 0 completion"
          },
          {
            "value": "B",
            "label": "Both reward 1 completions"
          },
          {
            "value": "C",
            "label": "The reward 2 completion"
          }
        ],
        "answer": [
          "C"
        ],
        "analysis": "The mean is 1, so only reward 2 is above it.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "What happens if all group rewards are equal?",
        "options": [
          {
            "value": "A",
            "label": "Relative reward differences vanish"
          },
          {
            "value": "B",
            "label": "Every completion is necessarily correct"
          },
          {
            "value": "C",
            "label": "The algorithm sorts deadlines"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "Equal rewards provide no within-group ranking signal; implementations handle zero variance numerically.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "What does original GRPO remove relative to standard PPO?",
        "options": [
          {
            "value": "A",
            "label": "All model parameters"
          },
          {
            "value": "B",
            "label": "A separately trained value critic"
          },
          {
            "value": "C",
            "label": "The need to evaluate outputs"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "GRPO uses a group-based baseline instead of a learned value critic; reward evaluation remains necessary.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "reason": "Replace unrelated or incorrect GRPO assessment.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[9].actions",
    "before": [
      {
        "id": "action_vmtC01lg",
        "type": "spotlight",
        "elementId": "text_qUslsKhC"
      },
      {
        "id": "action_iEWruNyX",
        "type": "speech",
        "text": "Let's close by consolidating the key results from today's lecture. This summary should anchor your understanding of group relative policy optimization and where it sits in the modern alignment stack."
      },
      {
        "id": "action_GMw9VTsc",
        "type": "spotlight",
        "elementId": "text_4KDj9Gly"
      },
      {
        "id": "action_sYBvZyBx",
        "type": "speech",
        "text": "First, we examined the TRL alignment pipeline: supervised fine-tuning, reward modeling, and policy optimization, with TRL providing the reference implementations that connect each stage end to end."
      },
      {
        "id": "action_dsRhGteP",
        "type": "spotlight",
        "elementId": "text_4KDj9Gly"
      },
      {
        "id": "action_SwK1xHP5",
        "type": "speech",
        "text": "Second, we derived GRPO's core mechanism: it replaces PPO's learned value function with a group-normalized advantage computed from multiple sampled completions per prompt, cutting memory and stabilizing the policy gradient."
      },
      {
        "id": "action_WprDILUJ",
        "type": "spotlight",
        "elementId": "text_4KDj9Gly"
      },
      {
        "id": "action_VDofCmpN",
        "type": "speech",
        "text": "Third, we covered practical implementation in PyTorch: KL regularization against the frozen reference policy, gradient clipping, and the throughput optimizations that make large-scale RL fine-tuning tractable."
      },
      {
        "id": "action_U83OW62q",
        "type": "spotlight",
        "elementId": "text_4KDj9Gly"
      },
      {
        "id": "action_WBgUpNFQ",
        "type": "speech",
        "text": "Finally, we surveyed open problems through 2024 to 2026, from reward hacking and scalable oversight to the interpretability of policies shaped by group-relative advantages, as seen in the DeepSeekMath and DeepSeek-R1 line of work."
      },
      {
        "id": "action_BIfgyJ0U",
        "type": "speech",
        "text": "Taken together, these results give you both the theoretical grounding and the engineering toolkit to read, reproduce, and extend current reinforcement learning from human feedback research."
      }
    ],
    "after": [
      {
        "id": "review-9-0",
        "type": "speech",
        "text": "The key distinction is relative comparison within one prompt. Reward quality and evaluation on held-out prompts determine whether an improvement is useful."
      },
      {
        "id": "review-9-1",
        "type": "speech",
        "text": "Explore reward hacking, length bias and zero-variance groups in a longer lesson before scaling a training run."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_college.json",
    "path": "scenes[9].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "wvGnIGJNuPEJ4NcMe2_MZ",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_qUslsKhC",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Summary and Key Takeaways</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_elHulnQD",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_XUpxyz7y",
            "type": "shape",
            "left": 60,
            "top": 180,
            "width": 880,
            "height": 260,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#f5f9ff",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_4KDj9Gly",
            "type": "text",
            "left": 80,
            "top": 208,
            "width": 840,
            "height": 232,
            "content": "<p style=\"font-size:18px;\">• TRL alignment pipeline: SFT, reward modeling, RL fine-tuning</p><p style=\"font-size:18px;\">• GRPO core mechanism: group-normalized advantage, no value network, KL-constrained updates</p><p style=\"font-size:18px;\">• Practical implementation: PyTorch, clipping, throughput and memory optimization</p><p style=\"font-size:18px;\">• Open problems (2024–2026): reward hacking, scalable oversight, interpretability</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-9",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Summary and Key Takeaways</h2>"
          },
          {
            "id": "review-text-9-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">The key distinction is relative comparison within one prompt. Reward quality and evaluation on held-out prompts determine whether an improvement is useful.</p>"
          },
          {
            "id": "review-text-9-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Explore reward hacking, length bias and zero-variance groups in a longer lesson before scaling a training run.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[0].actions",
    "before": [
      {
        "id": "action_jkCMVd20",
        "type": "spotlight",
        "elementId": "text_uZ7ZQG4R"
      },
      {
        "id": "action_nKYsMeBm",
        "type": "speech",
        "text": "Hello everyone! Today, we're starting an exciting journey into Transformers Reinforcement Learning, or TRL, and the GRPO algorithm. This course will help us understand how raw language models can be transformed into reasoning agents that align with our goals."
      },
      {
        "id": "action_1XjKriqe",
        "type": "spotlight",
        "elementId": "text_8jPXLP9i"
      },
      {
        "id": "action_Hx1ghY_6",
        "type": "speech",
        "text": "Let's begin with the question: What exactly is TRL? In simple terms, TRL takes large language models and teaches them to think and respond more like agents following specific reasoning steps. This helps make their answers more useful and aligned with what we actually want."
      },
      {
        "id": "action_ftoj45La",
        "type": "spotlight",
        "elementId": "text_8jPXLP9i"
      },
      {
        "id": "action_QFitkvkT",
        "type": "speech",
        "text": "Next, we'll look at the GRPO algorithm, a special method that plays a big role in this process. GRPO helps improve these reasoning agents by using reward signals that come not just from single answers, but groups of different completions. This group feedback is crucial for better learning."
      },
      {
        "id": "action_18SUxuyG",
        "type": "speech",
        "text": "Throughout this course, we'll explore these ideas step by step, learning how these techniques work and even trying some interactive exercises together. My goal is to make these advanced topics clear and approachable for everyone."
      },
      {
        "id": "action_z0jtBEMZ",
        "type": "spotlight",
        "elementId": "text_uZ7ZQG4R"
      },
      {
        "id": "action_C38_yN7d",
        "type": "speech",
        "text": "So to sum up, today we introduced the core ideas of TRL and the GRPO algorithm, and why group-based reward signals matter. Keep these points in mind as we dive deeper in the coming lessons. Let's have fun exploring these cutting-edge techniques!"
      }
    ],
    "after": [
      {
        "id": "review-0-0",
        "type": "speech",
        "text": "TRL is a library for language-model post-training. GRPO means Group Relative Policy Optimization. The group contains alternative completions of one prompt, not a team of agents or a task-priority queue."
      },
      {
        "id": "review-0-1",
        "type": "speech",
        "text": "Follow the same prompt through sampling, reward scoring, comparison, and a policy update."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[0].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "bGXGLypRQyLtco8v1AAtG",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_uZ7ZQG4R",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Introduction to TRL &amp; GRPO</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_R8y4f318",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_8jPXLP9i",
            "type": "text",
            "left": 80,
            "top": 160,
            "width": 840,
            "height": 190,
            "content": "<p style=\"font-size:18px;\">• What is TRL? Turning raw language models into aligned reasoning agents</p><p style=\"font-size:18px;\">• Overview of the GRPO algorithm and its role</p><p style=\"font-size:18px;\">• Why reward signals from groups of completions matter</p><p style=\"font-size:18px;\">• Course goals: Learning interactively, step by step</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-0",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Introduction to TRL &amp; GRPO</h2>"
          },
          {
            "id": "review-text-0-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">TRL is a library for language-model post-training. GRPO means Group Relative Policy Optimization. The group contains alternative completions of one prompt, not a team of agents or a task-priority queue.</p>"
          },
          {
            "id": "review-text-0-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Follow the same prompt through sampling, reward scoring, comparison, and a policy update.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[1].actions",
    "before": [
      {
        "id": "action_sPi1DhBp",
        "type": "spotlight",
        "elementId": "text_TbaQCGDj"
      },
      {
        "id": "action_G_4FlGd0",
        "type": "speech",
        "text": "Welcome everyone! Today, we’re diving into the fascinating world of TRL, specifically the alignment pipeline. This is a step-by-step process that helps AI learn to make better decisions, just like training someone to play a video game."
      },
      {
        "id": "action_Mfgb_Zn4",
        "type": "spotlight",
        "elementId": "text_ptvURJRQ"
      },
      {
        "id": "action_i-nPwT6p",
        "type": "speech",
        "text": "First, we have Phase 1: Supervised Fine-Tuning, or SFT. This is where the AI learns from examples, kind of like studying the game’s rulebook or watching a tutorial to understand the basics."
      },
      {
        "id": "action_TNdR4wu-",
        "type": "spotlight",
        "elementId": "text_78dVO8lE"
      },
      {
        "id": "action_xZIdUtkx",
        "type": "speech",
        "text": "Next is Phase 2: Preference Learning using DPO. Here, the AI learns to choose better responses by comparing options, similar to picking the best move after trying a few different strategies in a game."
      },
      {
        "id": "action_6JUyEseQ",
        "type": "spotlight",
        "elementId": "text_qu59_6Xw"
      },
      {
        "id": "action_IabWjm2Y",
        "type": "speech",
        "text": "Then comes Phase 3: Reinforcement Optimization with GRPO, which is all about improving based on group rewards. Imagine playing with a team where success depends on everyone working together and rewarding great plays."
      },
      {
        "id": "action___Wy3DTy",
        "type": "spotlight",
        "elementId": "text_GsG2bw0T"
      },
      {
        "id": "action_oXCtQWJ9",
        "type": "speech",
        "text": "To tie it all together, think of this pipeline like learning to play video games step-by-step — starting from basics, then figuring out better choices, and finally mastering teamwork for high scores."
      },
      {
        "id": "action_JK-y7R53",
        "type": "speech",
        "text": "So that’s the pathway AI follows in TRL to get smarter and more aligned with what we want. Keep this analogy in mind as we explore more about how AI learns effectively."
      }
    ],
    "after": [
      {
        "id": "review-1-0",
        "type": "speech",
        "text": "Supervised fine-tuning, DPO, and GRPO are different training options supported by TRL. They are not three mandatory stages that every model must follow."
      },
      {
        "id": "review-1-1",
        "type": "speech",
        "text": "Choose training data and the objective for the behavior you can evaluate."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[1].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "ad1BLXNyyh-ldjPDd4Dlg",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_TbaQCGDj",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Understanding TRL: The Alignment Pipeline</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_aqflfjp5",
            "type": "shape",
            "left": 60,
            "top": 140,
            "width": 280,
            "height": 120,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dbeafe",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_ptvURJRQ",
            "type": "text",
            "left": 80,
            "top": 172,
            "width": 240,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Phase 1: Supervised Fine-Tuning (SFT)</p><p style=\"font-size:18px; text-align:center;\">Learning from examples</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "shape_hUZb-xsT",
            "type": "shape",
            "left": 360,
            "top": 140,
            "width": 280,
            "height": 120,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dcfce7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_78dVO8lE",
            "type": "text",
            "left": 380,
            "top": 172,
            "width": 240,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Phase 2: Preference Learning using DPO</p><p style=\"font-size:18px; text-align:center;\">Choosing better outputs</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "shape_344uNfrC",
            "type": "shape",
            "left": 660,
            "top": 140,
            "width": 280,
            "height": 120,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fef3c7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_qu59_6Xw",
            "type": "text",
            "left": 680,
            "top": 172,
            "width": 240,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Phase 3: Reinforcement Optimization with GRPO</p><p style=\"font-size:18px; text-align:center;\">Optimizing with group rewards</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#92400e",
            "rotate": 0
          },
          {
            "id": "shape_dqK_IBv8",
            "type": "shape",
            "left": 60,
            "top": 290,
            "width": 880,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#e0f2fe",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_GsG2bw0T",
            "type": "text",
            "left": 80,
            "top": 322,
            "width": 840,
            "height": 130,
            "content": "<p style=\"font-size:20px; text-align:center;\"><strong>Analogy:</strong> Learning to play video games step-by-step</p><p style=\"font-size:18px; text-align:center;\">• Start by practicing basic moves (SFT)</p><p style=\"font-size:18px; text-align:center;\">• Then choose better strategies to win (DPO)</p><p style=\"font-size:18px; text-align:center;\">• Finally, optimize your play with team rewards (GRPO)</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e293b",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-1",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Understanding TRL: The Alignment Pipeline</h2>"
          },
          {
            "id": "review-text-1-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Supervised fine-tuning, DPO, and GRPO are different training options supported by TRL. They are not three mandatory stages that every model must follow.</p>"
          },
          {
            "id": "review-text-1-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Choose training data and the objective for the behavior you can evaluate.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[2].actions",
    "before": [
      {
        "id": "action_Wk8gy2uR",
        "type": "spotlight",
        "elementId": "text_LeM5kytH"
      },
      {
        "id": "action_yNj0dWFe",
        "type": "speech",
        "text": "Let's explore what changes when we shift our focus from individual reward signals to group reward signals in reinforcement learning."
      },
      {
        "id": "action_wGNHEKPs",
        "type": "spotlight",
        "elementId": "text_n5AkrZYR"
      },
      {
        "id": "action_gB3mAsYW",
        "type": "speech",
        "text": "First, with traditional rewards, feedback is given for single task completions. Think of it like getting a score right after finishing one question."
      },
      {
        "id": "action_t0qH-UVH",
        "type": "laser",
        "elementId": "text_n5AkrZYR"
      },
      {
        "id": "action_5hlwPkzM",
        "type": "speech",
        "text": "Now, group reward signals work differently — they provide feedback based on a whole set or group of completions, rather than just one."
      },
      {
        "id": "action_idoOK7o_",
        "type": "spotlight",
        "elementId": "text_n5AkrZYR"
      },
      {
        "id": "action_xy5RGqPA",
        "type": "speech",
        "text": "This group feedback can help algorithms align better with desired outcomes because it considers how actions perform collectively."
      },
      {
        "id": "action_u4DY2Nqa",
        "type": "speech",
        "text": "A simple way to imagine this is how social media works: likes on a group post versus likes on individual comments — the group post’s feedback reflects overall approval."
      },
      {
        "id": "action_dMdN4yUX",
        "type": "speech",
        "text": "Understanding this difference helps us see how reinforcement learning can be designed to learn more effectively from broader feedback signals."
      }
    ],
    "after": [
      {
        "id": "review-2-0",
        "type": "speech",
        "text": "Sample several completions from the old policy for the same prompt. Score each completion separately. Compare its reward with that group mean."
      },
      {
        "id": "review-2-1",
        "type": "speech",
        "text": "In original outcome-supervised GRPO, the centered reward is divided by the group standard deviation to produce a relative advantage."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[2].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "f4vakLld_wt0CqyyeNK9M",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_LeM5kytH",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px; font-weight:bold; color:#1e40af;\">What Changes with Group Reward Signals?</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_9SENUR1z",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#1e40af",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_n5AkrZYR",
            "type": "text",
            "left": 60,
            "top": 150,
            "width": 880,
            "height": 130,
            "content": "<p style=\"font-size:18px; color:#333333;\">• Traditional reward: feedback per single completion</p><p style=\"font-size:18px; color:#333333;\">• Group reward: feedback based on sets of completions</p><p style=\"font-size:18px; color:#333333;\">• Group feedback can improve alignment and learning</p><p style=\"font-size:18px; color:#333333;\">• Like social media: group posts vs individual comments</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-2",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>What Changes with Group Reward Signals?</h2>"
          },
          {
            "id": "review-text-2-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Sample several completions from the old policy for the same prompt. Score each completion separately. Compare its reward with that group mean.</p>"
          },
          {
            "id": "review-text-2-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">In original outcome-supervised GRPO, the centered reward is divided by the group standard deviation to produce a relative advantage.</p>"
          },
          {
            "id": "review-math-2",
            "type": "text",
            "left": 50,
            "top": 460,
            "width": 900,
            "height": 85,
            "content": "<p style=\"font-size:20px\">Aᵢ = (rᵢ − mean(r)) / (std(r) + ε)</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[3].actions",
    "before": [
      {
        "id": "action_3LQZINxl",
        "type": "speech",
        "text": "Let's dive into how rewards influence learning when working alone versus in groups using this simulation."
      },
      {
        "id": "action_6ZL917VC",
        "type": "widget_highlight",
        "target": "#groupSize-slider",
        "content": "Start by adjusting the group size slider to see how the number of people affects reward distribution."
      },
      {
        "id": "action_bK0-FBtN",
        "type": "widget_highlight",
        "target": "#rewardStrength-slider",
        "content": "Next, change the reward strength and observe how it impacts individual and group learning progress."
      },
      {
        "id": "action_QaKx68LM",
        "type": "speech",
        "text": "Try using the preset buttons to quickly switch between typical group sizes and reward settings to compare their effects."
      },
      {
        "id": "action_i9DXWLz-",
        "type": "widget_annotation",
        "target": "#indiv-progress",
        "content": "Watch this indicator for individual learning progress."
      },
      {
        "id": "action_qDzBCPUM",
        "type": "widget_annotation",
        "target": "#group-progress",
        "content": "And this one shows how well the group learns together."
      },
      {
        "id": "action_IawIgSJe",
        "type": "speech",
        "text": "Explore how changing group size and reward strength shapes the balance between solo and group behavior. What patterns do you notice?"
      }
    ],
    "after": [
      {
        "id": "review-3-0",
        "type": "speech",
        "text": "For rewards zero, one, one, and two, the mean is one. The population standard deviation is the square root of one half. The advantages are approximately minus1.414, zero, zero, and1.414."
      },
      {
        "id": "review-3-1",
        "type": "speech",
        "text": "If rewards are identical, there is no relative ranking signal. A numerical epsilon avoids division by zero; trainer variants differ."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[3].type",
    "before": "interactive",
    "after": "slide",
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[3].content",
    "before": {
      "type": "interactive",
      "url": "",
      "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\" />\n<title>Group Reward Optimization Simulation</title>\n<style>\n  /* Reset and base */\n  html, body {\n    margin: 0; padding: 0; height: 100%; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n    background: #121212; color: #eee;\n    -webkit-tap-highlight-color: transparent;\n  }\n  body {\n    display: flex; flex-direction: column; min-height: 100vh;\n  }\n  /* Layout */\n  #app {\n    flex: 1; display: flex; flex-direction: column;\n  }\n  @media(min-width: 768px) {\n    #app { flex-direction: row; }\n  }\n  /* Controls panel */\n  #controls {\n    background: #1e1e1e;\n    padding: 1rem 1.25rem 1rem 1.25rem;\n    box-sizing: border-box;\n    max-height: 40vh; /* mobile limit */\n    overflow-y: auto;\n    width: 100%;\n    border-bottom: 1px solid #3a3a3a;\n  }\n  @media(min-width: 768px) {\n    #controls {\n      max-height: 100vh;\n      width: 280px;\n      border-bottom: none;\n      border-right: 1px solid #3a3a3a;\n      overflow-y: auto;\n    }\n  }\n  #controls h2 {\n    margin: 0 0 1rem 0;\n    font-weight: 700;\n    font-size: 1.4rem;\n    color: #8b5cf6;\n    user-select: none;\n  }\n  /* Slider labels and containers */\n  .control-group {\n    margin-bottom: 1.25rem;\n  }\n  label {\n    display: block;\n    margin-bottom: 0.3rem;\n    font-weight: 600;\n    font-size: 1rem;\n    cursor: pointer;\n  }\n  input[type=range] {\n    appearance: none;\n    width: 100%;\n    height: 24px;\n    background: #333;\n    border-radius: 12px;\n    outline: none;\n    touch-action: manipulation;\n  }\n  input[type=range]::-webkit-slider-thumb {\n    appearance: none;\n    width: 28px; height: 28px;\n    background: #8b5cf6;\n    border-radius: 50%;\n    cursor: pointer;\n    box-shadow: 0 0 8px rgba(139,92,246,0.85);\n    border: 1px solid #651fff;\n    margin-top: -2px;\n    touch-action: manipulation;\n  }\n  input[type=range]::-moz-range-thumb {\n    width: 28px; height: 28px;\n    background: #8b5cf6;\n    border-radius: 50%;\n    cursor: pointer;\n    box-shadow: 0 0 8px rgba(139,92,246,0.85);\n    border: 1px solid #651fff;\n    touch-action: manipulation;\n  }\n  /* Variable display */\n  .value-display {\n    font-family: monospace;\n    margin-top: 0.25rem;\n    font-weight: 700;\n    font-size: 1.05rem;\n    color: #d1c4e9;\n    user-select: none;\n  }\n  /* Preset buttons */\n  #preset-buttons {\n    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 1rem;\n  }\n  button.preset-btn {\n    flex: 1 1 auto;\n    background: #4b35a2;\n    border: none;\n    border-radius: 8px;\n    color: white;\n    font-weight: 700;\n    font-size: 0.9rem;\n    padding: 0.45rem 0.6rem;\n    cursor: pointer;\n    touch-action: manipulation;\n    min-height: 44px;\n    box-shadow: 0 0 5px rgba(139,92,246,0.7);\n    transition: background-color 0.3s ease;\n  }\n  button.preset-btn:hover, button.preset-btn:focus {\n    background: #8b5cf6;\n    outline: none;\n  }\n  /* Main action button */\n  #mainBtn {\n    width: 100%;\n    background: #8b5cf6;\n    border: none;\n    border-radius: 12px;\n    color: white;\n    font-weight: 800;\n    font-size: 1.3rem;\n    padding: 0.6rem 0;\n    cursor: pointer;\n    user-select: none;\n    min-height: 48px;\n    box-shadow: 0 0 15px rgba(139, 92, 246, 0.9);\n    transition:\n      background-color 0.3s ease,\n      box-shadow 0.3s ease;\n    touch-action: manipulation;\n  }\n  #mainBtn:active {\n    background-color: #651fff;\n    box-shadow: 0 0 20px rgba(101, 31, 255, 1);\n  }\n  #mainBtn[disabled] {\n    background-color: #444;\n    box-shadow: none;\n    cursor: not-allowed;\n  }\n  /* Canvas container */\n  #canvas-container {\n    flex: 1 1 auto;\n    background: #181818;\n    position: relative;\n    min-height: 300px;\n    overflow: hidden;\n  }\n  canvas {\n    display: block;\n    width: 100%;\n    height: 100%;\n    touch-action: none;\n  }\n  /* HUD overlay on canvas */\n  #hud {\n    position: absolute;\n    top: 12px;\n    left: 12px;\n    right: 12px;\n    color: #ddd;\n    font-family: monospace, monospace;\n    font-size: 0.95rem;\n    pointer-events: none;\n    user-select: none;\n    background: rgba(0,0,0,0.4);\n    border-radius: 8px;\n    padding: 6px 10px;\n    line-height: 1.3;\n    max-width: 380px;\n  }\n  /* Running status indicator */\n  #statusIndicator {\n    position: absolute;\n    top: 12px;\n    right: 12px;\n    width: 18px; height: 18px;\n    border-radius: 50%;\n    background-color: #8b5cf6;\n    box-shadow: 0 0 10px #8b5cf6;\n    pointer-events: none;\n  }\n  #statusIndicator.paused {\n    background-color: #f59e0b;\n    box-shadow: 0 0 10px #f59e0b;\n  }\n  #statusIndicator.ended {\n    background-color: #ef4444;\n    box-shadow: 0 0 10px #ef4444;\n  }\n  /* Tooltip annotation (from postMessage) */\n  .teacher-annotation {\n    user-select: none;\n    font-size: 14px;\n    font-weight: 600;\n    pointer-events: none;\n  }\n  /* Animations */\n  @keyframes pulse-highlight {\n    0%, 100% { outline-color: rgba(139, 92, 246, 0.8); }\n    50% { outline-color: rgba(139, 92, 246, 0.4); }\n  }\n  @keyframes fadeIn {\n    from { opacity: 0; transform: translateY(10px); }\n    to { opacity: 1; transform: translateY(0); }\n  }\n  /* Scrollbar style for controls panel overflow */\n  #controls::-webkit-scrollbar {\n    width: 8px;\n  }\n  #controls::-webkit-scrollbar-thumb {\n    background-color: #651fff88;\n    border-radius: 4px;\n  }\n  /* Accessibility focus */\n  button:focus-visible, input[type=range]:focus-visible {\n    outline: 2px solid #8b5cf6;\n    outline-offset: 3px;\n  }\n  /* Touch target minimum sizes */\n  label {\n    min-height: 24px;\n  }\n</style>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<div id=\"app\">\n  <section id=\"controls\" aria-label=\"Simulation Controls\">\n    <h2 tabindex=\"0\">Group Reward Optimization</h2>\n    <div id=\"preset-buttons\" role=\"group\" aria-label=\"Presets\">\n      <button type=\"button\" class=\"preset-btn\" id=\"preset-hit-btn\" aria-pressed=\"false\">Typical group (5 people)</button>\n      <button type=\"button\" class=\"preset-btn\" id=\"preset-small-btn\" aria-pressed=\"false\">Small group (2 people)</button>\n      <button type=\"button\" class=\"preset-btn\" id=\"preset-large-btn\" aria-pressed=\"false\">Large group (15 people)</button>\n      <button type=\"button\" class=\"preset-btn\" id=\"preset-strong-btn\" aria-pressed=\"false\">Strong rewards</button>\n    </div>\n    <div class=\"control-group\">\n      <label for=\"groupSize-slider\">Group Size <span aria-live=\"polite\" aria-atomic=\"true\" id=\"groupSize-display\">5</span> people</label>\n      <input type=\"range\" min=\"1\" max=\"20\" step=\"1\" value=\"5\" id=\"groupSize-slider\" aria-valuemin=\"1\" aria-valuemax=\"20\" aria-valuenow=\"5\" aria-label=\"Group size slider\">\n    </div>\n    <div class=\"control-group\">\n      <label for=\"rewardStrength-slider\">Reward Strength <span aria-live=\"polite\" aria-atomic=\"true\" id=\"rewardStrength-display\">0.50</span></label>\n      <input type=\"range\" min=\"0\" max=\"1\" step=\"0.01\" value=\"0.5\" id=\"rewardStrength-slider\" aria-valuemin=\"0\" aria-valuemax=\"1\" aria-valuenow=\"0.5\" aria-label=\"Reward strength slider\">\n    </div>\n    <button id=\"mainBtn\" type=\"button\" aria-live=\"polite\" aria-label=\"Start simulation\">启动</button>\n    <p style=\"margin-top:1rem; font-size:0.9rem; color:#999; line-height:1.4;\">\n      Adjust the group size and reward strength.<br>\n      Click \"启动\" to start the simulation, \"暂停\" to pause, \"重新开始\" to reset.<br>\n      Watch how individuals and groups learn differently based on the reward signals!<br>\n      Keyboard shortcuts: Space = toggle start/pause, R = reset.\n    </p>\n  </section>\n\n  <section id=\"canvas-container\" aria-label=\"Simulation Visualization\">\n    <canvas id=\"canvas\" role=\"img\" aria-describedby=\"description\" aria-live=\"polite\"></canvas>\n    <div id=\"hud\" aria-hidden=\"true\">\n      <div><strong>Time:</strong> <span id=\"time-display\">0.00</span> s</div>\n      <div><strong>Group Size:</strong> <span id=\"hud-groupSize\">5</span></div>\n      <div><strong>Reward Strength:</strong> <span id=\"hud-rewardStrength\">0.50</span></div>\n      <div><strong>Individual Learning:</strong> <span id=\"indiv-progress\">0%</span></div>\n      <div><strong>Group Learning:</strong> <span id=\"group-progress\">0%</span></div>\n      <div><strong>Status:</strong> <span id=\"simulation-status\">Idle</span></div>\n    </div>\n    <div id=\"statusIndicator\" aria-hidden=\"true\" class=\"ended\"></div>\n  </section>\n</div>\n\n<script type=\"application/json\" id=\"widget-config\">\n{\n  \"type\": \"simulation\",\n  \"concept\": \"group_reward_optimization\",\n  \"description\": \"This simulation shows how reward signals affect learning progress differently when working alone versus in groups. Adjust the group size and reward strength to see how individual and group behavior changes.\",\n  \"variables\": [\n    { \"name\": \"groupSize\", \"label\": \"Group Size\", \"min\": 1, \"max\": 20, \"default\": 5, \"unit\": \"people\" },\n    { \"name\": \"rewardStrength\", \"label\": \"Reward Strength\", \"min\": 0, \"max\": 1, \"default\": 0.5, \"unit\": \"\" }\n  ],\n  \"presets\": [\n    { \"name\": \"Typical group (5 people)\", \"variables\": { \"groupSize\": 5, \"rewardStrength\": 0.5 } },\n    { \"name\": \"Small group (2 people)\", \"variables\": { \"groupSize\": 2, \"rewardStrength\": 0.5 } },\n    { \"name\": \"Large group (15 people)\", \"variables\": { \"groupSize\": 15, \"rewardStrength\": 0.3 } },\n    { \"name\": \"Strong rewards\", \"variables\": { \"groupSize\": 5, \"rewardStrength\": 0.9 } }\n  ]\n}\n</script>\n\n<script>\n(() => {\n  // Retrieve config from embedded JSON\n  const configJSON = document.getElementById('widget-config').textContent.trim();\n  const config = JSON.parse(configJSON);\n\n  // State variables\n  const state = {\n    running: false,\n    ended: false,\n    paused: false,\n    time: 0,\n    lastTimestamp: null,\n    groupSize: config.variables.find(v => v.name === 'groupSize').default,\n    rewardStrength: config.variables.find(v => v.name === 'rewardStrength').default,\n    indivProgress: 0,\n    groupProgress: 0,\n    maxTime: 30, // Run simulation max 30 seconds to show difference\n  };\n\n  // Animation frame id\n  let animationId = null;\n\n  // DOM elements\n  const groupSizeSlider = document.getElementById('groupSize-slider');\n  const rewardStrengthSlider = document.getElementById('rewardStrength-slider');\n  const groupSizeDisplay = document.getElementById('groupSize-display');\n  const rewardStrengthDisplay = document.getElementById('rewardStrength-display');\n  const mainBtn = document.getElementById('mainBtn');\n  const canvas = document.getElementById('canvas');\n  const hud = {\n    timeDisplay: document.getElementById('time-display'),\n    hudGroupSize: document.getElementById('hud-groupSize'),\n    hudRewardStrength: document.getElementById('hud-rewardStrength'),\n    indivProgress: document.getElementById('indiv-progress'),\n    groupProgress: document.getElementById('group-progress'),\n    simulationStatus: document.getElementById('simulation-status'),\n  };\n  const statusIndicator = document.getElementById('statusIndicator');\n\n  // Canvas context\n  const ctx = canvas.getContext('2d');\n\n  // For mobile minimum touch targets\n  function setAccessibilityAttributes() {\n    const sliders = [groupSizeSlider, rewardStrengthSlider];\n    sliders.forEach(slider => {\n      slider.style.touchAction = 'manipulation';\n      slider.setAttribute('tabindex', '0');\n    });\n    mainBtn.style.touchAction = 'manipulation';\n  }\n\n  // Update display values for sliders\n  function updateSliderDisplays() {\n    groupSizeDisplay.textContent = state.groupSize;\n    groupSizeSlider.setAttribute('aria-valuenow', state.groupSize);\n    rewardStrengthDisplay.textContent = state.rewardStrength.toFixed(2);\n    rewardStrengthSlider.setAttribute('aria-valuenow', state.rewardStrength.toFixed(2));\n    // HUD mirrors\n    hud.hudGroupSize.textContent = state.groupSize;\n    hud.hudRewardStrength.textContent = state.rewardStrength.toFixed(2);\n  }\n\n  // Reset simulation state to initial\n  function resetSimulation() {\n    state.running = false;\n    state.paused = false;\n    state.ended = false;\n    state.time = 0;\n    state.lastTimestamp = null;\n    state.indivProgress = 0;\n    state.groupProgress = 0;\n    updateButton('启动');\n    updateHUDStatus('Idle');\n    updateSliderDisplays();\n    draw();\n  }\n\n  // Start simulation\n  function startSimulation() {\n    if (state.ended) {\n      resetSimulation();\n    }\n    state.running = true;\n    state.paused = false;\n    state.ended = false;\n    state.lastTimestamp = null;\n    updateButton('暂停');\n    updateHUDStatus('Running');\n    statusIndicator.className = '';\n    statusIndicator.classList.add('running');\n    animationId = requestAnimationFrame(loop);\n  }\n\n  // Pause simulation\n  function pauseSimulation() {\n    state.paused = true;\n    state.running = false;\n    updateButton('继续');\n    updateHUDStatus('Paused');\n    statusIndicator.className = '';\n    statusIndicator.classList.add('paused');\n    cancelAnimationFrame(animationId);\n  }\n\n  // Resume simulation from pause\n  function resumeSimulation() {\n    state.paused = false;\n    state.running = true;\n    updateButton('暂停');\n    updateHUDStatus('Running');\n    statusIndicator.className = '';\n    statusIndicator.classList.add('running');\n    state.lastTimestamp = null;\n    animationId = requestAnimationFrame(loop);\n  }\n\n  // Simulation ended\n  function endSimulation() {\n    state.running = false;\n    state.ended = true;\n    state.paused = false;\n    updateButton('重新开始');\n    updateHUDStatus('Finished!');\n    statusIndicator.className = '';\n    statusIndicator.classList.add('ended');\n    cancelAnimationFrame(animationId);\n  }\n\n  // Update main button text and aria-label\n  function updateButton(text) {\n    mainBtn.textContent = text;\n    let label = 'Start simulation';\n    if (text === '启动') label = 'Start simulation';\n    else if (text === '暂停') label = 'Pause simulation';\n    else if (text === '继续') label = 'Resume simulation';\n    else if (text === '重新开始') label = 'Reset simulation';\n    mainBtn.setAttribute('aria-label', label);\n  }\n\n  // Update HUD status text\n  function updateHUDStatus(text) {\n    hud.simulationStatus.textContent = text;\n  }\n\n  // Resize canvas to container size\n  function resizeCanvas() {\n    const container = canvas.parentElement;\n    const rect = container.getBoundingClientRect();\n    // For high DPI screens:\n    const dpr = window.devicePixelRatio || 1;\n    canvas.width = rect.width * dpr;\n    canvas.height = rect.height * dpr;\n    canvas.style.width = rect.width + 'px';\n    canvas.style.height = rect.height + 'px';\n    ctx.setTransform(1,0,0,1,0,0); // Reset transforms\n    ctx.scale(dpr, dpr);\n    draw();\n  }\n\n  // Draw grid background\n  function drawGrid() {\n    const w = canvas.width / (window.devicePixelRatio || 1);\n    const h = canvas.height / (window.devicePixelRatio || 1);\n    const step = 40;\n    ctx.strokeStyle = '#333';\n    ctx.lineWidth = 1;\n    ctx.beginPath();\n    for (let x = 0; x <= w; x += step) {\n      ctx.moveTo(x, 0);\n      ctx.lineTo(x, h);\n    }\n    for (let y = 0; y <= h; y += step) {\n      ctx.moveTo(0, y);\n      ctx.lineTo(w, y);\n    }\n    ctx.stroke();\n  }\n\n  // Draw the simulation visualization\n  // We show two learning progress curves: Individual and Group\n  // Individual curve: learns steadily based on reward strength\n  // Group curve: learning progress enhanced or diminished by group size and reward strength\n  // Animate small circles traveling on curves with numeric progress also displayed\n  function draw() {\n    const w = canvas.width / (window.devicePixelRatio || 1);\n    const h = canvas.height / (window.devicePixelRatio || 1);\n    ctx.clearRect(0, 0, w, h);\n    drawGrid();\n\n    const padding = 60;\n    const graphWidth = w - 2 * padding;\n    const graphHeight = h - 2 * padding;\n\n    // Axes\n    ctx.strokeStyle = '#8b5cf6';\n    ctx.lineWidth = 2;\n    ctx.beginPath();\n    // X-axis\n    ctx.moveTo(padding, h - padding);\n    ctx.lineTo(w - padding, h - padding);\n    // Y-axis\n    ctx.lineTo(padding, padding);\n    ctx.stroke();\n    // Axes labels\n    ctx.fillStyle = '#d1c4e9';\n    ctx.font = '14px monospace';\n    ctx.fillText('Time (sec)', w / 2 - 28, h - padding + 40);\n    ctx.save();\n    ctx.translate(padding - 40, h/2 + 20);\n    ctx.rotate(-Math.PI/2);\n    ctx.fillText('Learning Progress', 0, 0);\n    ctx.restore();\n\n    // Draw progress curves background (for reference)\n    ctx.lineWidth = 3;\n    // Individual curve - solid purple\n    ctx.strokeStyle = '#a78bfa';\n    ctx.beginPath();\n    // Simple sigmoid curve (starts slow, then steep progress)\n    for (let i = 0; i <= graphWidth; i++) {\n      const tNorm = i / graphWidth;\n      // Individual learning is proportional to rewardStrength * sigmoid(t)\n      const y = sigmoid(tNorm*state.maxTime) * state.rewardStrength;\n      const yPix = h - padding - y * graphHeight;\n      if (i === 0) ctx.moveTo(padding + i, yPix);\n      else ctx.lineTo(padding + i, yPix);\n    }\n    ctx.stroke();\n\n    // Group curve - dashed cyan\n    ctx.strokeStyle = '#22d3ee';\n    ctx.setLineDash([8,6]);\n    ctx.lineWidth = 3;\n    ctx.beginPath();\n    // Group learning influenced by groupSize, max benefit ~ sqrt(groupSize)\n    for (let i = 0; i <= graphWidth; i++) {\n      const tNorm = i / graphWidth;\n      // Group effect: progress scaled by reward * sqrt(groupSize) / (1 + 0.1*groupSize)\n      // For demonstration, assume diminishing returns at larger group sizes\n      const groupFactor = (Math.sqrt(state.groupSize)) / (1 + 0.1 * state.groupSize);\n      const y = sigmoid(tNorm*state.maxTime) * state.rewardStrength * groupFactor;\n      const yPix = h - padding - y * graphHeight;\n      if (i === 0) ctx.moveTo(padding + i, yPix);\n      else ctx.lineTo(padding + i, yPix);\n    }\n    ctx.stroke();\n    ctx.setLineDash([]);\n\n    // Animate the progress dots for current time\n    const tNorm = state.time / state.maxTime;\n    if (tNorm > 1) return; // Already ended\n\n    // Individual dot position\n    const indivY = sigmoid(state.time) * state.rewardStrength;\n    const indivX = padding + tNorm * graphWidth;\n    const indivYPix = h - padding - indivY * graphHeight;\n\n    // Group dot position\n    const groupFactor = (Math.sqrt(state.groupSize)) / (1 + 0.1 * state.groupSize);\n    const groupY = sigmoid(state.time) * state.rewardStrength * groupFactor;\n    const groupX = padding + tNorm * graphWidth;\n    const groupYPix = h - padding - groupY * graphHeight;\n\n    // Draw individual progress dot (purple)\n    ctx.fillStyle = '#a78bfa';\n    ctx.beginPath();\n    ctx.shadowColor = \"rgba(167,139,250,0.7)\";\n    ctx.shadowBlur = 14;\n    ctx.shadowOffsetX = 0;\n    ctx.shadowOffsetY = 0;\n    ctx.arc(indivX, indivYPix, 12, 0, 2 * Math.PI);\n    ctx.fill();\n    ctx.shadowBlur = 0;\n\n    // Draw group progress dot (cyan)\n    ctx.fillStyle = '#22d3ee';\n    ctx.beginPath();\n    ctx.shadowColor = \"rgba(34,211,238,0.7)\";\n    ctx.shadowBlur = 14;\n    ctx.arc(groupX, groupYPix, 12, 0, 2*Math.PI);\n    ctx.fill();\n    ctx.shadowBlur = 0;\n\n    // Draw labels near dots\n    ctx.fillStyle = '#eee';\n    ctx.font = 'bold 13px monospace';\n    ctx.textAlign = 'center';\n    ctx.fillText('Individual', indivX, indivYPix - 20);\n    ctx.fillText((indivY*100).toFixed(1) + '%', indivX, indivYPix + 28);\n\n    ctx.fillText('Group', groupX, groupYPix - 20);\n    ctx.fillText((groupY*100).toFixed(1) + '%', groupX, groupYPix + 28);\n\n    // Update progress state for HUD\n    state.indivProgress = Math.min(1, indivY);\n    state.groupProgress = Math.min(1, groupY);\n  }\n\n  // Sigmoid function for smooth learning curve approximation\n  // Shifted/scaled to maxTime where it asymptotes near 1\n  function sigmoid(t) {\n    // We want sigmoid(0) ~ 0, sigmoid(maxTime) ~ 1\n    // Use logistic: L = 1, k = 0.35, x0 = maxTime/2\n    // Adjust for nicer curve\n    const L = 1;\n    const k = 0.35;\n    const x0 = state.maxTime / 2;\n    return L / (1 + Math.exp(-k*(t - x0)));\n  }\n\n  // Simulation loop with animation\n  function loop(timestamp) {\n    if (!state.lastTimestamp) state.lastTimestamp = timestamp;\n    const delta = (timestamp - state.lastTimestamp) / 1000;\n    state.lastTimestamp = timestamp;\n\n    if (state.running && !state.paused && !state.ended) {\n      state.time += delta;\n      if (state.time >= state.maxTime) {\n        state.time = state.maxTime;\n        endSimulation();\n      }\n      updateHUD();\n      draw();\n    }\n    animationId = requestAnimationFrame(loop);\n  }\n\n  // Update HUD with current stats\n  function updateHUD() {\n    hud.timeDisplay.textContent = state.time.toFixed(2);\n    hud.indivProgress.textContent = (state.indivProgress * 100).toFixed(1) + '%';\n    hud.groupProgress.textContent = (state.groupProgress * 100).toFixed(1) + '%';\n  }\n\n  // Slider event handlers\n  function onGroupSizeChange(e) {\n    const val = parseInt(e.target.value);\n    state.groupSize = val;\n    updateSliderDisplays();\n    if (!state.running) draw();\n  }\n  function onRewardStrengthChange(e) {\n    const val = parseFloat(e.target.value);\n    state.rewardStrength = val;\n    updateSliderDisplays();\n    if (!state.running) draw();\n  }\n  // Main button click handler\n  function onMainButtonClick() {\n    if (state.ended) {\n      // Reset then start fresh\n      resetSimulation();\n      startSimulation();\n    } else if (state.running) {\n      pauseSimulation();\n    } else if (state.paused) {\n      resumeSimulation();\n    } else {\n      startSimulation();\n    }\n  }\n\n  // Handle preset buttons\n  function applyPreset(preset) {\n    Object.entries(preset.variables).forEach(([key, val]) => {\n      const slider = document.getElementById(key + '-slider');\n      if (slider) {\n        slider.value = val;\n        slider.dispatchEvent(new Event('input', { bubbles: true })); // Trigger change events\n      }\n    });\n    resetSimulation();\n  }\n\n  // Keyboard shortcuts\n  function onKeyDown(e) {\n    if (document.activeElement && ['INPUT', 'TEXTAREA', 'SELECT'].includes(document.activeElement.tagName)) return;\n    if (e.code === 'Space') {\n      e.preventDefault();\n      mainBtn.click();\n    } else if (e.code === 'KeyR') {\n      e.preventDefault();\n      resetSimulation();\n    }\n  }\n\n  // Preset buttons setup\n  const presetButtons = [\n    {\n      element: document.getElementById('preset-hit-btn'),\n      preset: config.presets[0],\n    },\n    {\n      element: document.getElementById('preset-small-btn'),\n      preset: config.presets[1],\n    },\n    {\n      element: document.getElementById('preset-large-btn'),\n      preset: config.presets[2],\n    },\n    {\n      element: document.getElementById('preset-strong-btn'),\n      preset: config.presets[3],\n    }\n  ];\n  presetButtons.forEach(({element, preset}) => {\n    element.addEventListener('click', () => {\n      applyPreset(preset);\n    });\n  });\n\n  // Update ARIA pressed states on presets\n  function updatePresetAria(selectedIndex) {\n    presetButtons.forEach((btn, i) => {\n      btn.element.setAttribute('aria-pressed', i === selectedIndex ? 'true' : 'false');\n    });\n  }\n\n  // Initial setup\n  function init() {\n    setAccessibilityAttributes();\n    updateSliderDisplays();\n    updateHUD();\n    draw();\n\n    groupSizeSlider.addEventListener('input', onGroupSizeChange);\n    rewardStrengthSlider.addEventListener('input', onRewardStrengthChange);\n\n    mainBtn.addEventListener('click', onMainButtonClick);\n\n    window.addEventListener('keydown', onKeyDown);\n\n    // Responsive canvas resizing\n    window.addEventListener('resize', resizeCanvas);\n    // Initial resize\n    resizeCanvas();\n  }\n\n  // Start app\n  init();\n\n  // For external postMessage control - required by prompt\n  window.addEventListener('message', function(event) {\n    const { type, target, state: newState, content } = event.data || {};\n    switch(type) {\n      case 'SET_WIDGET_STATE':\n        if (newState) {\n          Object.entries(newState).forEach(([key, value]) => {\n            const slider = document.getElementById(key + '-slider') || document.querySelector('[data-var=\"' + key + '\"]');\n            if (slider) {\n              slider.value = value;\n              slider.dispatchEvent(new Event('input', { bubbles: true }));\n            }\n            // Also update internal state directly if no slider (not needed here)\n          });\n        }\n        break;\n      case 'HIGHLIGHT_ELEMENT':\n        const highlightEl = document.querySelector(target);\n        if (highlightEl) {\n          highlightEl.style.outline = '3px solid rgba(139, 92, 246, 0.8)';\n          highlightEl.style.outlineOffset = '4px';\n          highlightEl.style.animation = 'pulse-highlight 2s infinite';\n          setTimeout(() => {\n            if (highlightEl) {\n              highlightEl.style.outline = '';\n              highlightEl.style.animation = '';\n            }\n          }, 3000);\n        }\n        break;\n      case 'ANNOTATE_ELEMENT':\n        const annotateEl = document.querySelector(target);\n        if (annotateEl && content) {\n          const rect = annotateEl.getBoundingClientRect();\n          const tooltip = document.createElement('div');\n          tooltip.className = 'teacher-annotation';\n          tooltip.style.cssText = 'position:fixed; top:' + (rect.top - 40) + 'px; left:' + rect.left + 'px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;';\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n        break;\n      case 'REVEAL_ELEMENT':\n        const revealEl = document.querySelector(target);\n        if (revealEl) {\n          revealEl.style.display = '';\n          revealEl.style.opacity = '1';\n        }\n        break;\n    }\n  });\n  // Add CSS for animations used by postMessage\n  const style = document.createElement('style');\n  style.textContent = '@keyframes pulse-highlight { 0%, 100% { outline-color: rgba(139, 92, 246, 0.8); } 50% { outline-color: rgba(139, 92, 246, 0.4); } } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }';\n  document.head.appendChild(style);\n})();\n</script>\n</body>\n</html>",
      "widgetType": "simulation",
      "widgetConfig": {
        "type": "simulation",
        "concept": "group_reward_optimization",
        "description": "This simulation shows how reward signals affect learning progress differently when working alone versus in groups. Adjust the group size and reward strength to see how individual and group behavior changes.",
        "variables": [
          {
            "name": "groupSize",
            "label": "Group Size",
            "min": 1,
            "max": 20,
            "default": 5,
            "unit": "people"
          },
          {
            "name": "rewardStrength",
            "label": "Reward Strength",
            "min": 0,
            "max": 1,
            "default": 0.5,
            "unit": ""
          }
        ],
        "presets": [
          {
            "name": "Typical group (5 people)",
            "variables": {
              "groupSize": 5,
              "rewardStrength": 0.5
            }
          },
          {
            "name": "Small group (2 people)",
            "variables": {
              "groupSize": 2,
              "rewardStrength": 0.5
            }
          },
          {
            "name": "Large group (15 people)",
            "variables": {
              "groupSize": 15,
              "rewardStrength": 0.3
            }
          },
          {
            "name": "Strong rewards",
            "variables": {
              "groupSize": 5,
              "rewardStrength": 0.9
            }
          }
        ]
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-3",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Simulating Group Reward Effects</h2>"
          },
          {
            "id": "review-text-3-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">For rewards zero, one, one, and two, the mean is one. The population standard deviation is the square root of one half. The advantages are approximately minus1.414, zero, zero, and1.414.</p>"
          },
          {
            "id": "review-text-3-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">If rewards are identical, there is no relative ranking signal. A numerical epsilon avoids division by zero; trainer variants differ.</p>"
          },
          {
            "id": "review-math-3",
            "type": "text",
            "left": 50,
            "top": 460,
            "width": 900,
            "height": 85,
            "content": "<p style=\"font-size:20px\">Aᵢ = (rᵢ − mean(r)) / (std(r) + ε)</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[4].actions",
    "before": [
      {
        "id": "action_zlecK76B",
        "type": "spotlight",
        "elementId": "text_x608xQw4"
      },
      {
        "id": "action_QQuQjx7b",
        "type": "speech",
        "text": "Let's begin by exploring the core components of the GRPO algorithm. This will give us a clear roadmap of what we'll cover in this lesson."
      },
      {
        "id": "action_EQP8p5j4",
        "type": "spotlight",
        "elementId": "text_NmpREf5s"
      },
      {
        "id": "action_YnEbSjQE",
        "type": "speech",
        "text": "First, we have the GRPOTrainer, which is where training happens using group reward signals. Think of this as the heart of the learning process."
      },
      {
        "id": "action_b_wA3iu1",
        "type": "spotlight",
        "elementId": "text_AZxSvMwI"
      },
      {
        "id": "action_VGhyJKUO",
        "type": "speech",
        "text": "Next, the algorithm boosts efficiency with tools like vLLM and the Liger Kernel. These help make training faster and more powerful."
      },
      {
        "id": "action_3m2ZJ95y",
        "type": "spotlight",
        "elementId": "text_jFoPc5sj"
      },
      {
        "id": "action_kENJLHQU",
        "type": "speech",
        "text": "Now, let's look at the reward formula. We've simplified it here so it's easier to understand how the algorithm calculates rewards."
      },
      {
        "id": "action_z4RG-5HC",
        "type": "spotlight",
        "elementId": "latex_aNqsnlWT"
      },
      {
        "id": "action_DqN62otZ",
        "type": "speech",
        "text": "In simple terms, this formula shows how the algorithm combines different rewards from the group to decide what actions are best."
      },
      {
        "id": "action_iuZMk9AG",
        "type": "spotlight",
        "elementId": "text_KF1GE_TF"
      },
      {
        "id": "action_UCB77s-m",
        "type": "speech",
        "text": "To make it clearer, imagine this like scoring in a team sport. Everyone's performance contributes to the final score, just like in this algorithm."
      },
      {
        "id": "action_BRz0k_bj",
        "type": "speech",
        "text": "So, we've just broken down GRPO into its main parts: training with group rewards, improving efficiency, how the reward formula works, and a real-world way to think about it."
      }
    ],
    "after": [
      {
        "id": "review-4-0",
        "type": "speech",
        "text": "GRPO uses a clipped importance-ratio objective. The old sampling policy appears in the ratio. A reference policy can provide a separate KL regularizer."
      },
      {
        "id": "review-4-1",
        "type": "speech",
        "text": "Do not confuse the old policy with the reference policy, and do not minimize reward."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[4].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "6tgfaU9GrORRH-if9O_IA",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_x608xQw4",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Core Components of GRPO Algorithm</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_LMtsCJ0c",
            "type": "shape",
            "left": 60,
            "top": 140,
            "width": 430,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dbeafe",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_C4BHI7Qz",
            "type": "shape",
            "left": 510,
            "top": 140,
            "width": 430,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dcfce7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_NmpREf5s",
            "type": "text",
            "left": 80,
            "top": 172,
            "width": 390,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">GRPOTrainer:<br>Training with group reward signals</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "text_AZxSvMwI",
            "type": "text",
            "left": 530,
            "top": 172,
            "width": 390,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Efficiency Boost:<br>Using vLLM & Liger Kernel</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "shape_o2AR-Ovo",
            "type": "shape",
            "left": 60,
            "top": 310,
            "width": 430,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fef3c7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_9YLUs4yo",
            "type": "shape",
            "left": 510,
            "top": 310,
            "width": 430,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fde2e1",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_jFoPc5sj",
            "type": "text",
            "left": 80,
            "top": 342,
            "width": 390,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Reward Formula:<br>Simplified & Explained</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#92400e",
            "rotate": 0
          },
          {
            "id": "text_KF1GE_TF",
            "type": "text",
            "left": 530,
            "top": 342,
            "width": 390,
            "height": 76,
            "content": "<p style=\"font-size:18px; text-align:center;\">Real-World Analogy:<br>Team sports scoring</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#b91c1c",
            "rotate": 0
          },
          {
            "id": "latex_aNqsnlWT",
            "type": "latex",
            "left": 120,
            "top": 410,
            "width": 760,
            "height": 80,
            "latex": "\\text{Reward} = \\text{Group Reward} \\times \\text{Individual Contribution}",
            "color": "#000000",
            "align": "center",
            "html": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6944em;\"></span><span class=\"mord text\"><span class=\"mord\">Reward</span></span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.8889em;vertical-align:-0.1944em;\"></span><span class=\"mord text\"><span class=\"mord\">Group Reward</span></span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">×</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6944em;\"></span><span class=\"mord text\"><span class=\"mord\">Individual Contribution</span></span></span></span></span></span>",
            "fixedRatio": true,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-4",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Core Components of GRPO Algorithm</h2>"
          },
          {
            "id": "review-text-4-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">GRPO uses a clipped importance-ratio objective. The old sampling policy appears in the ratio. A reference policy can provide a separate KL regularizer.</p>"
          },
          {
            "id": "review-text-4-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Do not confuse the old policy with the reference policy, and do not minimize reward.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[5].actions",
    "before": [
      {
        "id": "action_cWtbxBLf",
        "type": "spotlight",
        "elementId": "text_K-J6bm2_"
      },
      {
        "id": "action_cK0PDx7R",
        "type": "speech",
        "text": "Let's compare two important reinforcement learning methods: PPO and GRPO. Understanding how they work differently helps us see which situations each is best for."
      },
      {
        "id": "action_1dZp8RGQ",
        "type": "spotlight",
        "elementId": "text_ExLZ_JUo"
      },
      {
        "id": "action_L5qvGyc2",
        "type": "speech",
        "text": "First, PPO optimizes based on single-step rewards. This means it adjusts actions by looking at immediate feedback after each move."
      },
      {
        "id": "action_JGxJXkWX",
        "type": "spotlight",
        "elementId": "text_QfoqDPfu"
      },
      {
        "id": "action_cnsndTLR",
        "type": "speech",
        "text": "In contrast, GRPO uses group reward signals for its optimization. Instead of just single steps, it considers the overall performance of a group."
      },
      {
        "id": "action_Rp7Eqw0c",
        "type": "spotlight",
        "elementId": "text_nVuPmt74"
      },
      {
        "id": "action_SnO1TzQP",
        "type": "speech",
        "text": "This approach makes GRPO more stable in learning and often more efficient, because it can smooth out fluctuations by focusing on collective outcomes."
      },
      {
        "id": "action_AUUPp73r",
        "type": "spotlight",
        "elementId": "text_6Vj8PxVU"
      },
      {
        "id": "action_h-Ikxxx8",
        "type": "speech",
        "text": "Think of it like a multiplayer game where a team works together. GRPO rewards the team’s overall success, encouraging strategies that benefit everyone."
      },
      {
        "id": "action_iTEKMkJ2",
        "type": "speech",
        "text": "In summary, PPO looks at single steps in isolation, while GRPO considers group rewards, leading to more stable and efficient learning. This team-based analogy helps grasp why group rewards matter."
      }
    ],
    "after": [
      {
        "id": "review-5-0",
        "type": "speech",
        "text": "PPO commonly learns a value critic for its advantage estimate. Original GRPO replaces that critic with a group-based baseline."
      },
      {
        "id": "review-5-1",
        "type": "speech",
        "text": "Neither method guarantees stability or correctness. Group size, reward quality, clipping and sampling still matter."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[5].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "fe7QWQnH3vzuJn8wZIM9_",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_K-J6bm2_",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Comparison: PPO vs GRPO</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "text_sNSuNzWQ",
            "type": "text",
            "left": 60,
            "top": 140,
            "width": 880,
            "height": 58,
            "content": "<p style=\"font-size:24px; color:#5b9bd5;\">Highlighting group reward advantages</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#5b9bd5",
            "rotate": 0
          },
          {
            "id": "shape_NZBrh5od",
            "type": "shape",
            "left": 60,
            "top": 220,
            "width": 430,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dbeafe",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_SGW8azYw",
            "type": "shape",
            "left": 510,
            "top": 220,
            "width": 430,
            "height": 140,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dcfce7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_ExLZ_JUo",
            "type": "text",
            "left": 80,
            "top": 252,
            "width": 390,
            "height": 94,
            "content": "<p style=\"font-size:18px; text-align:center; color:#1e40af;\"><strong>PPO</strong></p><p style=\"font-size:18px; text-align:center;\">• Optimizes using single-step rewards</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "text_QfoqDPfu",
            "type": "text",
            "left": 530,
            "top": 252,
            "width": 390,
            "height": 94,
            "content": "<p style=\"font-size:18px; text-align:center; color:#166534;\"><strong>GRPO</strong></p><p style=\"font-size:18px; text-align:center;\">• Uses group reward signals for optimization</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "shape_yjprE0Kx",
            "type": "shape",
            "left": 60,
            "top": 390,
            "width": 880,
            "height": 110,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#f3f4f6",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_nVuPmt74",
            "type": "text",
            "left": 80,
            "top": 416,
            "width": 840,
            "height": 76,
            "content": "<p style=\"font-size:18px; color:#92400e;\"><strong>Advantages of GRPO</strong></p><p style=\"font-size:18px;\">• More stable learning</p><p style=\"font-size:18px;\">• Improved efficiency in complex tasks</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#92400e",
            "rotate": 0
          },
          {
            "id": "text_6Vj8PxVU",
            "type": "text",
            "left": 60,
            "top": 525,
            "width": 880,
            "height": 58,
            "content": "<p style=\"font-size:18px; font-style:italic; color:#555555; text-align:center;\">Think of it like a multiplayer game team strategy</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#555555",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-5",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Comparison: PPO vs GRPO</h2>"
          },
          {
            "id": "review-text-5-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">PPO commonly learns a value critic for its advantage estimate. Original GRPO replaces that critic with a group-based baseline.</p>"
          },
          {
            "id": "review-text-5-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Neither method guarantees stability or correctness. Group size, reward quality, clipping and sampling still matter.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[6].actions",
    "before": [
      {
        "id": "action_4eH553n1",
        "type": "spotlight",
        "elementId": "text_M88i2zf0"
      },
      {
        "id": "action_ad2Tu3FQ",
        "type": "speech",
        "text": "Let's explore the real-world applications and benefits of TRL and GRPO in AI systems, and see how they help language models perform better."
      },
      {
        "id": "action_EmMxIw70",
        "type": "spotlight",
        "elementId": "text_T9kvOp6Z"
      },
      {
        "id": "action_CShRKPZm",
        "type": "speech",
        "text": "Here we have examples like chatbots and virtual assistants, which you might interact with daily. These systems use group rewards to improve their responses, making conversations more natural and helpful."
      },
      {
        "id": "action_SL_d4yV_",
        "type": "laser",
        "elementId": "text_T9kvOp6Z"
      },
      {
        "id": "action_JM-F3df5",
        "type": "speech",
        "text": "Notice how group rewards encourage better quality answers from AI models, similar to how teamwork leads to better results in our group projects."
      },
      {
        "id": "action_m6eO4vmS",
        "type": "spotlight",
        "elementId": "shape_rcstHagZ"
      },
      {
        "id": "action_1iManGcP",
        "type": "speech",
        "text": "Using group strategies like these helps reduce the amount of memory and computing power needed during AI training, which is a big efficiency win."
      },
      {
        "id": "action_P8sDmqMa",
        "type": "spotlight",
        "elementId": "shape_2lxr6bwe"
      },
      {
        "id": "action_n8XFY3Oz",
        "type": "speech",
        "text": "We can even think of this like social media groups—where people align their opinions and behaviors—helping language models learn better patterns from collective feedback."
      },
      {
        "id": "action_5Jy7cGtZ",
        "type": "speech",
        "text": "Together, these benefits show how TRL and GRPO make AI systems smarter, more efficient, and closer to how humans communicate."
      }
    ],
    "after": [
      {
        "id": "review-6-0",
        "type": "speech",
        "text": "Use the Workbench to change one reward while holding the other three fixed. Predict which advantages will change before moving the control."
      },
      {
        "id": "review-6-1",
        "type": "speech",
        "text": "All four advantages can change because both the group mean and its spread depend on every reward."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[6].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "_I3L4h2gQMvwgDI8Q4kQf",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_M88i2zf0",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>Real-World Applications and Benefits</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_rcstHagZ",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_T9kvOp6Z",
            "type": "text",
            "left": 60,
            "top": 160,
            "width": 880,
            "height": 130,
            "content": "<p style=\"font-size:18px;\">• Examples: Chatbots, virtual assistants</p><p style=\"font-size:18px;\">• Group rewards improve response quality</p><p style=\"font-size:18px;\">• Save memory and boost training efficiency</p><p style=\"font-size:18px;\">• Social media group behavior analogies</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_2lxr6bwe",
            "type": "shape",
            "left": 45,
            "top": 170,
            "width": 5,
            "height": 104,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#ed7d31",
            "fixedRatio": false,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-6",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Real-World Applications and Benefits</h2>"
          },
          {
            "id": "review-text-6-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Use the Workbench to change one reward while holding the other three fixed. Predict which advantages will change before moving the control.</p>"
          },
          {
            "id": "review-text-6-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">All four advantages can change because both the group mean and its spread depend on every reward.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[7].actions",
    "before": [
      {
        "id": "action_1AiM4ztw",
        "type": "speech",
        "text": "Now let's check what we've learned about TRL and GRPO. Try each question on your own, and take your time to think through your answers."
      },
      {
        "id": "action_49ZvryRL",
        "type": "speech",
        "text": "Once you've finished the quiz, I'll be here to go over any parts that need a bit more explanation."
      }
    ],
    "after": [
      {
        "id": "review-7-0",
        "type": "speech",
        "text": "A runnable trainer needs a model, tokenizer, prompt data and a tested reward function. Small teaching calculations do not reproduce a full training run."
      },
      {
        "id": "review-7-1",
        "type": "speech",
        "text": "Record the TRL version and objective settings: current implementations expose variants that differ from the original paper."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[7].content.questions",
    "before": [
      {
        "id": "q1",
        "type": "single",
        "question": "What does TRL stand for in technology development?",
        "options": [
          {
            "value": "A",
            "label": "Technology Readiness Level"
          },
          {
            "value": "B",
            "label": "Technical Resource List"
          },
          {
            "value": "C",
            "label": "Time-related Logistics"
          },
          {
            "value": "D",
            "label": "Total Reliability Load"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "TRL means Technology Readiness Level. It is a way to measure how mature or ready a technology is, from initial idea to full use. The other options are incorrect because they do not relate to measuring technology development stages.",
        "points": 5,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "Which of the following best describes a GRPO algorithm?",
        "options": [
          {
            "value": "A",
            "label": "A method to predict how users group information."
          },
          {
            "value": "B",
            "label": "An approach to process orders and handle priorities."
          },
          {
            "value": "C",
            "label": "A type of sorting algorithm for numbers."
          },
          {
            "value": "D",
            "label": "A way to measure energy efficiency."
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "GRPO stands for algorithms dealing with order processing and managing priorities, helping organize tasks efficiently. The other answers are either too general or unrelated.",
        "points": 6,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "If TRL is like climbing a ladder, what does the top step represent?",
        "options": [
          {
            "value": "A",
            "label": "A brand-new idea that needs testing."
          },
          {
            "value": "B",
            "label": "Technology that is fully tested and ready to use."
          },
          {
            "value": "C",
            "label": "An old technology being retired."
          },
          {
            "value": "D",
            "label": "A theory that hasn’t been proven."
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "The highest step in TRL means the technology is mature and ready for actual use. Starting ideas or theories belong to the bottom steps, not the top.",
        "points": 5,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "Imagine you have many tasks to do. How would a GRPO algorithm help you?",
        "options": [
          {
            "value": "A",
            "label": "By randomly picking tasks to do first."
          },
          {
            "value": "B",
            "label": "By sorting tasks based on their importance and deadline."
          },
          {
            "value": "C",
            "label": "By doing the easiest tasks last."
          },
          {
            "value": "D",
            "label": "By ignoring the order and focusing on one type only."
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "GRPO algorithms help to prioritize tasks by sorting them based on importance and due time, making your work efficient. Random or ignoring order would not help manage tasks well.",
        "points": 6,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "Why is it useful to know the TRL of a new gadget?",
        "options": [
          {
            "value": "A",
            "label": "To understand how many people use it."
          },
          {
            "value": "B",
            "label": "To know if it’s still being tested or ready to buy."
          },
          {
            "value": "C",
            "label": "To check what brand made it."
          },
          {
            "value": "D",
            "label": "To find out how expensive it is."
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "TRL helps users and developers know if the gadget is just an idea or fully developed and ready for the market. The other options do not relate to TRL’s purpose.",
        "points": 5,
        "hasAnswer": true
      }
    ],
    "after": [
      {
        "id": "q1",
        "type": "single",
        "question": "In this AI lesson, what does TRL stand for?",
        "options": [
          {
            "value": "A",
            "label": "Transformer Reinforcement Learning"
          },
          {
            "value": "B",
            "label": "Technology Readiness Level"
          },
          {
            "value": "C",
            "label": "Token Ranking List"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "TRL is the Hugging Face library for language-model post-training.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "What is a group in original outcome-supervised GRPO?",
        "options": [
          {
            "value": "A",
            "label": "Independent agents sharing one team reward"
          },
          {
            "value": "B",
            "label": "Several completions sampled for the same prompt"
          },
          {
            "value": "C",
            "label": "A list of task deadlines"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Each sampled completion receives its own reward, compared with rewards for the same prompt.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "Rewards are 0, 1, 1, 2. Which completion is above the mean?",
        "options": [
          {
            "value": "A",
            "label": "The reward 0 completion"
          },
          {
            "value": "B",
            "label": "Both reward 1 completions"
          },
          {
            "value": "C",
            "label": "The reward 2 completion"
          }
        ],
        "answer": [
          "C"
        ],
        "analysis": "The mean is 1, so only reward 2 is above it.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "What happens if all group rewards are equal?",
        "options": [
          {
            "value": "A",
            "label": "Relative reward differences vanish"
          },
          {
            "value": "B",
            "label": "Every completion is necessarily correct"
          },
          {
            "value": "C",
            "label": "The algorithm sorts deadlines"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "Equal rewards provide no within-group ranking signal; implementations handle zero variance numerically.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "What does original GRPO remove relative to standard PPO?",
        "options": [
          {
            "value": "A",
            "label": "All model parameters"
          },
          {
            "value": "B",
            "label": "A separately trained value critic"
          },
          {
            "value": "C",
            "label": "The need to evaluate outputs"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "GRPO uses a group-based baseline instead of a learned value critic; reward evaluation remains necessary.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "reason": "Replace unrelated or incorrect GRPO assessment.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[8].actions",
    "before": [
      {
        "id": "action_aCv4pIoG",
        "type": "spotlight",
        "elementId": "text_xDD18jnl"
      },
      {
        "id": "action_-2H9S6Ya",
        "type": "speech",
        "text": "Let's wrap up today's lesson by reviewing the key takeaways from our discussion on AI alignment."
      },
      {
        "id": "action_I1the_6v",
        "type": "spotlight",
        "elementId": "text_mYiuU0G6"
      },
      {
        "id": "action_n68DBOxk",
        "type": "speech",
        "text": "First, we talked about TRL, which is a method that transforms pre-trained language models into aligned agents who better understand and follow desired behaviors."
      },
      {
        "id": "action_CpOFcqhE",
        "type": "spotlight",
        "elementId": "text_HqqahOJp"
      },
      {
        "id": "action_lVCXPFiI",
        "type": "speech",
        "text": "Next, we looked at GRPO, a technique that uses group reward signals to improve training, making the learning process more effective."
      },
      {
        "id": "action_cRci779S",
        "type": "spotlight",
        "elementId": "text_99jTU8rB"
      },
      {
        "id": "action_DkPJSFxa",
        "type": "speech",
        "text": "This group reward approach also enhances stability and efficiency, helping models learn more consistently and reliably."
      },
      {
        "id": "action_wKwnBEFW",
        "type": "spotlight",
        "elementId": "text_LRt46osI"
      },
      {
        "id": "action_kiKCc7nE",
        "type": "speech",
        "text": "Finally, I encourage all of you to keep exploring the fascinating field of AI alignment, as there’s still much to discover and understand."
      },
      {
        "id": "action_o4RTkufc",
        "type": "speech",
        "text": "That brings us to the end of our session. Great job following along, and I look forward to seeing your continued curiosity in this exciting area."
      }
    ],
    "after": [
      {
        "id": "review-8-0",
        "type": "speech",
        "text": "Check the definitions and calculate a group baseline. A correct answer should refer to completions of the same prompt."
      },
      {
        "id": "review-8-1",
        "type": "speech",
        "text": "Review the explanation after choosing, then try again if your answer relied on the old team analogy."
      }
    ],
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "09_trl-grpo_highschool.json",
    "path": "scenes[8].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "Vqmmf5aPZ-pQSPjvW5Job",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_xDD18jnl",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:36px;\"><strong>Summary and Key Takeaways</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_uIOzlASx",
            "type": "shape",
            "left": 70,
            "top": 130,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_YFum07qk",
            "type": "shape",
            "left": 60,
            "top": 160,
            "width": 880,
            "height": 100,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#e8f4fd",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_mYiuU0G6",
            "type": "text",
            "left": 80,
            "top": 186,
            "width": 840,
            "height": 76,
            "content": "<p style=\"font-size:20px;\">• TRL turns pre-trained language models into aligned agents</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "shape_tXAbI5uV",
            "type": "shape",
            "left": 60,
            "top": 280,
            "width": 880,
            "height": 100,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dcfce7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_HqqahOJp",
            "type": "text",
            "left": 80,
            "top": 306,
            "width": 840,
            "height": 76,
            "content": "<p style=\"font-size:20px;\">• GRPO uses group reward signals for better training</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "shape__nr7AyqQ",
            "type": "shape",
            "left": 60,
            "top": 400,
            "width": 880,
            "height": 100,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fef3c7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_99jTU8rB",
            "type": "text",
            "left": 80,
            "top": 426,
            "width": 840,
            "height": 76,
            "content": "<p style=\"font-size:20px;\">• Group reward approach brings stability and efficiency</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#92400e",
            "rotate": 0
          },
          {
            "id": "shape_MKrDYD2Y",
            "type": "shape",
            "left": 60,
            "top": 520,
            "width": 880,
            "height": 100,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#fde2e1",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_LRt46osI",
            "type": "text",
            "left": 80,
            "top": 546,
            "width": 840,
            "height": 76,
            "content": "<p style=\"font-size:20px;\">• Keep exploring to learn more about AI alignment</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#b02a37",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-8",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>Summary and Key Takeaways</h2>"
          },
          {
            "id": "review-text-8-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Check the definitions and calculate a group baseline. A correct answer should refer to completions of the same prompt.</p>"
          },
          {
            "id": "review-text-8-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">Review the explanation after choosing, then try again if your answer relied on the old team analogy.</p>"
          }
        ]
      }
    },
    "reason": "Replace incorrect GRPO definitions and group-agent interpretation.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "11_next-token-emergence_college.json",
    "path": "scenes[3].elements[6].latex",
    "before": "\\text{Sparse Attention: } \\mathbf{X}W_Q\\cdot \\mathbf{X}W_K^T \\to \\text{sparse mask}",
    "after": "S=(XW_Q)(XW_K)^\\top/\\sqrt{d_k}+M,\\quad A=\\operatorname{softmax}(S)",
    "reason": "Transpose the complete key projection and add the mask to logits.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "11_next-token-emergence_college.json",
    "path": "scenes[5].elements[5].latex",
    "before": "\\frac{\\partial L}{\\partial E} = \\left(\\hat{y} - y\\right) W^T",
    "after": "Z=HW_o,\\quad \\nabla_H L=(P-Y)W_o^\\top;\\quad \\nabla_E L\\text{ additionally follows the upstream network}",
    "reason": "A final hidden-state gradient is not generally the embedding-table gradient.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
  },
  {
    "file": "12_attention-mechanism_college.json",
    "path": "scenes[8].elements[4].latex",
    "before": "\\text{Sparse Attention: } \\mathbf{A} = \\text{softmax}(QK^T \\odot \\mathbf{M}) V",
    "after": "A=\\operatorname{softmax}(QK^\\top/\\sqrt{d_k}+M)V;\\quad M_{ij}\\in\\{0,-\\infty\\}",
    "reason": "Multiplying logits by a zero mask does not exclude them.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "12a_add-attention_college.json",
    "path": "scenes[0].elements[7].latex",
    "before": "e_t = \\mathbf{v}^\\top \\tanh(\\mathbf{W}_1 \\mathbf{s}_{t-1} + \\mathbf{W}_2 \\mathbf{h}_j)",
    "after": "e_{tj}=v^\\top\\tanh(W_s s_{t-1}+W_h h_j)",
    "reason": "Compatibility scores require both query and key indices.",
    "reference": "https://arxiv.org/abs/1409.0473"
  },
  {
    "file": "12a_add-attention_college.json",
    "path": "scenes[0].elements[8].latex",
    "before": "\\alpha_{tj} = \\frac{\\exp(e_t)}{\\sum_k \\exp(e_k)}",
    "after": "\\alpha_{tj}=\\frac{\\exp(e_{tj})}{\\sum_k\\exp(e_{tk})}",
    "reason": "Normalize over keys for a fixed decoder query.",
    "reference": "https://arxiv.org/abs/1409.0473"
  },
  {
    "file": "12a_add-attention_college.json",
    "path": "scenes[5].elements[5].latex",
    "before": "\\text{Efficient Additive Attention: } \\quad \\mathrm{Attention}(Q,K,V) = \\mathop{\\mathrm{softmax}}\\left( \\frac{QW_Q + KW_K^T}{\\sqrt{d}} \\right) V",
    "after": "e_{ij}=v^\\top\\tanh(W_q q_i+W_k k_j);\\quad O_i=\\sum_j\\operatorname{softmax}_j(e_{ij})v_j",
    "reason": "The original expression was not a valid additive attention equation.",
    "reference": "https://arxiv.org/abs/1409.0473"
  },
  {
    "file": "12a_add-attention_college.json",
    "path": "scenes[5].elements[8].latex",
    "before": "\\mathrm{Attention_{hybrid}}(Q,K,V) = \\lambda \\cdot \\mathrm{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right) V + (1-\\lambda) \\cdot \\mathrm{softmax}(Q + K^T) V",
    "after": "O_i=\\lambda\\sum_j\\operatorname{softmax}_j(q_i^\\top k_j/\\sqrt{d_k})v_j+(1-\\lambda)\\sum_j\\operatorname{softmax}_j(u^\\top\\tanh(W_q q_i+W_k k_j))v_j",
    "reason": "Label this as an illustrative mixture, not a standard algorithm.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "13_transformer-block_college.json",
    "path": "scenes[4].elements[10].latex",
    "before": "\\mathrm{FFN}(x) = \\mathrm{W}_2\\left(\\mathrm{SwiGLU}(\\mathrm{W}_1 x)\\right) + b_2",
    "after": "\\operatorname{FFN}(x)=W_2[\\operatorname{SiLU}(W_gx)\\odot(W_vx)]+b_2",
    "reason": "SwiGLU requires two projected branches.",
    "reference": "https://arxiv.org/abs/2002.05202"
  },
  {
    "file": "13_transformer-block_college.json",
    "path": "scenes[5].elements[6].latex",
    "before": "\\text{Output} = \\mathrm{LayerNorm}\\big(\\mathrm{FFN}(\\mathrm{LayerNorm}(\\mathrm{Attention}(X) + X)) + \\mathrm{Attention}(X) + X\\big)",
    "after": "H=\\operatorname{LN}(X+\\operatorname{Attn}(X));\\quad Y=\\operatorname{LN}(H+\\operatorname{FFN}(H))\\quad\\text{(post-norm)}",
    "reason": "Use the normalized residual state consistently.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "13_transformer-block_college.json",
    "path": "scenes[10].elements[9].latex",
    "before": "\\frac{\\partial L}{\\partial x} = \\frac{1}{\\sigma} \\left(\\frac{\\partial L}{\\partial y} - \\frac{1}{d} \\sum \\frac{\\partial L}{\\partial y} - y \\circ \\sum \\left( \\frac{\\partial L}{\\partial y} \\circ y \\right)\\right)",
    "after": "\\hat{x}=(x-\\mu)/\\sqrt{\\sigma^2+\\epsilon},\\ g=\\nabla_yL\\odot\\gamma;\\quad \\nabla_xL=[g-\\operatorname{mean}(g)-\\hat{x}\\operatorname{mean}(g\\odot\\hat{x})]/\\sqrt{\\sigma^2+\\epsilon}",
    "reason": "LayerNorm derivative needs both means and the affine scale.",
    "reference": "https://arxiv.org/abs/1607.06450"
  },
  {
    "file": "13_transformer-block_college.json",
    "path": "scenes[10].elements[14].latex",
    "before": "\\nabla_{L} = \\nabla_{\\text{CE}} + \\lambda_1 \\nabla_{\\text{attention}} + \\lambda_2 \\nabla_{\\text{residual}}",
    "after": "\\nabla_X L=\\nabla_H L+J_f(X)^\\top\\nabla_H L\\quad\\text{for }H=X+f(X)",
    "reason": "Residual gradients add via chain rule; separate attention losses are not implied.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "15_training-optimizations_college.json",
    "path": "scenes[1].elements[12].latex",
    "before": "\\theta_t = \\theta_{t-1} - \\eta \\frac{m_t}{\\sqrt{v_t} + \\epsilon}",
    "after": "\\hat m_t=m_t/(1-\\beta_1^t),\\quad\\hat v_t=v_t/(1-\\beta_2^t);\\quad\\theta_t=(1-\\eta\\lambda)\\theta_{t-1}-\\eta\\hat m_t/(\\sqrt{\\hat v_t}+\\epsilon)",
    "reason": "AdamW includes bias correction and decoupled weight decay.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.optim.AdamW.html"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[5].actions",
    "before": [
      {
        "id": "action_cv0ZYEQG",
        "type": "spotlight",
        "elementId": "text_BH4iBPVY"
      },
      {
        "id": "action_K0gu9FHj",
        "type": "speech",
        "text": "KTO recasts alignment as prospect theoretic optimization: rather than maximize expected reward under a fixed utility, it optimizes a reference dependent value that treats wins and failures asymmetrically, borrowing Kahneman and Tversky’s account of human choice."
      },
      {
        "id": "action_m3S0mfOi",
        "type": "spotlight",
        "elementId": "text_iv0EEg9z"
      },
      {
        "id": "action_cMlHFYR_",
        "type": "speech",
        "text": "The motivation is that expected utility is too symmetric. Prospect theory uses a reference point, concave utility for gains, steeper losses, and distorted probability weighting; that loss aversion is a better prior for messy preference labels and safety critical errors."
      },
      {
        "id": "action_8wqk-M9I",
        "type": "spotlight",
        "elementId": "text_iv0EEg9z"
      },
      {
        "id": "action_fQpRUEFx",
        "type": "speech",
        "text": "The KTO objective replaces paired preference comparisons with binary desirable or undesirable signals, then shapes log likelihood ratios against a reference policy, with K L regularization and loss aversion weights controlling downside risk more strongly than upside."
      },
      {
        "id": "action_bvDsA2gK",
        "type": "spotlight",
        "elementId": "text_vx7LJuMZ"
      },
      {
        "id": "action_PpXtAlCx",
        "type": "speech",
        "text": "Ethayarajh and colleagues introduced this human aware view in twenty twenty four, showing that alignment can exploit abundant binary judgments when paired demonstrations are scarce, while remaining close to the DPO and RLHF lineage."
      },
      {
        "id": "action_FRPp7vqa",
        "type": "spotlight",
        "elementId": "text_iv0EEg9z"
      },
      {
        "id": "action_nLjPTay4",
        "type": "speech",
        "text": "Against DPO or vanilla RLHF, KTO is less tied to calibrated pairwise probabilities and more sensitive to catastrophic negatives; the cost is extra hyperparameters and a value function whose behavioral assumptions must be ablated, not assumed."
      },
      {
        "id": "action_nfxWlvhR",
        "type": "speech",
        "text": "The takeaway: alignment is not only reward fitting but reference dependent risk shaping. KTO gives a principled way to encode loss aversion, though its gains still hinge on data quality, K L strength, and careful evaluation."
      }
    ],
    "after": [
      {
        "id": "review-5-0",
        "type": "speech",
        "text": "KTO means Kahneman-Tversky Optimization. It uses a prospect-theory-inspired objective and can learn from individual outputs labeled desirable or undesirable."
      },
      {
        "id": "review-5-1",
        "type": "speech",
        "text": "It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best."
      }
    ],
    "reason": "Correct alignment algorithm definitions.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[5].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "pz7H-nACIFRPajG8x-mDD",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_BH4iBPVY",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:36px;\"><strong>KTO: Model Alignment as Prospect Theoretic Optimization</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "text_vx7LJuMZ",
            "type": "text",
            "left": 60,
            "top": 140,
            "width": 880,
            "height": 58,
            "content": "<p style=\"font-size:24px; color:#5b9bd5;\">Human-aware alignment beyond expected utility (Ethayarajh et al. 2024)</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#5b9bd5",
            "rotate": 0
          },
          {
            "id": "shape_IQcu97s-",
            "type": "shape",
            "left": 60,
            "top": 200,
            "width": 880,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_iv0EEg9z",
            "type": "text",
            "left": 60,
            "top": 220,
            "width": 880,
            "height": 202,
            "content": "<p style=\"font-size:20px; color:#333333;\">• Prospect theory: reference point, loss aversion, probability weighting</p><p style=\"font-size:20px; color:#333333;\">• KTO: binary desirable or undesirable signals, KL-regularized policy shift</p><p style=\"font-size:20px; color:#333333;\">• Versus DPO and RLHF: fewer pairs, sharper downside control, more ablations</p><p style=\"font-size:20px; color:#333333;\">• Citations: Kahneman and Tversky 1979; Ethayarajh et al. 2024</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_vFvZOpTm",
            "type": "shape",
            "left": 45,
            "top": 228,
            "width": 6,
            "height": 169,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#ed7d31",
            "fixedRatio": false,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-5",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>KTO: Model Alignment as Prospect Theoretic Optimization</h2>"
          },
          {
            "id": "review-text-5-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">KTO means Kahneman-Tversky Optimization. It uses a prospect-theory-inspired objective and can learn from individual outputs labeled desirable or undesirable.</p>"
          },
          {
            "id": "review-text-5-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.</p>"
          }
        ]
      }
    },
    "reason": "Correct alignment algorithm definitions.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[5].actions[1].text",
    "before": "It is not Kendall Tau Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.",
    "after": "It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.",
    "reason": "Correct KTO expansion.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[5].content.canvas.elements[2].content",
    "before": "<p style=\"font-size:23px\">It is not Kendall Tau Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.</p>",
    "after": "<p style=\"font-size:23px\">It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.</p>",
    "reason": "Correct KTO expansion.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[6].actions",
    "before": [
      {
        "id": "action_tx-zJH1h",
        "type": "spotlight",
        "elementId": "text_pobRRKoU"
      },
      {
        "id": "action_LOQww0N_",
        "type": "speech",
        "text": "Today we examine ORPO, Odds Ratio Preference Optimization, introduced by Hong, Lee, and Thorne in 2024. Its monolithic design collapses supervised fine-tuning and preference alignment into a single training stage."
      },
      {
        "id": "action_swEd4GG9",
        "type": "spotlight",
        "elementId": "text_G4B8-tPy"
      },
      {
        "id": "action_Y-ez2uUb",
        "type": "speech",
        "text": "The monolithic idea is this: rather than first running supervised fine-tuning and then a separate alignment phase like PPO or DPO, ORPO optimizes one joint objective over chosen and rejected response pairs."
      },
      {
        "id": "action_f1WDLz7n",
        "type": "spotlight",
        "elementId": "text_AkO5pv8_"
      },
      {
        "id": "action_aM5-hrh9",
        "type": "speech",
        "text": "Formally, the loss is the standard negative log likelihood on the chosen response, plus a lambda-weighted odds ratio term: the log sigmoid of the log odds ratio between chosen and rejected sequences."
      },
      {
        "id": "action_sBKmHxs0",
        "type": "spotlight",
        "elementId": "text_dZNUpij4"
      },
      {
        "id": "action_UelEAE5o",
        "type": "speech",
        "text": "A key consequence is the elimination of the reference model. DPO still requires a frozen reference policy for its KL constraint; ORPO drops it entirely, halving memory and simplifying the training pipeline considerably."
      },
      {
        "id": "action_xJAjDm9y",
        "type": "spotlight",
        "elementId": "text_D9yELsxN"
      },
      {
        "id": "action_tAL9yMnG",
        "type": "speech",
        "text": "The odds ratio term contributes an adaptive gradient: it penalizes the rejected response proportionally to the model's confidence in it, pushing down likelihood of bad outputs without distorting the chosen distribution."
      },
      {
        "id": "action_0_t8QBOz",
        "type": "spotlight",
        "elementId": "text_VfWTiMTK"
      },
      {
        "id": "action_DmzSd3Q-",
        "type": "speech",
        "text": "Hong and colleagues validated this empirically: models fine-tuned with ORPO on Phi-2, Llama-2, and Mistral matched or exceeded DPO baselines on AlpacaEval, despite the simpler single-stage recipe."
      },
      {
        "id": "action_W599bZev",
        "type": "speech",
        "text": "To summarize: ORPO folds preference optimization into the supervised loss itself, removing both the reference model and the two-stage pipeline. It is a strong baseline when you want alignment without the machinery of PPO or DPO."
      }
    ],
    "after": [
      {
        "id": "review-6-0",
        "type": "speech",
        "text": "ORPO means Odds Ratio Preference Optimization. It combines a supervised negative-log-likelihood term with a preference term comparing chosen and rejected output odds."
      },
      {
        "id": "review-6-1",
        "type": "speech",
        "text": "The original method does not require a separate reference model. Odds are p divided by one minus p; odds and probabilities are different."
      }
    ],
    "reason": "Correct alignment algorithm definitions.",
    "reference": "https://arxiv.org/abs/2403.07691"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[6].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "mOW63ZD4Be6NAHZcLu6ia",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_pobRRKoU",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>ORPO: Monolithic Preference Optimization</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_yhqZr_5C",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 3,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#5b9bd5",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "shape_bHJBBqvt",
            "type": "shape",
            "left": 60,
            "top": 180,
            "width": 430,
            "height": 150,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dbeafe",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_G4B8-tPy",
            "type": "text",
            "left": 80,
            "top": 212,
            "width": 390,
            "height": 94,
            "content": "<p style=\"font-size:18px; text-align:center;\"><strong>Monolithic Optimization Concept</strong></p><p style=\"font-size:18px; text-align:center;\">• Single-stage: SFT + preference alignment in one loss<br>• No reference model, no separate RLHF phase</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1e40af",
            "rotate": 0
          },
          {
            "id": "shape_HETzcX5c",
            "type": "shape",
            "left": 510,
            "top": 180,
            "width": 430,
            "height": 150,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#dcfce7",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_AkO5pv8_",
            "type": "text",
            "left": 530,
            "top": 212,
            "width": 390,
            "height": 94,
            "content": "<p style=\"font-size:18px; text-align:center;\"><strong>Mathematical Definition & Properties</strong></p><p style=\"font-size:18px; text-align:center;\">• Loss: \\(\\mathcal{L}_{ORPO} = \\mathcal{L}_{SFT} + \\lambda\\, \\mathcal{L}_{OR}\\), \\(\\mathcal{L}_{OR} = -\\log\\sigma\\!\\left(\\log\\tfrac{\\mathrm{odds}_\\theta(y_w|x)}{\\mathrm{odds}_\\theta(y_l|x)}\\right)\\)<br>• \\(\\mathrm{odds}_\\theta(y|x) = \\frac{p_\\theta(y|x)}{1 - p_\\theta(y|x)}\\); reference-free</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#166534",
            "rotate": 0
          },
          {
            "id": "text_dZNUpij4",
            "type": "text",
            "left": 60,
            "top": 360,
            "width": 880,
            "height": 52,
            "content": "<p style=\"font-size:24px; color:#333333;\"><strong>Implications for Alignment Scalability</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "text_D9yELsxN",
            "type": "text",
            "left": 80,
            "top": 420,
            "width": 860,
            "height": 94,
            "content": "<p style=\"font-size:18px;\">• No reference model: roughly half the memory of DPO training<br>• Adaptive penalty on rejected responses scales with model confidence<br>• Matches or beats DPO on AlpacaEval (Phi-2, Llama-2, Mistral)</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "text_VfWTiMTK",
            "type": "text",
            "left": 780,
            "top": 520,
            "width": 180,
            "height": 43,
            "content": "<p style=\"font-size:14px; color:#666666; text-align:right;\">Hong, Lee, & Thorne, 2024</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#666666",
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-6",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>ORPO: Monolithic Preference Optimization</h2>"
          },
          {
            "id": "review-text-6-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">ORPO means Odds Ratio Preference Optimization. It combines a supervised negative-log-likelihood term with a preference term comparing chosen and rejected output odds.</p>"
          },
          {
            "id": "review-text-6-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">The original method does not require a separate reference model. Odds are p divided by one minus p; odds and probabilities are different.</p>"
          }
        ]
      }
    },
    "reason": "Correct alignment algorithm definitions.",
    "reference": "https://arxiv.org/abs/2403.07691"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[9].content.questions",
    "before": [
      {
        "id": "q1",
        "type": "single",
        "question": "Which of the following best characterizes the DPO (Direct Preference Optimization) principle in preference learning?",
        "options": [
          {
            "value": "A",
            "label": "DPO directly optimizes a policy to maximize expected reward by modeling pairwise preference data."
          },
          {
            "value": "B",
            "label": "DPO relies solely on ranking-based loss functions without using probabilistic models."
          },
          {
            "value": "C",
            "label": "DPO is an unsupervised learning approach focusing on clustering preference patterns."
          },
          {
            "value": "D",
            "label": "DPO uses reinforcement learning with explicit exploration strategies for preference elicitation."
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "DPO is designed to directly optimize a policy based on pairwise preference data by formulating an objective that maximizes expected reward, contrasted with approaches that rely only on ranking losses or unsupervised learning. Options B, C, and D mischaracterize DPO by ignoring its optimization framework or purpose.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "multiple",
        "question": "Select all principles that are foundational to the KTO (Kendall Tau Optimization) approach in preference learning:",
        "options": [
          {
            "value": "A",
            "label": "Maximizing the concordance between predicted and observed rankings"
          },
          {
            "value": "B",
            "label": "Minimizing classification error over absolute labels"
          },
          {
            "value": "C",
            "label": "Utilizing pairwise comparisons to approximate ranking metrics"
          },
          {
            "value": "D",
            "label": "Employing probabilistic models without explicit ranking objective"
          }
        ],
        "answer": [
          "A",
          "C"
        ],
        "analysis": "KTO focuses on maximizing Kendall Tau correlation, which measures concordance between predicted and observed rankings, by leveraging pairwise comparisons to approximate ranking losses. Options B and D are incorrect as they do not align with KTO’s emphasis on ranking concordance and pairwise optimization.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "short_answer",
        "question": "Explain the primary motivation and mechanism behind the ORPO (Optimized Rank Probability Objective) principle in preference learning. How does it differ conceptually from DPO and KTO?",
        "commentPrompt": "Grading rubric: (1) Explanation of ORPO's use of a differentiable surrogate for ranking probabilities - 40% (2) Discussion of the optimization of probabilistic ranking objectives as opposed to direct policy or concordance optimization - 35% (3) Clarity and precision of explanation including distinctions from DPO and KTO - 25%",
        "analysis": "ORPO aims to maximize a probabilistic ranking objective by introducing a differentiable surrogate that captures ranking uncertainties, allowing gradient-based optimization. Unlike DPO which directly optimizes policies on preference pairs, or KTO which targets concordance metrics like Kendall Tau, ORPO focuses on the optimization of smooth ranking probability functions. This makes ORPO more suitable for continuous optimization frameworks and enables finer-grained control.",
        "points": 20,
        "hasAnswer": false
      },
      {
        "id": "q4",
        "type": "single",
        "question": "Consider the loss function L = -log(sigmoid(score_positive - score_negative)) used in a pairwise preference model. What does the gradient of L with respect to the score_positive represent?",
        "options": [
          {
            "value": "A",
            "label": "A negative adjustment scaled by the probability that the positive score is indeed preferred over the negative"
          },
          {
            "value": "B",
            "label": "A positive adjustment scaled by the same sigmoid probability"
          },
          {
            "value": "C",
            "label": "A constant zero gradient independent of scores"
          },
          {
            "value": "D",
            "label": "A gradient encouraging the scores to become equal"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "The gradient of the logistic loss with respect to score_positive is negative scaled by (1 - sigmoid(score_positive - score_negative)), which represents pushing the positive score higher if its predicted preference probability is low. Hence it is a negative adjustment scaled by the probability the positive score is indeed larger. Other options misunderstand the direction or magnitude principle of the gradient in this loss.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "short_answer",
        "question": "Analyze the provided PyTorch snippet below and explain what optimization objective it implements. Include in your explanation the role of each key step in the process:\n\nimport torch\nimport torch.nn.functional as F\n\nscores_pos = torch.tensor([3.0, 5.0, 2.5])\nscores_neg = torch.tensor([2.0, 4.5, 3.0])\n\nloss = -torch.mean(F.logsigmoid(scores_pos - scores_neg))\n\n# optimizer.zero_grad()\n# loss.backward()\n# optimizer.step()",
        "commentPrompt": "Evaluation rubric: (1) Correct identification of the pairwise logistic loss implementation - 50% (2) Interpretation of the logits difference and sigmoid function role - 25% (3) Understanding of the optimizer steps and backward propagation significance - 25%",
        "analysis": "This PyTorch code computes the average negative log-sigmoid loss over pairs of positive and negative scores, implementing a pairwise logistic loss which encourages higher scores for preferred items. The difference scores_pos - scores_neg is passed through logsigmoid to estimate preference probability. The commented optimizer steps indicate gradient clearing, backward propagation of loss gradients, and parameter update, confirming an optimization loop consistent with pairwise preference learning.",
        "points": 20,
        "hasAnswer": false
      }
    ],
    "after": [
      {
        "id": "q1",
        "type": "single",
        "question": "What information does standard DPO use?",
        "options": [
          {
            "value": "A",
            "label": "Chosen/rejected pairs and reference-policy log probabilities"
          },
          {
            "value": "B",
            "label": "Only a Kendall rank statistic"
          },
          {
            "value": "C",
            "label": "Only task deadlines"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "The DPO loss compares policy-to-reference log ratios for the preferred and rejected responses.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "What feedback can KTO learn from?",
        "options": [
          {
            "value": "A",
            "label": "Only complete rankings"
          },
          {
            "value": "B",
            "label": "Desirable or undesirable labels for individual outputs"
          },
          {
            "value": "C",
            "label": "Only next-token labels"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "KTO uses a prospect-theory-inspired objective with binary desirability feedback.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "What does ORPO stand for?",
        "options": [
          {
            "value": "A",
            "label": "Odds Ratio Preference Optimization"
          },
          {
            "value": "B",
            "label": "Odds Ratio Preference Optimization"
          },
          {
            "value": "C",
            "label": "Off-Policy Reinforcement from Preferences and Objectives"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "ORPO combines supervised learning with an odds-ratio preference term and does not require a separate reference model.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "For loss -log sigmoid(d), what is its derivative with respect to d?",
        "options": [
          {
            "value": "A",
            "label": "sigmoid(d)-1"
          },
          {
            "value": "B",
            "label": "sigmoid(d)"
          },
          {
            "value": "C",
            "label": "1"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "Differentiate softplus(-d): its derivative is sigmoid(d)-1.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "Does preference optimization guarantee truthful and safe outputs?",
        "options": [
          {
            "value": "A",
            "label": "Yes for every prompt"
          },
          {
            "value": "B",
            "label": "Only if the model is large"
          },
          {
            "value": "C",
            "label": "No; data, evaluation and deployment context still matter"
          }
        ],
        "answer": [
          "C"
        ],
        "analysis": "Learning from preferences does not prove general reliability.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "reason": "Replace misnamed KTO and ORPO assessment.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_college.json",
    "path": "scenes[9].content.questions[2].options[1].label",
    "before": "Optimized Rank Probability Objective",
    "after": "Odds Ratio Preference Optimization",
    "reason": "Correct ORPO expansion.",
    "reference": "https://arxiv.org/abs/2403.07691"
  },
  {
    "file": "16_rlhf-alignment_highschool.json",
    "path": "scenes[6].actions",
    "before": [
      {
        "id": "action_0JEv2OvG",
        "type": "spotlight",
        "elementId": "text_XZJQpHjY"
      },
      {
        "id": "action_9jJZOUNp",
        "type": "speech",
        "text": "Let's start by exploring what KTO and ORPO stand for. These are newer techniques in teaching AI how to learn preferences more effectively."
      },
      {
        "id": "action_4VIRay51",
        "type": "spotlight",
        "elementId": "text_O2k27RRB"
      },
      {
        "id": "action_DN3E9DG-",
        "type": "speech",
        "text": "First, KTO uses ideas from prospect theory, which is all about how people make choices with risks and rewards. It helps AI make smarter decisions by mimicking that kind of thinking."
      },
      {
        "id": "action_cwL3jIRF",
        "type": "spotlight",
        "elementId": "text_O2k27RRB"
      },
      {
        "id": "action_ti11IPvZ",
        "type": "speech",
        "text": "Next, ORPO is a single, more complete method that improves how we optimize preferences, making AI behavior even more reliable and aligned with what we want."
      },
      {
        "id": "action_aUEM3Pky",
        "type": "spotlight",
        "elementId": "text_XZJQpHjY"
      },
      {
        "id": "action_k9Qh01HY",
        "type": "speech",
        "text": "Together, these innovations keep pushing the field of AI alignment forward, making sure AI systems understand and follow the right preferences better than before."
      },
      {
        "id": "action_uL1CS29Y",
        "type": "speech",
        "text": "So, in summary, KTO borrows ideas from how humans think about risks, ORPO simplifies preference optimization into one powerful method, and both help build stronger AI that aligns with human values."
      }
    ],
    "after": [
      {
        "id": "review-6-0",
        "type": "speech",
        "text": "KTO means Kahneman-Tversky Optimization. It uses a prospect-theory-inspired objective and can learn from individual outputs labeled desirable or undesirable."
      },
      {
        "id": "review-6-1",
        "type": "speech",
        "text": "It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best."
      }
    ],
    "reason": "Correct alignment algorithm definitions.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_highschool.json",
    "path": "scenes[6].content",
    "before": {
      "type": "slide",
      "canvas": {
        "id": "Lqfrf9nEcr8W8nRKktBQr",
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "theme": {
          "backgroundColor": "#ffffff",
          "themeColors": [
            "#5b9bd5",
            "#ed7d31",
            "#a5a5a5",
            "#ffc000",
            "#4472c4"
          ],
          "fontColor": "#333333",
          "fontName": "Microsoft YaHei",
          "outline": {
            "color": "#d14424",
            "width": 2,
            "style": "solid"
          },
          "shadow": {
            "h": 0,
            "v": 0,
            "blur": 10,
            "color": "#000000"
          }
        },
        "elements": [
          {
            "id": "text_XZJQpHjY",
            "type": "text",
            "left": 60,
            "top": 50,
            "width": 880,
            "height": 76,
            "content": "<p style=\"font-size:32px;\"><strong>What are KTO and ORPO?</strong></p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#333333",
            "rotate": 0
          },
          {
            "id": "shape_im-32ogk",
            "type": "shape",
            "left": 60,
            "top": 150,
            "width": 880,
            "height": 230,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#f0f6ff",
            "fixedRatio": false,
            "rotate": 0
          },
          {
            "id": "text_O2k27RRB",
            "type": "text",
            "left": 80,
            "top": 180,
            "width": 840,
            "height": 130,
            "content": "<p style=\"font-size:18px;\">• <strong>KTO</strong>: Uses ideas from prospect theory to guide AI choices</p><p style=\"font-size:18px;\">• <strong>ORPO</strong>: A single, powerful method for better preference learning</p><p style=\"font-size:18px;\">• Together, they make AI alignment stronger and smarter</p>",
            "defaultFontName": "Microsoft YaHei",
            "defaultColor": "#1f2937",
            "rotate": 0
          },
          {
            "id": "shape_xySS9rQo",
            "type": "shape",
            "left": 70,
            "top": 126,
            "width": 860,
            "height": 4,
            "path": "M 0 0 L 1 0 L 1 1 L 0 1 Z",
            "viewBox": [
              1,
              1
            ],
            "fill": "#3b82f6",
            "fixedRatio": false,
            "rotate": 0
          }
        ],
        "background": {
          "type": "solid",
          "color": "#ffffff"
        }
      }
    },
    "after": {
      "type": "slide",
      "canvas": {
        "viewportSize": 1000,
        "viewportRatio": 0.5625,
        "elements": [
          {
            "id": "review-title-6",
            "type": "text",
            "left": 50,
            "top": 35,
            "width": 900,
            "height": 65,
            "content": "<h2>What are KTO and ORPO?</h2>"
          },
          {
            "id": "review-text-6-0",
            "type": "text",
            "left": 50,
            "top": 115,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">KTO means Kahneman-Tversky Optimization. It uses a prospect-theory-inspired objective and can learn from individual outputs labeled desirable or undesirable.</p>"
          },
          {
            "id": "review-text-6-1",
            "type": "text",
            "left": 50,
            "top": 285,
            "width": 900,
            "height": 155,
            "content": "<p style=\"font-size:23px\">It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.</p>"
          }
        ]
      }
    },
    "reason": "Correct alignment algorithm definitions.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_highschool.json",
    "path": "scenes[6].actions[1].text",
    "before": "It is not Kendall Tau Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.",
    "after": "It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.",
    "reason": "Correct KTO expansion.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_highschool.json",
    "path": "scenes[6].content.canvas.elements[2].content",
    "before": "<p style=\"font-size:23px\">It is not Kendall Tau Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.</p>",
    "after": "<p style=\"font-size:23px\">It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best.</p>",
    "reason": "Correct KTO expansion.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "16_rlhf-alignment_highschool.json",
    "path": "scenes[8].content.questions",
    "before": [
      {
        "id": "q1",
        "type": "single",
        "question": "What is the main goal of Reinforcement Learning from Human Feedback (RLHF)?",
        "options": [
          {
            "value": "A",
            "label": "To train AI by letting it learn from human preferences and corrections"
          },
          {
            "value": "B",
            "label": "To allow AI to create its own goals without human input"
          },
          {
            "value": "C",
            "label": "To replace humans in decision-making completely"
          },
          {
            "value": "D",
            "label": "To teach AI how to store large amounts of data"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "RLHF is about training AI by using feedback from humans to guide the model's behavior, like how a game teaches players through hints and corrections. Options B, C, and D misunderstand the human-centered feedback aspect.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "What does Direct Preference Optimization (DPO) do differently from traditional RLHF?",
        "options": [
          {
            "value": "A",
            "label": "It directly optimizes AI to prefer actions humans like without complex reward models"
          },
          {
            "value": "B",
            "label": "It ignores human preferences completely"
          },
          {
            "value": "C",
            "label": "It uses a complicated game controller to teach AI"
          },
          {
            "value": "D",
            "label": "It trains AI only on random feedback data"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "DPO simplifies training by directly using human preferences rather than building complicated reward signals. Options B, C, and D are incorrect as they misrepresent this direct and preference-focused approach.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "What does Kullback-Leibler (KL) Target Optimization help achieve in AI alignment?",
        "options": [
          {
            "value": "A",
            "label": "It balances AI’s learned policy with a safe reference policy to avoid risky behaviors"
          },
          {
            "value": "B",
            "label": "It increases randomness in AI decisions to confuse users"
          },
          {
            "value": "C",
            "label": "It deletes all data that AI learns"
          },
          {
            "value": "D",
            "label": "It makes AI only answer with one word responses"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "KL Target Optimization ensures AI behaviors stay close to a trusted baseline, reducing risks. Other options are silly or incorrect, ignoring the concept of balancing policies.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "Why is Off-Policy Reinforcement Learning from Preferences and Objectives (ORPO) useful?",
        "options": [
          {
            "value": "A",
            "label": "It can learn from past experiences and multiple objectives without needing fresh data every time"
          },
          {
            "value": "B",
            "label": "It forces AI to forget old lessons and start fresh each time"
          },
          {
            "value": "C",
            "label": "It deletes human preferences after training"
          },
          {
            "value": "D",
            "label": "It makes AI guess without any feedback"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "ORPO improves efficiency by reusing past data and handling multiple goals, like playing a game replay to learn better. Other options misunderstand its purpose or suggest risky AI behavior.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "In simple terms, why do AI researchers care about alignment methods like RLHF, DPO, KTO, and ORPO?",
        "options": [
          {
            "value": "A",
            "label": "To make sure AI behaves the way humans want and avoid unexpected or harmful outcomes"
          },
          {
            "value": "B",
            "label": "To make AI smarter at ignoring human commands"
          },
          {
            "value": "C",
            "label": "To build AI that talks only in memes and emojis"
          },
          {
            "value": "D",
            "label": "To teach AI how to win video games faster than humans"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "The main focus of alignment is ensuring AI actions match human values and safety needs. Options B, C, and D are funny but miss the core purpose of alignment research.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "after": [
      {
        "id": "q1",
        "type": "single",
        "question": "What information does standard DPO use?",
        "options": [
          {
            "value": "A",
            "label": "Chosen/rejected pairs and reference-policy log probabilities"
          },
          {
            "value": "B",
            "label": "Only a Kendall rank statistic"
          },
          {
            "value": "C",
            "label": "Only task deadlines"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "The DPO loss compares policy-to-reference log ratios for the preferred and rejected responses.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "What feedback can KTO learn from?",
        "options": [
          {
            "value": "A",
            "label": "Only complete rankings"
          },
          {
            "value": "B",
            "label": "Desirable or undesirable labels for individual outputs"
          },
          {
            "value": "C",
            "label": "Only next-token labels"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "KTO uses a prospect-theory-inspired objective with binary desirability feedback.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "What does ORPO stand for?",
        "options": [
          {
            "value": "A",
            "label": "Odds Ratio Preference Optimization"
          },
          {
            "value": "B",
            "label": "Odds Ratio Preference Optimization"
          },
          {
            "value": "C",
            "label": "Off-Policy Reinforcement from Preferences and Objectives"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "ORPO combines supervised learning with an odds-ratio preference term and does not require a separate reference model.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "For loss -log sigmoid(d), what is its derivative with respect to d?",
        "options": [
          {
            "value": "A",
            "label": "sigmoid(d)-1"
          },
          {
            "value": "B",
            "label": "sigmoid(d)"
          },
          {
            "value": "C",
            "label": "1"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "Differentiate softplus(-d): its derivative is sigmoid(d)-1.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "Does preference optimization guarantee truthful and safe outputs?",
        "options": [
          {
            "value": "A",
            "label": "Yes for every prompt"
          },
          {
            "value": "B",
            "label": "Only if the model is large"
          },
          {
            "value": "C",
            "label": "No; data, evaluation and deployment context still matter"
          }
        ],
        "answer": [
          "C"
        ],
        "analysis": "Learning from preferences does not prove general reliability.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "reason": "Replace misnamed KTO and ORPO assessment.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "18_peft-lora_college.json",
    "path": "scenes[3].elements[10].latex",
    "before": "\\frac{\\partial L}{\\partial B} = \\frac{\\partial L}{\\partial Y} A, \\quad \\frac{\\partial L}{\\partial A} = B^{T} \\frac{\\partial L}{\\partial Y}",
    "after": "Y=W_0X+(\\alpha/r)BAX;\\quad G_B=(\\alpha/r)G_Y(AX)^\\top;\\quad G_A=(\\alpha/r)B^\\top G_YX^\\top",
    "reason": "LoRA factor gradients need X, transposes, and the chosen scaling.",
    "reference": "https://arxiv.org/abs/2106.09685"
  },
  {
    "file": "21_token-pipeline_college.json",
    "path": "scenes[1].elements[3].latex",
    "before": "f(ab) = f(a,b) + \\sum_{x} f((a,b), x) \\quad \\to \\quad f'(s) = f(s) - f((a,b)) + f(ab)",
    "after": "(a,b)=\\arg\\max_{(u,v)}\\operatorname{count}(u,v);\\quad (a,b)\\mapsto ab\\ ;\\ \\text{recount adjacent pairs}",
    "reason": "BPE merge counts must be recomputed on the updated corpus.",
    "reference": "https://github.com/google/sentencepiece"
  },
  {
    "file": "22_qkv-projection_college.json",
    "path": "scenes[2].elements[4].latex",
    "before": "\\nabla_{W_Q} L = \\nabla_{Q} L \\cdot K^{\\mathrm{T}}",
    "after": "\\nabla_{W_Q}L=X^\\top\\nabla_Q L",
    "reason": "Projection gradients use the input X, not K.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "22_qkv-projection_college.json",
    "path": "scenes[2].elements[5].latex",
    "before": "\\nabla_{W_K} L = \\nabla_{K} L \\cdot Q^{\\mathrm{T}}",
    "after": "\\nabla_{W_K}L=X^\\top\\nabla_K L",
    "reason": "Projection gradients use the input X, not Q.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "24_latent-space-explorer_college.json",
    "path": "scenes[1].elements[10].latex",
    "before": "L_{rec} = \\mathbb{E}_{q_{\\phi}(z|x)}[\\log p_{\\theta}(x|z)]",
    "after": "L_{rec}=-\\mathbb E_{q_\\phi(z|x)}\\log p_\\theta(x|z)",
    "reason": "A minimized reconstruction loss is negative log likelihood.",
    "reference": "https://arxiv.org/abs/1312.6114"
  },
  {
    "file": "24_latent-space-explorer_college.json",
    "path": "scenes[1].elements[11].latex",
    "before": "D_{KL}(q_{\\phi}(z|x) \\| p(z)) = \\frac{1}{2} \\sum_{j=1}^d \\big(1 + \\log(\\sigma_j^2) - \\mu_j^2 - \\sigma_j^2 \\big)",
    "after": "D_{KL}(q_\\phi(z|x)\\|\\mathcal N(0,I))=\\tfrac12\\sum_j(\\mu_j^2+\\sigma_j^2-1-\\log\\sigma_j^2)",
    "reason": "The displayed expression had the negative KL sign.",
    "reference": "https://arxiv.org/abs/1312.6114"
  },
  {
    "file": "24_latent-space-explorer_college.json",
    "path": "scenes[4].elements[6].latex",
    "before": "p_\\theta(x_{t-1}|x_t, y) \\propto \\exp\\left(-\\| \\epsilon_\\theta(x_t,t,y) - \\epsilon_t \\|^2\\right) \\quad \\text{with} \\quad y = \\text{conditioning}",
    "after": "L_{noise}=\\mathbb E\\|\\epsilon-\\epsilon_\\theta(x_t,t,y)\\|^2",
    "reason": "A noise-prediction training objective is not the normalized reverse transition density.",
    "reference": "https://arxiv.org/abs/2006.11239"
  },
  {
    "file": "26v_ai-film-studios_college.json",
    "path": "scenes[2].elements[5].latex",
    "before": "\\text{Latent Diffusion: } z_t = \\sqrt{\\bar{\\alpha_t}} z_0 + \\sqrt{1 - \\bar{\\alpha_t}} \\epsilon_\\theta(z_t, t)",
    "after": "z_t=\\sqrt{\\bar\\alpha_t}z_0+\\sqrt{1-\\bar\\alpha_t}\\epsilon,\\quad\\epsilon\\sim\\mathcal N(0,I)",
    "reason": "Forward corruption uses sampled noise, not predicted noise.",
    "reference": "https://arxiv.org/abs/2006.11239"
  },
  {
    "file": "f-audio-sync_audio-sync_college.json",
    "path": "scenes[5].elements[4].latex",
    "before": "E(t) = |x(t)|^2, \\quad beat \\iff E(t) \\text{ local max}",
    "after": "E(t)=|x(t)|^2;\\quad\\text{energy peaks can suggest onsets, not determine musical beats}",
    "reason": "Beat tracking requires temporal/rhythmic inference beyond a local energy maximum.",
    "reference": "https://librosa.org/doc/latest/generated/librosa.beat.beat_track.html"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[4].elements[4].latex",
    "before": "\\text{Cross-Attention: } \\quad \\mathbf{H}_t = \\mathrm{softmax}\\left(\\frac{\\mathbf{Q}_t \\mathbf{K}_v^\\top}{\\sqrt{d}}\\right) \\mathbf{V}_v + \\mathrm{softmax}\\left(\\frac{\\mathbf{Q}_v \\mathbf{K}_t^\\top}{\\sqrt{d}}\\right) \\mathbf{V}_t",
    "after": "H_t=\\operatorname{softmax}(Q_tK_v^\\top/\\sqrt d)V_v;\\quad H_v=\\operatorname{softmax}(Q_vK_t^\\top/\\sqrt d)V_t",
    "reason": "Text and image output lengths can differ; do not add these tensors directly.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[5].title",
    "before": "ERNE-Image Architecture",
    "after": "ERNIE-Image Architecture",
    "reason": "Correct model spelling.",
    "reference": "https://github.com/baidu/ERNIE-Image"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[5].actions[1].text",
    "before": "Consider the ERNE-Image architecture: a diffusion-based image synthesis system that couples a large diffusion transformer backbone with reasoning-driven prompt rewriting and a text-rendering pipeline aimed at dense technical labels.",
    "after": "Consider the ERNIE-Image architecture: a diffusion-based image synthesis system that couples a large diffusion transformer backbone with reasoning-driven prompt rewriting and a text-rendering pipeline aimed at dense technical labels.",
    "reason": "Correct model spelling.",
    "reference": "https://github.com/baidu/ERNIE-Image"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[5].actions[12].text",
    "before": "In sum, ERNE-Image shows that scaling a unified diffusion transformer, reasoning over prompts, and distilling the sampler are complementary levers for reliable synthesis from complex, text-heavy technical prompts.",
    "after": "In sum, ERNIE-Image shows that scaling a unified diffusion transformer, reasoning over prompts, and distilling the sampler are complementary levers for reliable synthesis from complex, text-heavy technical prompts.",
    "reason": "Correct model spelling.",
    "reference": "https://github.com/baidu/ERNIE-Image"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[5].content.canvas.elements[0].content",
    "before": "<p style=\"font-size:32px;\"><strong>ERNE-Image: Unified Diffusion Transformer Architecture</strong></p>",
    "after": "<p style=\"font-size:32px;\"><strong>ERNIE-Image: Unified Diffusion Transformer Architecture</strong></p>",
    "reason": "Correct model spelling.",
    "reference": "https://github.com/baidu/ERNIE-Image"
  },
  {
    "file": "f-stt_stt-whisper_college.json",
    "path": "scenes[3].elements[5].latex",
    "before": "\\nabla \\theta = - \\eta \\frac{\\partial L}{\\partial \\theta}",
    "after": "\\theta_{new}=\\theta-\\eta\\nabla_\\theta L",
    "reason": "Distinguish a parameter update from a gradient.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
  },
  {
    "file": "f-stt_stt-whisper_college.json",
    "path": "scenes[7].elements[12].latex",
    "before": "\\text{Throughput} \\propto \\frac{1}{\\text{Latency}} = \\frac{\\text{CTranslate2 Speed}\\times \\text{Batch Size}}{\\text{Model Size}}",
    "after": "\\text{throughput}=\\frac{\\text{completed audio seconds}}{\\text{wall-clock seconds}}",
    "reason": "Model size and engine speed do not define a universal latency identity.",
    "reference": "https://github.com/SYSTRAN/faster-whisper"
  },
  {
    "file": "f-voice-clone_voice-cloning_college.json",
    "path": "scenes[6].elements[13].latex",
    "before": "L = \\frac{1}{N} \\sum_{i=1}^N \\|\\hat{Y}_i - Y_i\\|^2 + \\lambda \\sum_{j=1}^M \\max\\left(0, m - d(E_j, E_j^+) + d(E_j, E_j^-)\\right)",
    "after": "L=L_{rec}+\\lambda\\sum_j\\max(0,m+d(E_j,E_j^+)-d(E_j,E_j^-))",
    "reason": "Triplet loss should penalize positives farther than negatives.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.TripletMarginLoss.html"
  },
  {
    "file": "f-voice-clone_voice-cloning_college.json",
    "path": "scenes[9].elements[6].latex",
    "before": "\\nabla_\\theta \\mathcal{L}(\\theta) = \\sum_{t=1}^T \\bigl(f_\\theta(\\mathbf{x}_{\\leq t}) - \\mathbf{y}_t\\bigr) \\nabla_\\theta f_\\theta (\\mathbf{x}_{\\leq t}) + \\lambda \\nabla_\\theta \\mathcal{R}(\\theta)",
    "after": "\\nabla_\\theta L=2\\sum_t J_{f_t}(\\theta)^\\top(f_t-y_t)+\\lambda\\nabla_\\theta R",
    "reason": "An unhalved squared error needs a factor of two.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
  },
  {
    "file": "03_rlhf-reasoning_college.json",
    "path": "scenes[7].elements[3].latex",
    "before": "\\text{GRPO Objective: }\\quad \\min_{\\theta} \\mathbb{E}_{\\pi_\\theta}[r(s,a)] + \\lambda \\, \\mathbb{E}_{\\pi_{\\theta_{old}}}\\big[\\|\\nabla_\\theta \\log \\pi_\\theta(a|s) - \\nabla_\\theta \\log \\pi_{\\theta_{old}}(a|s)\\|^2\\big]",
    "after": "A_i=(r_i-\\bar r)/(\\operatorname{std}(r)+\\epsilon);\\quad J=\\mathbb E[\\min(\\rho_i A_i,\\operatorname{clip}(\\rho_i,1-\\epsilon_c,1+\\epsilon_c)A_i)-\\beta D_{KL}(\\pi_\\theta\\|\\pi_{ref})]",
    "reason": "Replace non-GRPO objective with an explicitly simplified clipped group-relative objective.",
    "reference": "https://arxiv.org/html/2402.03300v3"
  },
  {
    "file": "06_cbow-skipgram_college.json",
    "path": "scenes[3].actions",
    "before": [
      {
        "id": "action_43BFrdTN",
        "type": "spotlight",
        "elementId": "text_4qlcMSZy"
      },
      {
        "id": "action_dgvfzrpV",
        "type": "speech",
        "text": "Now we derive the gradients for the continuous bag-of-words model. These derivations are the mechanism by which backpropagation shapes the embedding space: every semantic regularity in word2vec is a consequence of this update rule applied at scale."
      },
      {
        "id": "action_tAXjskqd",
        "type": "spotlight",
        "elementId": "text_HXB-LXZM"
      },
      {
        "id": "action_cy8dY3AX",
        "type": "speech",
        "text": "We begin with the gradient of the loss with respect to the logits and the output weight matrix. The softmax minus one-hot error term tells us exactly how each prediction deviates from the target, and the chain rule routes that signal back to the parameters."
      },
      {
        "id": "action_hQsHrP-X",
        "type": "spotlight",
        "elementId": "latex_jhwnAZjA"
      },
      {
        "id": "action_b2uZg7JA",
        "type": "speech",
        "text": "The objective is the negative log likelihood of the center word given its context: L equals minus log of p of w-t conditioned on the surrounding window, where p is the softmax over the inner products of the context vector with every output embedding."
      },
      {
        "id": "action_rCHozdah",
        "type": "spotlight",
        "elementId": "latex_haM8VtEz"
      },
      {
        "id": "action_CJI-xyM9",
        "type": "speech",
        "text": "Applying the chain rule in matrix form, the gradient with respect to the output matrix W is the prediction error, y-hat minus the one-hot target, outer-producted with the averaged context embedding. This rank-one update is what makes training tractable."
      },
      {
        "id": "action_u1SDLlEn",
        "type": "spotlight",
        "elementId": "text_HXB-LXZM"
      },
      {
        "id": "action_-djgVjsn",
        "type": "speech",
        "text": "The same error signal backpropagates to the input embeddings: each context vector receives a gradient proportional to W transpose times the error, divided by the window size. Repeated over millions of windows, these updates pull co-occurring words together in the embedding space."
      },
      {
        "id": "action_6XwuT8HY",
        "type": "speech",
        "text": "In short, the CBOW gradients are a rank-one correction driven by the softmax error term, and they are the entire engine of representation learning here. Hold onto this derivation, because negative sampling and skip-gram reuse exactly the same structure."
      }
    ],
    "after": [
      {
        "id": "review-3-0",
        "type": "speech",
        "text": "For softmax followed by cross entropy, the derivative with respect to each logit is predicted probability minus target probability. The derivative with respect to a probability is different: negative target divided by prediction."
      },
      {
        "id": "review-3-1",
        "type": "speech",
        "text": "For a linear classifier z equals W h, the weight gradient is the outer product of the logit gradient and h. Backpropagate through the context average to the contributing embedding rows."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
  },
  {
    "file": "11_next-token-emergence_college.json",
    "path": "scenes[7].questions[0]",
    "before": {
      "id": "q1",
      "type": "single",
      "question": "Which of the following best characterizes emergent capabilities in large-scale language models?",
      "options": [
        {
          "value": "A",
          "label": "They arise smoothly and predictably as model size increases"
        },
        {
          "value": "B",
          "label": "They manifest abruptly and cannot be linearly extrapolated from smaller models"
        },
        {
          "value": "C",
          "label": "They are always explicitly programmed into the model architecture"
        },
        {
          "value": "D",
          "label": "They depend solely on the amount of training data and not the model's structure"
        }
      ],
      "answer": [
        "B"
      ],
      "analysis": "Emergent capabilities refer to abilities that appear suddenly and are not linearly predictable from smaller scale models; they are not explicitly programmed but arise from complex interactions within large-scale models. Thus, option B correctly captures this behavior, whereas options A, C, and D misunderstand the nature of emergence.",
      "points": 12,
      "hasAnswer": true
    },
    "after": {
      "id": "q1",
      "type": "single",
      "question": "Why should an abrupt jump in a benchmark score be interpreted carefully?",
      "options": [
        {
          "value": "A",
          "label": "It proves that the model suddenly became conscious"
        },
        {
          "value": "B",
          "label": "The metric and threshold can make gradual improvements appear abrupt"
        },
        {
          "value": "C",
          "label": "Every model acquires every skill at the same size"
        }
      ],
      "answer": [
        "B"
      ],
      "analysis": "Compare continuous and thresholded metrics, datasets and uncertainty before claiming a sharp capability transition.",
      "points": 10,
      "hasAnswer": true
    },
    "reason": "Remove unconditional emergence claim.",
    "reference": "https://arxiv.org/abs/2304.15004"
  },
  {
    "file": "11_next-token-emergence_highschool.json",
    "path": "scenes[6].questions[1]",
    "before": {
      "id": "q2",
      "type": "multiple",
      "question": "Which of the following are examples of emergent capabilities in AI models? (Select all that apply)",
      "options": [
        {
          "value": "A",
          "label": "Understanding jokes and puns"
        },
        {
          "value": "B",
          "label": "Solving new types of math problems without explicit training"
        },
        {
          "value": "C",
          "label": "Automatically backing up data to the cloud"
        },
        {
          "value": "D",
          "label": "Learning to swim by watching others"
        }
      ],
      "answer": [
        "A",
        "B"
      ],
      "analysis": "Emergent capabilities are new skills that appear unexpectedly as the AI model grows bigger or better trained. Understanding jokes and solving new problems are examples of this. Option C is a computer feature unrelated to AI learning, and option D is about a living being, not AI.",
      "points": 15,
      "hasAnswer": true
    },
    "after": {
      "id": "q2",
      "type": "single",
      "question": "Why should an abrupt jump in a benchmark score be interpreted carefully?",
      "options": [
        {
          "value": "A",
          "label": "It proves that the model suddenly became conscious"
        },
        {
          "value": "B",
          "label": "The metric and threshold can make gradual improvements appear abrupt"
        },
        {
          "value": "C",
          "label": "Every model acquires every skill at the same size"
        }
      ],
      "answer": [
        "B"
      ],
      "analysis": "Compare continuous and thresholded metrics, datasets and uncertainty before claiming a sharp capability transition.",
      "points": 10,
      "hasAnswer": true
    },
    "reason": "Remove unconditional emergence claim.",
    "reference": "https://arxiv.org/abs/2304.15004"
  },
  {
    "file": "11_next-token-emergence_highschool.json",
    "path": "scenes[6].questions[3]",
    "before": {
      "id": "q4",
      "type": "multiple",
      "question": "Why might bigger language models have abilities that smaller ones don't? (Select all that apply)",
      "options": [
        {
          "value": "A",
          "label": "Bigger models have more parameters to store complex patterns"
        },
        {
          "value": "B",
          "label": "They are trained using more data, so they see more examples"
        },
        {
          "value": "C",
          "label": "They run faster on older computers"
        },
        {
          "value": "D",
          "label": "Bigger models have emergent traits that appear only after reaching a certain size"
        }
      ],
      "answer": [
        "A",
        "B",
        "D"
      ],
      "analysis": "Bigger models can store more information and see more data during training, which helps them learn complex patterns and abilities. Some capabilities just appear once the model passes a certain size, called emergent abilities. Speed on old computers (C) is unrelated.",
      "points": 15,
      "hasAnswer": true
    },
    "after": {
      "id": "q4",
      "type": "single",
      "question": "Why should an abrupt jump in a benchmark score be interpreted carefully?",
      "options": [
        {
          "value": "A",
          "label": "It proves that the model suddenly became conscious"
        },
        {
          "value": "B",
          "label": "The metric and threshold can make gradual improvements appear abrupt"
        },
        {
          "value": "C",
          "label": "Every model acquires every skill at the same size"
        }
      ],
      "answer": [
        "B"
      ],
      "analysis": "Compare continuous and thresholded metrics, datasets and uncertainty before claiming a sharp capability transition.",
      "points": 10,
      "hasAnswer": true
    },
    "reason": "Remove unconditional emergence claim.",
    "reference": "https://arxiv.org/abs/2304.15004"
  },
  {
    "file": "12_attention-mechanism_college.json",
    "path": "scenes[8].actions[5].text",
    "before": "The mask is added to the logits before softmax, setting disallowed pairs to minus infinity, so attention normalizes over a subquadratic set of edges.",
    "after": "Add zero for allowed pairs and negative infinity for excluded pairs before softmax. A causal mask alone still has quadratically many allowed pairs.",
    "reason": "Correct an overgeneralization or inconsistent explanation.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "16_rlhf-alignment_highschool.json",
    "path": "scenes[6].actions",
    "before": [
      {
        "id": "review-6-0",
        "type": "speech",
        "text": "KTO means Kahneman-Tversky Optimization. It uses a prospect-theory-inspired objective and can learn from individual outputs labeled desirable or undesirable."
      },
      {
        "id": "review-6-1",
        "type": "speech",
        "text": "It is not Kahneman-Tversky Optimization or KL Target Optimization. The choice of feedback and objective matters; no method is universally best."
      }
    ],
    "after": [
      {
        "id": "review-6-0",
        "type": "speech",
        "text": "KTO means Kahneman-Tversky Optimization. It can learn from individual outputs marked desirable or undesirable using a prospect-theory-inspired objective."
      },
      {
        "id": "review-6-1",
        "type": "speech",
        "text": "ORPO means Odds Ratio Preference Optimization. It combines supervised learning and preference optimization without a separate reference model. Neither name refers to task ordering or Kendall rank correlation."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://arxiv.org/abs/2402.01306"
  },
  {
    "file": "17_llm-highway_college.json",
    "path": "scenes[2].actions",
    "before": [
      {
        "id": "action_7ChxYpXg",
        "type": "spotlight",
        "elementId": "text_qbgyScMz"
      },
      {
        "id": "action_7y8oRf6k",
        "type": "speech",
        "text": "Today we optimize autoregressive decoding with the KV cache, the standard trick for eliminating redundant computation in transformer inference."
      },
      {
        "id": "action_0e3r_2Dz",
        "type": "spotlight",
        "elementId": "text_8yxmHp1G"
      },
      {
        "id": "action_SmtyRM2t",
        "type": "speech",
        "text": "Consider naïve generation: at every decoding step, the model recomputes key and value projections for the entire prefix, even though those representations never change under causal masking."
      },
      {
        "id": "action_YyGKR9I2",
        "type": "spotlight",
        "elementId": "text_OIqJQGR7"
      },
      {
        "id": "action_lZnATT1c",
        "type": "speech",
        "text": "Concretely, each new token recomputes the query-key dot products over the full sequence, so generating N tokens costs order N squared times d total FLOPs."
      },
      {
        "id": "action_mCk6fdDS",
        "type": "spotlight",
        "elementId": "text_l9jUvVWU"
      },
      {
        "id": "action_KTvmDBVo",
        "type": "speech",
        "text": "The KV cache removes this waste by storing the key and value tensors of all previous positions; since causal attention never lets earlier tokens attend to later ones, these tensors are fixed."
      },
      {
        "id": "action_xMN6RdND",
        "type": "spotlight",
        "elementId": "text_DVvShGQn"
      },
      {
        "id": "action_MTCYuFqm",
        "type": "speech",
        "text": "Each step then computes only the new token's query, key, and value, attending against the cached entries: a single row of the attention matrix instead of the whole thing."
      },
      {
        "id": "action_EiqxP3CX",
        "type": "spotlight",
        "elementId": "text_zASrds7d"
      },
      {
        "id": "action_N-yFz3Gd",
        "type": "speech",
        "text": "The complexity impact: per-step attention cost drops from order t times d to exactly t dot products of dimension d, and total generation cost falls from order N squared to order N times d for the attention reads."
      },
      {
        "id": "action_pRilcBZD",
        "type": "spotlight",
        "elementId": "latex_yvR7kD5V"
      },
      {
        "id": "action_K_CAKA9Q",
        "type": "speech",
        "text": "Formally, naïve decoding time grows quadratically in N because step t re-derives all t key-value pairs, summing to N squared over two projections."
      },
      {
        "id": "action_bbQ8rZDe",
        "type": "spotlight",
        "elementId": "latex_29xcagHZ"
      },
      {
        "id": "action_ApKP1tmQ",
        "type": "speech",
        "text": "With caching, step t performs one projection and t cached reads, so total time scales linearly in N; the tradeoff is memory, since the cache grows as N times d times layers."
      },
      {
        "id": "action_Gj1LFKiy",
        "type": "spotlight",
        "elementId": "text_0IKZhVtg"
      },
      {
        "id": "action_2b3n9Bbr",
        "type": "speech",
        "text": "This is why long-context serving is memory-bandwidth bound, motivating multi-query and grouped-query attention, which shrink the cache by sharing keys and values across heads."
      }
    ],
    "after": [
      {
        "id": "review-2-0",
        "type": "speech",
        "text": "Caching keys and values avoids projecting the entire prefix again for every generated token. It does not make dense attention constant-time per token. Each new query still compares against a growing set of cached keys."
      },
      {
        "id": "review-2-1",
        "type": "speech",
        "text": "For fixed width and layers, cache storage grows linearly with context length. Total dense attention work over N generated positions remains quadratic in N. Prefill, projection work and decode attention are different costs."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://huggingface.co/docs/transformers/en/cache_explanation"
  },
  {
    "file": "17_llm-highway_highschool.json",
    "path": "scenes[2].actions",
    "before": [
      {
        "id": "action_HabRd9uG",
        "type": "spotlight",
        "elementId": "text_wpreVroF"
      },
      {
        "id": "action_p4TXhe1i",
        "type": "speech",
        "text": "Let's dive into the KV Cache, a smart shortcut that speeds up how computers process words when they try to understand or generate language."
      },
      {
        "id": "action_qXkjQZdE",
        "type": "spotlight",
        "elementId": "text_hhfJbDgh"
      },
      {
        "id": "action_a6DORrDe",
        "type": "speech",
        "text": "First, what is the KV Cache? Think of it like a special memory that stores information about words we’ve already processed so the computer doesn't have to start from scratch each time."
      },
      {
        "id": "action_1xi2DSJl",
        "type": "spotlight",
        "elementId": "text_aq4c1x2j"
      },
      {
        "id": "action_MCIn2_5S",
        "type": "speech",
        "text": "This means it avoids repeating the same calculations again and again by reusing earlier results, which saves a lot of time and effort."
      },
      {
        "id": "action_cJkolDMZ",
        "type": "spotlight",
        "elementId": "text_VfKdLNAF"
      },
      {
        "id": "action_-vqT2uSl",
        "type": "speech",
        "text": "Imagine it as taking a shortcut on your route home—once you know the quicker path, you use it to get there faster instead of wandering all over the place."
      },
      {
        "id": "action_gaEprohc",
        "type": "spotlight",
        "elementId": "shape_V_Kj5zk4"
      },
      {
        "id": "action_ddHusBoX",
        "type": "speech",
        "text": "Here, the shapes on the slide represent how data flows through this shortcut, helping the system skip unnecessary steps and speed up its work."
      },
      {
        "id": "action_n5YRae48",
        "type": "speech",
        "text": "So in summary, KV Cache is like a helpful memory boost that makes language understanding much quicker by remembering past calculations and avoiding extra work."
      }
    ],
    "after": [
      {
        "id": "review-2-0",
        "type": "speech",
        "text": "Caching keys and values avoids projecting the entire prefix again for every generated token. It does not make dense attention constant-time per token. Each new query still compares against a growing set of cached keys."
      },
      {
        "id": "review-2-1",
        "type": "speech",
        "text": "For fixed width and layers, cache storage grows linearly with context length. Total dense attention work over N generated positions remains quadratic in N. Prefill, projection work and decode attention are different costs."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://huggingface.co/docs/transformers/en/cache_explanation"
  },
  {
    "file": "18_peft-lora_highschool.json",
    "path": "scenes[5].actions[3].text",
    "before": "First, QLoRA compresses or quantizes models to use less memory. Think of it like squeezing a big suitcase into carry-on size without losing anything important.",
    "after": "First, QLoRA compresses or quantizes models to use less memory. Quantization stores weights with fewer bits and can introduce error; measure the resulting quality.",
    "reason": "Correct an overgeneralization or inconsistent explanation.",
    "reference": "https://arxiv.org/abs/2106.09685"
  },
  {
    "file": "18_peft-lora_highschool.json",
    "path": "scenes[8].actions[5].text",
    "before": "Next, QLoRA uses quantization techniques to speed up training and reduce memory requirements without big losses in accuracy.",
    "after": "Next, QLoRA uses quantization to reduce base-weight storage while training adapters; speed and quality depend on hardware and implementation.",
    "reason": "Correct an overgeneralization or inconsistent explanation.",
    "reference": "https://arxiv.org/abs/2106.09685"
  },
  {
    "file": "20_rag-prompting_college.json",
    "path": "scenes[1].actions[9].text",
    "before": "To summarize: embeddings define the geometry, the contrastive loss shapes that geometry, and exact gradient flow through both modules is what lets retrieval-augmented models learn end to end and generalize.",
    "after": "To summarize: embeddings define the geometry, the contrastive loss shapes that geometry, while discrete top-k selection is not generally differentiable; retriever and generator training must specify how each receives a learning signal.",
    "reason": "Correct an overgeneralization or inconsistent explanation.",
    "reference": "https://arxiv.org/abs/2005.11401"
  },
  {
    "file": "21_token-pipeline_college.json",
    "path": "scenes[3].actions",
    "before": [
      {
        "id": "action_R8yoD-Hy",
        "type": "spotlight",
        "elementId": "text_9RMWm4wd"
      },
      {
        "id": "action_cLBzth-F",
        "type": "speech",
        "text": "Byte level BPE and SentencePiece are two answers to one problem: mapping text into a finite vocabulary while controlling sequence length, coverage, and entropy."
      },
      {
        "id": "action_fHkvuVba",
        "type": "spotlight",
        "elementId": "text_Ia5T0XZw"
      },
      {
        "id": "action_74GBQTiA",
        "type": "speech",
        "text": "Byte level BPE, popularized by GPT two, starts from the two hundred fifty six byte alphabet, so every Unicode string is representable and out of vocabulary items cannot occur; merges then learn frequent byte sequences directly from the corpus."
      },
      {
        "id": "action_hgop-evn",
        "type": "spotlight",
        "elementId": "text_LEWhN-QU"
      },
      {
        "id": "action_qD5dhsWY",
        "type": "speech",
        "text": "SentencePiece, from Kudo and Richardson in twenty eighteen, treats text as a raw stream and scores segmentations with a unigram language model, so pieces compete probabilistically rather than by greedy merge frequency alone."
      },
      {
        "id": "action_Tipljs1W",
        "type": "spotlight",
        "elementId": "latex_PVmRx8Cp"
      },
      {
        "id": "action_LcXfpJ5k",
        "type": "speech",
        "text": "For byte level BPE, the objective is compression: repeatedly merge the adjacent pair with highest count, raising likelihood indirectly by shortening tokenized sequences and lowering model entropy."
      },
      {
        "id": "action_sSUEVHI-",
        "type": "spotlight",
        "elementId": "latex_S01tZFmZ"
      },
      {
        "id": "action_uftS0YdQ",
        "type": "speech",
        "text": "SentencePiece uses Expectation Maximization: estimate piece probabilities, resegment the corpus, prune low likelihood units, and repeat until convergence."
      },
      {
        "id": "action_QKDDbiZV",
        "type": "spotlight",
        "elementId": "text_M6INPL4d"
      },
      {
        "id": "action_2LGdNaB-",
        "type": "speech",
        "text": "At scale the trade off is fertility versus expressivity: byte level BPE is simple, fast, and robust, but can fragment rare scripts; SentencePiece smooths distributions and enables sampling regularization, at extra training cost."
      },
      {
        "id": "action_0CzY_ZgK",
        "type": "spotlight",
        "elementId": "text_C8b59nlt"
      },
      {
        "id": "action_MmPAiMCZ",
        "type": "speech",
        "text": "The summary is not that one tokenizer wins; vocabulary size, compression rate, language coverage, and downstream cross entropy must be ablated jointly with model scale and data mixture."
      },
      {
        "id": "action_zx0K2LfO",
        "type": "speech",
        "text": "Choose the tokenizer as part of the model: measure bits per byte, token fertility, robustness to noise, and final loss, because preprocessing is an inductive bias, not a detail."
      }
    ],
    "after": [
      {
        "id": "review-3-0",
        "type": "speech",
        "text": "Byte-level BPE starts with a byte alphabet and learns pair merges. SentencePiece is a tokenizer framework offering BPE and unigram models; it is not synonymous with the unigram algorithm."
      },
      {
        "id": "review-3-1",
        "type": "speech",
        "text": "Unigram segmentation uses a probabilistic model. SentencePiece can train directly on raw sentences, represents whitespace explicitly, and may normalize text; exact round trips depend on normalization and byte-fallback settings."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://github.com/google/sentencepiece"
  },
  {
    "file": "21_token-pipeline_college.json",
    "path": "scenes[6].actions[10].text",
    "before": "The takeaway: tokenization is a compute allocation decision, not a preprocessing afterthought. Under Chinchilla-style compute-optimal training, the tokenizer that maximizes bytes per token at fixed vocabulary cost wins.",
    "after": "The takeaway: tokenization is a compute allocation decision, not a preprocessing afterthought. Tokenizer choice requires measuring compression, coverage, downstream quality and compute together.",
    "reason": "Correct an overgeneralization or inconsistent explanation.",
    "reference": "https://arxiv.org/abs/2203.15556"
  },
  {
    "file": "21_token-pipeline_highschool.json",
    "path": "scenes[2].actions",
    "before": [
      {
        "id": "action_nbMm2Ycf",
        "type": "spotlight",
        "elementId": "text_P9AH_vZA"
      },
      {
        "id": "action_8LhQFex5",
        "type": "speech",
        "text": "Let's dive into two important techniques in language processing: Byte-Level BPE and SentencePiece. These methods help computers break down words into smaller pieces so they can understand and generate text better."
      },
      {
        "id": "action_L4XZ5Y7B",
        "type": "spotlight",
        "elementId": "text_UjN9UTRG"
      },
      {
        "id": "action_z6Rut8yY",
        "type": "speech",
        "text": "First, Byte-level BPE works directly on raw bytes. This means it doesn't rely on knowing the language or spaces between words. It can handle any language because it breaks down text to the smallest electronic building blocks."
      },
      {
        "id": "action_HHWbdorb",
        "type": "spotlight",
        "elementId": "text_c37jp2rk"
      },
      {
        "id": "action_j4T3TbC3",
        "type": "speech",
        "text": "Now, to understand these chunks, think of Lego blocks of different sizes snapping together to build words. SentencePiece builds tokens this way, without needing spaces, which is super useful when the language is unknown or when words run together."
      },
      {
        "id": "action_iaimjPy4",
        "type": "spotlight",
        "elementId": "text_P9AH_vZA"
      },
      {
        "id": "action_prt76LKH",
        "type": "speech",
        "text": "So, Byte-Level BPE focuses on the smallest raw parts of text, while SentencePiece creates a neat, space-free way to split words into meaningful pieces, even if the language is unfamiliar."
      },
      {
        "id": "action_fKMnr4gv",
        "type": "speech",
        "text": "Together, these tools help computers read and write almost any language more effectively. Keep these ideas in mind as we explore more on how machines understand language."
      }
    ],
    "after": [
      {
        "id": "review-2-0",
        "type": "speech",
        "text": "Byte-level BPE starts with a byte alphabet and learns pair merges. SentencePiece is a tokenizer framework offering BPE and unigram models; it is not synonymous with the unigram algorithm."
      },
      {
        "id": "review-2-1",
        "type": "speech",
        "text": "Unigram segmentation uses a probabilistic model. SentencePiece can train directly on raw sentences, represents whitespace explicitly, and may normalize text; exact round trips depend on normalization and byte-fallback settings."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://github.com/google/sentencepiece"
  },
  {
    "file": "22_qkv-projection_college.json",
    "path": "scenes[2].actions",
    "before": [
      {
        "id": "action_xKB_aRyB",
        "type": "spotlight",
        "elementId": "text_sTv0UKLD"
      },
      {
        "id": "action_khbfdnH3",
        "type": "speech",
        "text": "Backpropagation through the Q, K, and V projections is how cross entropy reaches the weight matrices and turns prediction error into parameter updates."
      },
      {
        "id": "action_vjkNuX5V",
        "type": "spotlight",
        "elementId": "text_3NTtjNjz"
      },
      {
        "id": "action_Zxtv3CLH",
        "type": "speech",
        "text": "Each projection is just a linear map from the residual stream, so it is differentiable and admits a clean Jacobian for reverse mode accumulation."
      },
      {
        "id": "action_wYZhKaQG",
        "type": "spotlight",
        "elementId": "latex_ZTDvDiVp"
      },
      {
        "id": "action_-bBCsPMX",
        "type": "speech",
        "text": "For Q equals X W-Q, the Jacobian of a linear map gives partial L over partial W-Q equals X transpose times partial L over partial Q; upstream attention gradients enter through that Q term."
      },
      {
        "id": "action_d9FbBlpg",
        "type": "spotlight",
        "elementId": "latex_Pirq9h2z"
      },
      {
        "id": "action_3--s-4Zq",
        "type": "speech",
        "text": "Likewise, partial L over partial W-K is X transpose times partial L over partial K, and W-V follows identically; the residual stream carries the upstream signal."
      },
      {
        "id": "action_P07kFwA4",
        "type": "spotlight",
        "elementId": "text_acNP2wPN"
      },
      {
        "id": "action_nLSBCKb-",
        "type": "speech",
        "text": "In practice, PyTorch autograd records the matmul graph and returns exactly these Jacobians; call loss dot backward and inspect W-Q dot grad rather than differentiating by hand."
      },
      {
        "id": "action_IPPG-leq",
        "type": "speech",
        "text": "Once these gradients are correct, cross entropy pushes W-Q, W-K, and W-V through Adam or SGD, shrinking attention loss step by step; wrong shapes silently corrupt learning."
      }
    ],
    "after": [
      {
        "id": "review-2-0",
        "type": "speech",
        "text": "Write the input as rows of X, with Q equals X times W Q. The query projection gradient is X transpose times the upstream gradient with respect to Q. The key projection follows the same rule using the gradient with respect to K."
      },
      {
        "id": "review-2-1",
        "type": "speech",
        "text": "Check shapes before multiplying. The input X, not the other attention projection, appears in the gradient of a projection weight matrix. Attention itself has additional score and softmax derivatives."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://arxiv.org/abs/1706.03762"
  },
  {
    "file": "24_latent-space-explorer_college.json",
    "path": "scenes[1].actions",
    "before": [
      {
        "id": "action_-ji2yDDy",
        "type": "spotlight",
        "elementId": "text_wQOqHPOp"
      },
      {
        "id": "action_B9kpuLey",
        "type": "speech",
        "text": "We now formalize latent space representations, the mathematical machinery underlying deep generative models such as the Variational Autoencoder introduced by Kingma and Welling in 2013."
      },
      {
        "id": "action_a_YyYcpM",
        "type": "spotlight",
        "elementId": "text_7FaHh_Ti"
      },
      {
        "id": "action_A7x8XZSI",
        "type": "speech",
        "text": "Consider the VAE architecture. The encoder compresses input x into a low-dimensional latent variable z, a bottleneck that discards nuisance variation while retaining the structure required for faithful reconstruction."
      },
      {
        "id": "action_YYMKFqR5",
        "type": "spotlight",
        "elementId": "latex_djNtQTK2"
      },
      {
        "id": "action_odeEV_9e",
        "type": "speech",
        "text": "The probabilistic encoder q-phi of z given x approximates the true posterior; the decoder p-theta of x given z defines the likelihood. Both are neural networks outputting Gaussian means and variances."
      },
      {
        "id": "action_keOJfpiw",
        "type": "spotlight",
        "elementId": "text_gBAIdtqW"
      },
      {
        "id": "action_Bh0qdxIc",
        "type": "speech",
        "text": "Turn to the matrix view. In the simplest instantiation, the latent mean is an affine transformation of the input: a weight matrix times x plus a bias vector. Practical deep encoders compose many such maps with nonlinear activation functions."
      },
      {
        "id": "action_wpXx_NUR",
        "type": "spotlight",
        "elementId": "latex_Pm91xi1P"
      },
      {
        "id": "action_lidmh7Jz",
        "type": "speech",
        "text": "Concretely, z equals W-e times x plus b-e, the encoder's affine transformation. This compact form supports batched computation and clean backpropagation through every parameter."
      },
      {
        "id": "action_BuceNbrX",
        "type": "spotlight",
        "elementId": "text_30tVSx4S"
      },
      {
        "id": "action_CLccnlII",
        "type": "speech",
        "text": "Now the objective. Training maximizes the evidence lower bound, the ELBO, which decomposes into two competing terms: a reconstruction loss measuring how faithfully the decoder reproduces x, and a Kullback-Leibler divergence pulling the approximate posterior toward a prior, usually a standard Gaussian."
      },
      {
        "id": "action_ALGaS-ia",
        "type": "spotlight",
        "elementId": "latex_RCRESpN5"
      },
      {
        "id": "action_pQwdZhPS",
        "type": "speech",
        "text": "The reconstruction term is the expected log likelihood of x under the decoder, with the expectation taken over the encoder distribution q-phi."
      },
      {
        "id": "action_v75tO-ah",
        "type": "spotlight",
        "elementId": "latex_eFOHtjsM"
      },
      {
        "id": "action_zNQ02m0w",
        "type": "speech",
        "text": "The Kullback-Leibler divergence between q-phi of z given x and the prior p of z acts as a regularizer; for diagonal Gaussians it admits a closed form in the means and variances."
      },
      {
        "id": "action_K9ZUA25j",
        "type": "spotlight",
        "elementId": "latex_02OSdhu2"
      },
      {
        "id": "action_BYcvgYha",
        "type": "speech",
        "text": "The full objective balances these forces: reconstruction fidelity against posterior regularization. Optimizing the ELBO with the reparameterization trick yields low-variance gradients and a structured, interpolable latent space."
      },
      {
        "id": "action_1c4x_2Jk",
        "type": "speech",
        "text": "To summarize: we derived the VAE's mathematical core, the encoder-decoder architecture, affine latent transformations, and the ELBO objective coupling reconstruction with KL regularization. This framework underlies modern generative modeling, from autoencoders to diffusion models."
      }
    ],
    "after": [
      {
        "id": "review-1-0",
        "type": "speech",
        "text": "For a diagonal Gaussian posterior, KL to a standard normal is one half the sum of mean squared plus variance minus one minus log variance. It is nonnegative and is zero for zero mean and unit variance."
      },
      {
        "id": "review-1-1",
        "type": "speech",
        "text": "To minimize a VAE loss, add positive KL to negative expected reconstruction log likelihood. Equivalently, maximize the evidence lower bound. Keep this sign convention consistent."
      }
    ],
    "reason": "Align narration with corrected definition or formula.",
    "reference": "https://arxiv.org/abs/1312.6114"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[0].actions[1].text",
    "before": "Welcome to our course on modern unified image generation architectures. This session examines how state-of-the-art models like FLUX, ERNIE-Image, and HiDream are reshaping image synthesis, replacing the modular latent diffusion paradigm with single-stream transformer designs.",
    "after": "Welcome to our course on modern unified image generation architectures. This session examines how state-of-the-art models like FLUX, ERNIE-Image, and HiDream are reshaping image synthesis, exploring different combinations of latent or pixel representations and separate or integrated encoders.",
    "reason": "Correct an overgeneralization or inconsistent explanation.",
    "reference": "https://github.com/black-forest-labs/flux"
  },
  {
    "file": "f-modern_modern-image_college.json",
    "path": "scenes[11].content.questions",
    "before": [
      {
        "id": "q1",
        "type": "single",
        "question": "Which architectural difference primarily distinguishes a classical Transformer from a Diffusion Transformer in generative modeling?",
        "options": [
          {
            "value": "A",
            "label": "Transformers use self-attention; Diffusion Transformers replace self-attention with CNN layers"
          },
          {
            "value": "B",
            "label": "Transformers process sequences deterministically; Diffusion Transformers incorporate noise conditioning and time embeddings"
          },
          {
            "value": "C",
            "label": "Transformers operate only on text data; Diffusion Transformers operate only on images"
          },
          {
            "value": "D",
            "label": "Transformers use fixed positional encodings; Diffusion Transformers do not use positional encodings"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Classical Transformers process data deterministically using self-attention, while Diffusion Transformers explicitly integrate noise conditioning and timestep embeddings to handle the stochastic diffusion process. Options A, C, and D are incorrect: CNN layers are not a general replacement in Diffusion Transformers; both models can operate on multiple modalities depending on design; positional encodings are typically present in both architectures though implemented differently.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "multiple",
        "question": "Consider the simplified ELBO (Evidence Lower Bound) loss for a diffusion model: Which of the following statements regarding its components are correct? (Select all that apply)",
        "options": [
          {
            "value": "A",
            "label": "The loss term includes a reconstruction error between predicted and actual noise"
          },
          {
            "value": "B",
            "label": "The KL divergence term regularizes the latent space to match a prior distribution"
          },
          {
            "value": "C",
            "label": "The noise schedule directly influences the weighting on different timesteps within the loss"
          },
          {
            "value": "D",
            "label": "The ELBO loss is minimized by maximizing the noise variance at each step"
          }
        ],
        "answer": [
          "A",
          "B",
          "C"
        ],
        "analysis": "Correct statements: A is true because reconstruction of noise is fundamental in denoising diffusion; B is true as KL divergence constrains latent distribution alignment; C is true since noise schedule weights timestep losses. D is false because minimizing ELBO involves optimizing the noise variance indirectly but not necessarily maximizing it; increasing noise variance arbitrarily harms generation quality.",
        "points": 20,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "short_answer",
        "question": "Given the PyTorch snippet below, explain the role of each key line and how the code facilitates one forward prediction step in a diffusion model.\n\n```python\nimport torch\nclass DiffusionStep(torch.nn.Module):\n    def __init__(self, model):\n        super().__init__()\n        self.model = model\n    def forward(self, x_t, t):\n        noise_pred = self.model(x_t, t)  # Predict noise\n        alpha = 0.9  # Assume fixed alpha for simplicity\n        x_0_pred = (x_t - (1 - alpha).sqrt() * noise_pred) / alpha.sqrt()\n        return x_0_pred\n```\n",
        "commentPrompt": "Rubric: (1) Explanation of noise prediction and its significance - 40% (2) Derivation and role of x_0_pred in denoising - 30% (3) Clarity and completeness of explanation - 30%",
        "analysis": "The forward method predicts the noise component from the noisy input x_t and timestep t using the model. Then it computes the estimate of the original clean data x_0 by removing the noise scaled appropriately by alpha and its complement. This process implements a standard denoising step to approximate the clean signal from a noisy observation in diffusion modeling.",
        "points": 25,
        "hasAnswer": false
      },
      {
        "id": "q4",
        "type": "single",
        "question": "In matrix terms, if the diffusion step relies on covariance matrices Sigma_t and noise covariance Sigma_noise, how is the posterior mean of the clean data x_0 expressed given noisy observation x_t?",
        "options": [
          {
            "value": "A",
            "label": "Posterior mean = Sigma_noise * (Sigma_t + Sigma_noise)^(-1) * x_t"
          },
          {
            "value": "B",
            "label": "(Sigma_t + Sigma_noise)^(-1) * (Sigma_t * x_t + Sigma_noise * x_0)"
          },
          {
            "value": "C",
            "label": "Sigma_t * (Sigma_t + Sigma_noise)^(-1) * x_t"
          },
          {
            "value": "D",
            "label": "Sigma_t * Sigma_noise * x_t"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "The posterior mean of the clean data given the noisy input can be derived from Bayesian Gaussian conditioning and is expressed as (Sigma_t + Sigma_noise)^(-1) times the weighted sum of Sigma_t * x_t and Sigma_noise * x_0. Options A, C, and D confuse the matrix weighting and inversion structure inherent to Gaussian posterior computations.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "multiple",
        "question": "Advanced scenario: In optimizing a transformer-based diffusion model, which strategies contribute to improved training stability and sample diversity? (Select all that apply)",
        "options": [
          {
            "value": "A",
            "label": "Gradient clipping to prevent exploding gradients"
          },
          {
            "value": "B",
            "label": "Using fixed, non-learnable positional embeddings only"
          },
          {
            "value": "C",
            "label": "Applying adaptive learning rate schedulers such as cosine annealing"
          },
          {
            "value": "D",
            "label": "Implementing stochastic conditioning techniques with data augmentation"
          }
        ],
        "answer": [
          "A",
          "C",
          "D"
        ],
        "analysis": "Gradient clipping (A) improves stability by preventing gradient explosion; adaptive learning rate schedulers (C) help optimize convergence speed and stability; stochastic conditioning with data augmentation (D) enhances sample diversity and robustness. Option B is incorrect because fixed-only positional embeddings may limit model expressiveness; often a mix or learnable embeddings provide better training performance.",
        "points": 20,
        "hasAnswer": true
      }
    ],
    "after": [
      {
        "id": "q1",
        "type": "single",
        "question": "Does using a diffusion transformer necessarily remove a VAE and separate text encoder?",
        "options": [
          {
            "value": "A",
            "label": "Yes"
          },
          {
            "value": "B",
            "label": "No; inspect the particular architecture"
          },
          {
            "value": "C",
            "label": "Only at high resolution"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "FLUX.1 retains an autoencoder and separate text encoders; architecture details differ across models.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "Which comparison is most defensible?",
        "options": [
          {
            "value": "A",
            "label": "All unified models are better at every task"
          },
          {
            "value": "B",
            "label": "Compare model versions, tasks, metrics and resource costs"
          },
          {
            "value": "C",
            "label": "Compare only parameter count"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "A design claim is not a benchmark result.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "What does the HiDream-O1 project describe?",
        "options": [
          {
            "value": "A",
            "label": "A pixel-level unified transformer without external VAE or disjoint text encoders"
          },
          {
            "value": "B",
            "label": "A tokenization algorithm"
          },
          {
            "value": "C",
            "label": "A universal law for image models"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "This claim is specific to HiDream-O1, not every model called HiDream.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "What does ERNIE-Image use according to its project?",
        "options": [
          {
            "value": "A",
            "label": "A single-stream diffusion transformer"
          },
          {
            "value": "B",
            "label": "Only a text classifier"
          },
          {
            "value": "C",
            "label": "A task-priority scheduler"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "The project describes an8B diffusion transformer; product names alone do not establish shared internal components.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "Which is a useful validation step?",
        "options": [
          {
            "value": "A",
            "label": "Assume all newer models are faster"
          },
          {
            "value": "B",
            "label": "Measure quality, memory and latency on the same task"
          },
          {
            "value": "C",
            "label": "Ignore prompt and sampler settings"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Use reproducible settings and representative tasks.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "reason": "Replace unsupported architecture-wide claims and ambiguous formulas.",
    "reference": "https://github.com/black-forest-labs/flux"
  },
  {
    "file": "f-modern_modern-image_highschool.json",
    "path": "scenes[7].content.questions",
    "before": [
      {
        "id": "q1",
        "type": "single",
        "question": "What is the key advantage of the FLUX model in modern image AI systems?",
        "options": [
          {
            "value": "A",
            "label": "A. It combines image generation and text understanding into one unified process"
          },
          {
            "value": "B",
            "label": "B. It focuses only on improving text translation accuracy"
          },
          {
            "value": "C",
            "label": "C. It uses multiple separate networks for each task"
          },
          {
            "value": "D",
            "label": "D. It removes the need for any training data"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "FLUX unifies both image generation and text understanding in a single system, unlike older models that used separate steps for each task. This helps make the model more efficient and easier to use.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "multiple",
        "question": "Which of the following are benefits of removing the VAE (Variational Autoencoder) and separate text encoders in unified image models?",
        "options": [
          {
            "value": "A",
            "label": "A. Faster image generation"
          },
          {
            "value": "B",
            "label": "B. More complicated training procedures"
          },
          {
            "value": "C",
            "label": "C. Better coordination between text and image features"
          },
          {
            "value": "D",
            "label": "D. Reduced model size and computational needs"
          }
        ],
        "answer": [
          "A",
          "C",
          "D"
        ],
        "analysis": "Removing the VAE and separate text encoders simplifies the system. This leads to faster image generation, better integration between text and image parts, and smaller, less demanding models. More complicated training is not a benefit and is incorrect.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "How does the HiDream model improve the process of generating images from text compared to older methods?",
        "options": [
          {
            "value": "A",
            "label": "A. By splitting text and image parts into separate pipelines"
          },
          {
            "value": "B",
            "label": "B. By using a unified pipeline that treats text and image data together"
          },
          {
            "value": "C",
            "label": "C. By ignoring text input completely"
          },
          {
            "value": "D",
            "label": "D. By only generating black and white images"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "HiDream uses a unified pipeline that processes text and images in one combined system, which is faster and often produces better matches between text and images, unlike older models that separated these processes.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "multiple",
        "question": "Which features belong to the ERNIE model for unified image-text understanding?",
        "options": [
          {
            "value": "A",
            "label": "A. Integrates knowledge from multiple sources"
          },
          {
            "value": "B",
            "label": "B. Separates image and text data for independent processing"
          },
          {
            "value": "C",
            "label": "C. Uses a large-transformer based approach for both modalities"
          },
          {
            "value": "D",
            "label": "D. Is only designed for image recognition without text"
          }
        ],
        "answer": [
          "A",
          "C"
        ],
        "analysis": "ERNIE combines knowledge from various types of data and uses a transformer architecture that jointly processes image and text input. It does not separate these or focus only on images.",
        "points": 15,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "Why are unified pipelines considered better than old cascaded pipelines in image AI models?",
        "options": [
          {
            "value": "A",
            "label": "A. They work slower but produce lower quality images"
          },
          {
            "value": "B",
            "label": "B. They combine multiple steps into one, making the process faster and more accurate"
          },
          {
            "value": "C",
            "label": "C. They require multiple separate programs to work together"
          },
          {
            "value": "D",
            "label": "D. They only use text data without images"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Unified pipelines combine the multiple steps of understanding text and generating images into one smooth flow, reducing delays and errors, unlike cascaded pipelines which run tasks step-by-step, often slowing things down.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "after": [
      {
        "id": "q1",
        "type": "single",
        "question": "Does using a diffusion transformer necessarily remove a VAE and separate text encoder?",
        "options": [
          {
            "value": "A",
            "label": "Yes"
          },
          {
            "value": "B",
            "label": "No; inspect the particular architecture"
          },
          {
            "value": "C",
            "label": "Only at high resolution"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "FLUX.1 retains an autoencoder and separate text encoders; architecture details differ across models.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q2",
        "type": "single",
        "question": "Which comparison is most defensible?",
        "options": [
          {
            "value": "A",
            "label": "All unified models are better at every task"
          },
          {
            "value": "B",
            "label": "Compare model versions, tasks, metrics and resource costs"
          },
          {
            "value": "C",
            "label": "Compare only parameter count"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "A design claim is not a benchmark result.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q3",
        "type": "single",
        "question": "What does the HiDream-O1 project describe?",
        "options": [
          {
            "value": "A",
            "label": "A pixel-level unified transformer without external VAE or disjoint text encoders"
          },
          {
            "value": "B",
            "label": "A tokenization algorithm"
          },
          {
            "value": "C",
            "label": "A universal law for image models"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "This claim is specific to HiDream-O1, not every model called HiDream.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q4",
        "type": "single",
        "question": "What does ERNIE-Image use according to its project?",
        "options": [
          {
            "value": "A",
            "label": "A single-stream diffusion transformer"
          },
          {
            "value": "B",
            "label": "Only a text classifier"
          },
          {
            "value": "C",
            "label": "A task-priority scheduler"
          }
        ],
        "answer": [
          "A"
        ],
        "analysis": "The project describes an8B diffusion transformer; product names alone do not establish shared internal components.",
        "points": 10,
        "hasAnswer": true
      },
      {
        "id": "q5",
        "type": "single",
        "question": "Which is a useful validation step?",
        "options": [
          {
            "value": "A",
            "label": "Assume all newer models are faster"
          },
          {
            "value": "B",
            "label": "Measure quality, memory and latency on the same task"
          },
          {
            "value": "C",
            "label": "Ignore prompt and sampler settings"
          }
        ],
        "answer": [
          "B"
        ],
        "analysis": "Use reproducible settings and representative tasks.",
        "points": 10,
        "hasAnswer": true
      }
    ],
    "reason": "Replace unsupported architecture-wide claims and ambiguous formulas.",
    "reference": "https://github.com/black-forest-labs/flux"
  },
  {
    "file": "25_huggingface-git_college.json",
    "path": "root.classroom.scenes[3].actions[6].state.code",
    "before": "git clone https://huggingface.co/meta-llama/Llama-3-8b-hf",
    "after": "git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B",
    "reason": "Use the actual gated model repository instead of a nonexistent GitHub/model identifier.",
    "reference": "https://huggingface.co/meta-llama/Meta-Llama-3-8B"
  },
  {
    "file": "25_huggingface-git_college.json",
    "path": "root.classroom.scenes[3].content.html",
    "before": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Hands-On: Cloning a 40 GB Model with Git LFS - Python Playground</title>\n<!-- CodeMirror 6 from CDN -->\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/codemirror@6.65.7/theme/monokai.min.css\" />\n<style>\n  body {\n    margin: 0;\n    font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen,\n      Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;\n    background: #1e1e1e;\n    color: #d4d4d4;\n    display: flex;\n    flex-direction: column;\n    height: 100vh;\n    overflow: hidden;\n  }\n  header {\n    background: #2d2d30;\n    padding: 1rem 1.5rem;\n    font-weight: 700;\n    font-size: 1.25rem;\n    color: #8b5cf6;\n    user-select: none;\n  }\n  #container {\n    flex: 1;\n    display: flex;\n    flex-direction: row;\n    overflow: hidden;\n  }\n  #editor-container, #right-panel {\n    display: flex;\n    flex-direction: column;\n  }\n  #editor-container {\n    flex: 1 1 60%;\n    min-width: 320px;\n    border-right: 1px solid #3c3c3c;\n  }\n  #code-input {\n    height: 100%;\n    outline: none;\n    font-size: 1rem;\n    line-height: 1.4;\n  }\n  #right-panel {\n    flex: 1 1 40%;\n    min-width: 320px;\n    background: #252526;\n    overflow-y: auto;\n  }\n  #controls {\n    padding: 0.75rem 1rem;\n    border-bottom: 1px solid #3c3c3c;\n    background: #2d2d30;\n    display: flex;\n    align-items: center;\n    gap: 12px;\n  }\n  #run-btn {\n    background: #8b5cf6;\n    border: none;\n    color: white;\n    font-weight: 600;\n    padding: 0.5rem 1.25rem;\n    border-radius: 5px;\n    cursor: pointer;\n    user-select: none;\n    transition: background-color 0.3s ease;\n  }\n  #run-btn:disabled {\n    background: #5c3a96;\n    cursor: default;\n  }\n  #status {\n    font-size: 0.875rem;\n    color: #aaa;\n    min-width: 90px;\n  }\n  #output,\n  #test-results {\n    padding: 1rem;\n    font-family: \"Source Code Pro\", monospace, monospace;\n    font-size: 0.9rem;\n    white-space: pre-wrap;\n    background: #1e1e1e;\n    border-radius: 4px;\n    margin: 1rem;\n    color: #d4d4d4;\n    flex: 1;\n    overflow-y: auto;\n    border: 1px solid #3c3c3c;\n  }\n  #test-results {\n    max-height: 180px;\n  }\n  .test-case {\n    margin-bottom: 0.4rem;\n    font-size: 0.875rem;\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n    padding: 0.15rem 0.5rem;\n    border-radius: 4px;\n  }\n  .test-case.pass {\n    background: #144620;\n    color: #b4f8b4;\n  }\n  .test-case.fail {\n    background: #5a1e1e;\n    color: #f88c8c;\n  }\n  #hints {\n    padding: 0 1rem 1rem 1rem;\n  }\n  #hint-btn {\n    cursor: pointer;\n    border: none;\n    background: #8b5cf6;\n    color: white;\n    font-weight: 600;\n    border-radius: 6px;\n    padding: 0.4rem 1rem;\n    margin: 0.5rem 1rem;\n    user-select: none;\n    transition: background-color 0.3s ease;\n  }\n  #hints-list {\n    list-style: none;\n    padding-left: 1rem;\n    margin-top: 0.5rem;\n    color: #ccc;\n    font-size: 0.9rem;\n  }\n  #hints-list li {\n    margin-bottom: 0.4rem;\n  }\n  #description {\n    background: #252526;\n    color: #d4d4d4;\n    padding: 1rem;\n    font-size: 1rem;\n    line-height: 1.5;\n    border-bottom: 1px solid #3c3c3c;\n    max-height: 12rem;\n    overflow-y: auto;\n  }\n  #solution {\n    background: #252526;\n    margin: 1rem;\n    padding: 1rem;\n    border: 1px solid #8b5cf6;\n    border-radius: 6px;\n    font-family: \"Source Code Pro\", monospace, monospace;\n    font-size: 0.85rem;\n    white-space: pre-wrap;\n    color: #d4d4d4;\n    display: none;\n    user-select: text;\n  }\n  #show-solution-btn {\n    cursor: pointer;\n    border: none;\n    background: #6f42c1;\n    color: white;\n    font-weight: 600;\n    border-radius: 6px;\n    padding: 0.4rem 1rem;\n    margin: 0 1rem;\n    user-select: none;\n    transition: background-color 0.3s ease;\n  }\n\n  /* Scrollbar for output and test results */\n  #output::-webkit-scrollbar, #test-results::-webkit-scrollbar {\n    width: 8px;\n  }\n  #output::-webkit-scrollbar-thumb, #test-results::-webkit-scrollbar-thumb {\n    background: #555;\n    border-radius: 4px;\n  }\n\n  /* Responsive layout adjustments */\n  @media (max-width: 767px) {\n    #container {\n      flex-direction: column;\n    }\n    #editor-container, #right-panel {\n      flex: none;\n      min-width: 100%;\n      height: 40vh;\n    }\n    #output {\n      max-height: 30vh;\n      margin: 0 1rem 1rem 1rem;\n    }\n    #test-results {\n      max-height: none;\n      margin: 0 1rem 1rem 1rem;\n    }\n    #code-input {\n      height: 200px !important;\n    }\n  }\n\n  /* Teacher annotation style */\n  .teacher-annotation {\n    box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);\n  }\n</style>\n<!-- CodeMirror 6 Dependencies -->\n<script>function createLessonEditor(parent, code) {\n const input=document.createElement('textarea'); input.value=code; input.spellcheck=false;\n input.setAttribute('aria-label','Python code editor');\n input.style.cssText='display:block;width:100%;min-height:320px;box-sizing:border-box;background:#171722;color:#e8e8ee;font:14px/1.6 monospace;padding:16px;border:1px solid #666;resize:vertical;white-space:pre;overflow:auto';\n parent.replaceChildren(input);\n const editor={getValue:()=>input.value,setValue:value=>input.value=value,focus:()=>input.focus(),dispatch:tr=>{const ch=tr.changes;if(ch)input.value=input.value.slice(0,ch.from)+ch.insert+input.value.slice(ch.to);}};\n Object.defineProperty(editor,'state',{get:()=>({doc:{toString:()=>input.value,length:input.value.length},update:tr=>tr})});\n return editor;\n}\nwindow.createEditor=createLessonEditor;</script>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<header>Hands-On: Cloning a 40 GB Model with Git LFS - Python Playground</header>\n<div id=\"container\">\n  <section id=\"editor-container\" aria-label=\"Code editor\">\n    <div id=\"code-input\" role=\"textbox\" aria-multiline=\"true\" aria-label=\"Code editor\"></div>\n  </section>\n  <section id=\"right-panel\" aria-label=\"Output and controls\">\n    <div id=\"controls\">\n      <button id=\"run-btn\" aria-label=\"Run code\" disabled>Run</button>\n      <span id=\"status\" aria-live=\"polite\" aria-atomic=\"true\">Loading Python environment…</span>\n    </div>\n    <section id=\"description\" aria-label=\"Challenge description\">\n      <p>In this hands-on exercise, you will learn to install and use Git Large File Storage (Git LFS) to clone a very large repository: the Meta-Llama-3-8B model (~40 GB). This dynamic technique allows handling of large AI model weights that exceed typical Git repository size limits by storing them efficiently on remote servers while managing small pointer files locally.</p>\n      <p>You will simulate command-line operations for installing Git LFS, initializing it within your Git configuration, cloning the remote repository with automatic filtering of large files, and inspecting the downloaded model files stored as <code>.safetensors</code>. This practical knowledge is crucial when dealing with state-of-the-art large language models (LLMs) distributed via repository hosting platforms.</p>\n    </section>\n    <label for=\"terminal-input\">Simulated commands (one per line; no files are downloaded)</label><textarea id=\"terminal-input\" rows=\"5\" style=\"width:100%;box-sizing:border-box\">git lfs install\ngit clone https://github.com/facebookresearch/Meta-Llama-3-8B.git\nls -lh Meta-Llama-3-8B/model/\nexit</textarea><pre id=\"output\" tabindex=\"0\" aria-live=\"polite\" aria-atomic=\"true\" aria-label=\"Program output\"></pre>\n    <section id=\"test-results\" aria-live=\"polite\" aria-atomic=\"true\" aria-label=\"Test case results\"></section>\n    <button id=\"show-solution-btn\" aria-expanded=\"false\" aria-controls=\"solution\" aria-label=\"Show solution code\">Show solution</button>\n    <pre id=\"solution\" tabindex=\"0\" aria-label=\"Solution code\"><code>import time\n\ndef simulate_command(command: str) -> str:\n    \"\"\"\n    Simulates terminal command responses related to Git LFS install and cloning the Meta-Llama-3-8B model repository.\n\n    Parameters\n    ----------\n    command : str\n        The command entered by the user.\n\n    Returns\n    -------\n    str\n        The simulated terminal output corresponding to the command.\n    \"\"\"\n    command = command.strip().lower()\n    if command == \"git lfs install\":\n        return (\n            \"Git LFS initialized.\\n\"\n            \"Tracking *.safetensors files.\\n\"\n            \"Smudge and clean filters configured.\\n\"\n            \"Git LFS is now enabled for this repository.\"\n        )\n    if command.startswith(\"git clone\"):\n        if \"meta-llama-3-8b\" not in command:\n            return \"fatal: repository not found.\"\n        return (\n            \"Cloning into 'Meta-Llama-3-8B'...\\n\"\n            \"Git LFS: (0 of 30 files, 0 skipped) 0 B / 40.0 GB\\n\"\n            \"Filtering content: 100% (30/30), 40.00 GB | 45.00 MB/s\\n\"\n            \"Check out the latest commit: abc123def456\\n\"\n            \"Clone completed successfully.\\n\"\n            \"Large files downloaded via Git LFS.\"\n        )\n    if command == \"ls -lh meta-llama-3-8b/model/\":\n        # Show sample list of .safetensors files and their sizes\n        return (\n            \"total 40G\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_1.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_2.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_3.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_4.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_5.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_6.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_7.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_8.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_9.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_10.safetensors\\n\"\n        )\n    return f\"-bash: {command}: command not found\"\n\nprint(\"# Welcome to your interactive shell simulation.\")\nprint(\"Type your commands below. Supported commands for this exercise are:\")\nprint(\" - git lfs install\")\nprint(\" - git clone https://github.com/facebookresearch/Meta-Llama-3-8B.git\")\nprint(\" - ls -lh Meta-Llama-3-8B/model/\")\n\nwhile True:\n    try:\n        user_input = input(\"➜ $ \")\n        if user_input.lower() in {\"exit\", \"quit\"}:\n            print(\"Exiting simulation.\")\n            break\n        output = simulate_command(user_input)\n        print(output)\n    except EOFError:\n        print(\"\\nExiting simulation.\")\n        break\n</code></pre>\n    <div id=\"hints\" aria-label=\"Hints\">\n      <button id=\"hint-btn\" aria-expanded=\"false\" aria-controls=\"hints-list\" aria-label=\"Reveal next hint\">Show Hint</button>\n      <ul id=\"hints-list\" style=\"display:none;\"></ul>\n    </div>\n  </section>\n</div>\n\n<script type=\"module\">\n  const starterCode = `\\\nprint(\"# Welcome to your interactive shell simulation.\")\nprint(\"Type your commands below. Supported commands for this exercise are:\")\nprint(\" - git lfs install\")\nprint(\" - git clone https://github.com/facebookresearch/Meta-Llama-3-8B.git\")\nprint(\" - ls -lh Meta-Llama-3-8B/model/\")\n\ndef simulate_command(command: str) -> str:\n    \\\"\"\"\n    Simulates terminal command responses related to Git LFS install and cloning the Meta-Llama-3-8B model repository.\n\n    Parameters\n    ----------\n    command : str\n        The command entered by the user.\n\n    Returns\n    -------\n    str\n        The simulated terminal output corresponding to the command.\n    \\\"\"\"\n    command = command.strip().lower()\n    if command == \"git lfs install\":\n        return (\n            \"Git LFS initialized.\\\\n\"\n            \"Tracking *.safetensors files.\\\\n\"\n            \"Smudge and clean filters configured.\\\\n\"\n            \"Git LFS is now enabled for this repository.\"\n        )\n    if command.startswith(\"git clone\"):\n        if \"meta-llama-3-8b\" not in command:\n            return \"fatal: repository not found.\"\n        return (\n            \"Cloning into 'Meta-Llama-3-8B'...\\\\n\"\n            \"Git LFS: (0 of 30 files, 0 skipped) 0 B / 40.0 GB\\\\n\"\n            \"Filtering content: 100% (30/30), 40.00 GB | 45.00 MB/s\\\\n\"\n            \"Check out the latest commit: abc123def456\\\\n\"\n            \"Clone completed successfully.\\\\n\"\n            \"Large files downloaded via Git LFS.\"\n        )\n    if command == \"ls -lh meta-llama-3-8b/model/\":\n        # Show sample list of .safetensors files and their sizes\n        return (\n            \"total 40G\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_1.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_2.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_3.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_4.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_5.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_6.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_7.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_8.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_9.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_10.safetensors\\\\n\"\n        )\n    return f\"-bash: {command}: command not found\"\n\nwhile True:\n    try:\n        user_input = input(\"➜ $ \")\n        if user_input.lower() in {\"exit\", \"quit\"}:\n            print(\"Exiting simulation.\")\n            break\n        output = simulate_command(user_input)\n        print(output)\n    except EOFError:\n        print(\"\\\\nExiting simulation.\")\n        break\n`;\n\n  const hints = [\n    \"Git LFS (Large File Storage) is a Git extension designed to handle large files efficiently.\",\n    \"Before cloning a repository with large files, run 'git lfs install' to initialize Git LFS tracking locally.\",\n    \"The 'git clone' command automatically downloads large files through Git LFS if the repository is configured correctly.\",\n    \"Files tracked with Git LFS are replaced by pointer files in the repository, reducing storage and bandwidth.\",\n    \"Use 'ls -lh' on the repository's model directory to verify downloaded large files, typically stored with the '.safetensors' extension.\"\n  ];\n\n  let currentHintIndex = 0;\n\n  const hintBtn = document.getElementById(\"hint-btn\");\n  const hintsList = document.getElementById(\"hints-list\");\n\n  hintBtn.addEventListener(\"click\", () => {\n    if (currentHintIndex === 0) {\n      hintsList.style.display = \"block\";\n      hintBtn.setAttribute(\"aria-expanded\", \"true\");\n    }\n    if (currentHintIndex < hints.length) {\n      const li = document.createElement(\"li\");\n      li.textContent = hints[currentHintIndex];\n      hintsList.appendChild(li);\n      currentHintIndex += 1;\n      if (currentHintIndex === hints.length) {\n        hintBtn.disabled = true;\n        hintBtn.textContent = \"All hints revealed\";\n      }\n    }\n  });\n\n  // Initialize CodeMirror editor\n  const editorHost = document.getElementById(\"code-input\");\n  window.editor = createEditor(editorHost, starterCode);\n\n  // Pyodide loading and setup\n  let pyodide = null;\n  const runBtn = document.getElementById(\"run-btn\");\n  const status = document.getElementById(\"status\");\n  const outputElem = document.getElementById(\"output\");\n  const testResultsElem = document.getElementById(\"test-results\");\n  const showSolutionBtn = document.getElementById(\"show-solution-btn\");\n  const solutionElem = document.getElementById(\"solution\");\n\n  showSolutionBtn.addEventListener(\"click\", () => {\n    if (solutionElem.style.display === \"none\") {\n      solutionElem.style.display = \"\";\n      showSolutionBtn.textContent = \"Hide solution\";\n      showSolutionBtn.setAttribute(\"aria-expanded\", \"true\");\n      // Reveal the solution panel on demand for postMessage compatibility\n      window.dispatchEvent(new MessageEvent('message', {data: {type: 'REVEAL_ELEMENT', target: '#solution'}}));\n    } else {\n      solutionElem.style.display = \"none\";\n      showSolutionBtn.textContent = \"Show solution\";\n      showSolutionBtn.setAttribute(\"aria-expanded\", \"false\");\n    }\n  });\n\n  async function initPyodide() {\n    try {\n      status.textContent = \"Initializing Python runtime...\";\n      pyodide = await loadPyodide({indexURL : \"https://cdn.jsdelivr.net/pyodide/v0.23.4/full/\"});\n      // No additional packages needed for simulation, but if we did, load like this:\n      // await pyodide.loadPackage(['numpy']);\n      runBtn.disabled = false;\n      status.textContent = \"Python environment ready\";\n    } catch (e) {\n      status.textContent = \"Failed to load Python environment\";\n      outputElem.textContent = \"Error during Pyodide initialization:\\n\" + e.message;\n    }\n  }\n  initPyodide();\n\n  async function runCode() {\n    if (!pyodide) {\n      alert(\"Python environment not ready\");\n      return;\n    }\n    runBtn.disabled = true;\n    status.textContent = \"Running code...\";\n    outputElem.textContent = \"\";\n    testResultsElem.textContent = \"\";\n    try {\n      const code = editor.state.doc.toString();\n\n      // Setup stdout capture as per specification\n      await pyodide.runPythonAsync(`\nimport sys\nimport io\nsys.stdout = io.StringIO()\n`);\n\n      const commands = document.getElementById(\"terminal-input\").value.split(\"\\n\");\n      pyodide.setStdin({stdin: () => commands.length ? commands.shift() : null});\n      // Evaluate user code asynchronously\n      await pyodide.runPythonAsync(code);\n\n      // Retrieve stdout captured text\n      const output = pyodide.runPython('sys.stdout.getvalue()');\n      outputElem.textContent = output;\n      status.textContent = \"Execution completed\";\n\n      validateTests(code, output);\n    } catch (e) {\n      outputElem.textContent = `Error: ${e.message}`;\n      status.textContent = \"Execution failed\";\n    } finally {\n      runBtn.disabled = false;\n    }\n  }\n\n  // Since the simulation is interactive by design, tests will verify that at least\n  // the initial instructions are preserved and simulated commands function as expected.\n  // This is a pedagogic aid rather than a strict correctness criterion.\n  function validateTests(userCode, output) {\n    testResultsElem.innerHTML = \"\";\n    const tests = [\n      {\n        id: \"t1\",\n        description: \"Starter code includes prompt for 'git lfs install'\",\n        passed: /git lfs install/i.test(userCode)\n      },\n      {\n        id: \"t2\",\n        description: \"Simulate 'git lfs install' command in output\",\n        passed: output.includes(\"Git LFS initialized\")\n      },\n      {\n        id: \"t3\",\n        description: \"Simulate 'git clone' command in output\",\n        passed: output.includes(\"Cloning into 'Meta-Llama-3-8B'\") && output.includes(\"Large files downloaded via Git LFS.\")\n      },\n      {\n        id: \"t4\",\n        description: \"Simulate 'ls -lh ...' displays .safetensors files\",\n        passed: output.includes(\".safetensors\")\n      }\n    ];\n\n    for (const test of tests) {\n      const div = document.createElement(\"div\");\n      div.classList.add(\"test-case\");\n      div.classList.add(test.passed ? \"pass\" : \"fail\");\n      div.textContent = (test.passed ? \"✓ \" : \"✗ \") + test.description;\n      testResultsElem.appendChild(div);\n    }\n  }\n\n  runBtn.addEventListener(\"click\", runCode);\n\n  // Implement postMessage listener as required\n  window.addEventListener(\"message\", function(event) {\n    const { type, target, state, content } = event.data;\n\n    switch (type) {\n      case \"SET_WIDGET_STATE\":\n        // state: { code: \"...\", run: true }\n        if (state && typeof state.code === \"string\") {\n          if (typeof editor !== \"undefined\" && typeof editor.dispatch === \"function\") {\n            const transaction = editor.state.update({\n              changes: { from: 0, to: editor.state.doc.length, insert: state.code }\n            });\n            editor.dispatch(transaction);\n          } else {\n            const ta = document.getElementById(\"code-input\");\n            if (ta) ta.value = state.code;\n          }\n        }\n        if (state && state.run && typeof runCode === \"function\") {\n          runCode();\n        }\n        break;\n\n      case \"HIGHLIGHT_ELEMENT\":\n        const highlightEl = document.querySelector(target);\n        if (highlightEl) {\n          highlightEl.style.outline = \"3px solid rgba(139, 92, 246, 0.8)\";\n          highlightEl.style.outlineOffset = \"4px\";\n          highlightEl.style.animation = \"pulse-highlight 2s infinite\";\n          setTimeout(() => {\n            highlightEl.style.outline = \"\";\n            highlightEl.style.animation = \"\";\n          }, 3000);\n        }\n        break;\n\n      case \"ANNOTATE_ELEMENT\":\n        const annotateEl = document.querySelector(target);\n        if (annotateEl && content) {\n          const rect = annotateEl.getBoundingClientRect();\n          const tooltip = document.createElement(\"div\");\n          tooltip.className = \"teacher-annotation\";\n          tooltip.style.cssText = \n            \"position:fixed; top:\" + (rect.top - 40) + \"px; left:\" + rect.left + \n            \"px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;\";\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n        break;\n\n      case \"REVEAL_ELEMENT\":\n        const revealEl = document.querySelector(target);\n        if (revealEl) {\n          revealEl.style.display = \"\";\n          revealEl.style.opacity = \"1\";\n        }\n        break;\n    }\n  });\n\n  // Add global styles for highlight animations\n  const style = document.createElement(\"style\");\n  style.textContent = `\n@keyframes pulse-highlight {\n  0%, 100% { outline-color: rgba(139, 92, 246, 0.8); }\n  50% { outline-color: rgba(139, 92, 246, 0.4); }\n}\n@keyframes fadeIn {\n  from { opacity: 0; transform: translateY(10px); }\n  to { opacity: 1; transform: translateY(0); }\n}`;\n  document.head.appendChild(style);\n</script>\n\n<!-- Pyodide -->\n<script src=\"https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js\"></script>\n\n<script>\n  // Prevent form submission or lost focus on enter key in CodeMirror editor for better UX\n  document.getElementById(\"code-input\").addEventListener(\"keydown\", (e) => {\n    if (e.key === \"Enter\" && (e.ctrlKey || e.metaKey)) {\n      e.preventDefault();\n      document.getElementById(\"run-btn\").click();\n    }\n  });\n</script>\n\n<script type=\"application/json\" id=\"widget-config\" style=\"display:none\">\n{\n  \"type\": \"code\",\n  \"language\": \"python\",\n  \"description\": \"In this hands-on exercise, you will simulate the installation of Git Large File Storage (Git LFS) and cloning a large AI model's repository (~40 GB) to understand the workflow of managing large models in machine learning projects.\",\n  \"starterCode\": \"print(\\\"# Welcome to your interactive shell simulation.\\\")\\nprint(\\\"Type your commands below. Supported commands for this exercise are:\\\")\\nprint(\\\" - git lfs install\\\")\\nprint(\\\" - git clone https://github.com/facebookresearch/Meta-Llama-3-8B.git\\\")\\nprint(\\\" - ls -lh Meta-Llama-3-8B/model/\\\")\\n\\n# (See full simulation code in the editor above)\",\n  \"testCases\": [\n    { \"id\": \"t1\", \"input\": \"contains 'git lfs install'\", \"expected\": true, \"description\": \"Starter code must mention 'git lfs install' command\" },\n    { \"id\": \"t2\", \"input\": \"'git lfs install'\", \"expected\": \"Git LFS initialized.\", \"description\": \"Simulate 'git lfs install' command output\" },\n    { \"id\": \"t3\", \"input\": \"'git clone https://github.com/facebookresearch/Meta-Llama-3-8B.git'\", \"expected\": \"Cloning into 'Meta-Llama-3-8B'...\", \"description\": \"Simulate cloning with Git LFS filtering\" },\n    { \"id\": \"t4\", \"input\": \"'ls -lh Meta-Llama-3-8B/model/'\", \"expected\": \".safetensors\", \"description\": \"Show local safetensors model files after cloning\" }\n  ],\n  \"hints\": [\n    \"Git LFS enables tracking and management of files larger than usual Git size limits.\",\n    \"Running 'git lfs install' activates Git LFS filters on your local Git repository.\",\n    \"Git LFS replaces large files with pointers in your main repository while storing the actual data remotely.\",\n    \"Cloning a Git LFS-enabled repo downloads pointers first, then downloads actual large files behind the scenes.\",\n    \"Inspect your local clone's model directory to verify downloaded large model files, typically with .safetensors extensions.\"\n  ],\n  \"solution\": \"See the code block inside the editor titled 'solution' for the full simulation implementation in Python simulating shell commands for git lfs install, cloning, and ls.\"\n}\n</script>\n</body>\n</html>",
    "after": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Hands-On: Cloning a 40 GB Model with Git LFS - Python Playground</title>\n<!-- CodeMirror 6 from CDN -->\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/codemirror@6.65.7/theme/monokai.min.css\" />\n<style>\n  body {\n    margin: 0;\n    font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen,\n      Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;\n    background: #1e1e1e;\n    color: #d4d4d4;\n    display: flex;\n    flex-direction: column;\n    height: 100vh;\n    overflow: hidden;\n  }\n  header {\n    background: #2d2d30;\n    padding: 1rem 1.5rem;\n    font-weight: 700;\n    font-size: 1.25rem;\n    color: #8b5cf6;\n    user-select: none;\n  }\n  #container {\n    flex: 1;\n    display: flex;\n    flex-direction: row;\n    overflow: hidden;\n  }\n  #editor-container, #right-panel {\n    display: flex;\n    flex-direction: column;\n  }\n  #editor-container {\n    flex: 1 1 60%;\n    min-width: 320px;\n    border-right: 1px solid #3c3c3c;\n  }\n  #code-input {\n    height: 100%;\n    outline: none;\n    font-size: 1rem;\n    line-height: 1.4;\n  }\n  #right-panel {\n    flex: 1 1 40%;\n    min-width: 320px;\n    background: #252526;\n    overflow-y: auto;\n  }\n  #controls {\n    padding: 0.75rem 1rem;\n    border-bottom: 1px solid #3c3c3c;\n    background: #2d2d30;\n    display: flex;\n    align-items: center;\n    gap: 12px;\n  }\n  #run-btn {\n    background: #8b5cf6;\n    border: none;\n    color: white;\n    font-weight: 600;\n    padding: 0.5rem 1.25rem;\n    border-radius: 5px;\n    cursor: pointer;\n    user-select: none;\n    transition: background-color 0.3s ease;\n  }\n  #run-btn:disabled {\n    background: #5c3a96;\n    cursor: default;\n  }\n  #status {\n    font-size: 0.875rem;\n    color: #aaa;\n    min-width: 90px;\n  }\n  #output,\n  #test-results {\n    padding: 1rem;\n    font-family: \"Source Code Pro\", monospace, monospace;\n    font-size: 0.9rem;\n    white-space: pre-wrap;\n    background: #1e1e1e;\n    border-radius: 4px;\n    margin: 1rem;\n    color: #d4d4d4;\n    flex: 1;\n    overflow-y: auto;\n    border: 1px solid #3c3c3c;\n  }\n  #test-results {\n    max-height: 180px;\n  }\n  .test-case {\n    margin-bottom: 0.4rem;\n    font-size: 0.875rem;\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n    padding: 0.15rem 0.5rem;\n    border-radius: 4px;\n  }\n  .test-case.pass {\n    background: #144620;\n    color: #b4f8b4;\n  }\n  .test-case.fail {\n    background: #5a1e1e;\n    color: #f88c8c;\n  }\n  #hints {\n    padding: 0 1rem 1rem 1rem;\n  }\n  #hint-btn {\n    cursor: pointer;\n    border: none;\n    background: #8b5cf6;\n    color: white;\n    font-weight: 600;\n    border-radius: 6px;\n    padding: 0.4rem 1rem;\n    margin: 0.5rem 1rem;\n    user-select: none;\n    transition: background-color 0.3s ease;\n  }\n  #hints-list {\n    list-style: none;\n    padding-left: 1rem;\n    margin-top: 0.5rem;\n    color: #ccc;\n    font-size: 0.9rem;\n  }\n  #hints-list li {\n    margin-bottom: 0.4rem;\n  }\n  #description {\n    background: #252526;\n    color: #d4d4d4;\n    padding: 1rem;\n    font-size: 1rem;\n    line-height: 1.5;\n    border-bottom: 1px solid #3c3c3c;\n    max-height: 12rem;\n    overflow-y: auto;\n  }\n  #solution {\n    background: #252526;\n    margin: 1rem;\n    padding: 1rem;\n    border: 1px solid #8b5cf6;\n    border-radius: 6px;\n    font-family: \"Source Code Pro\", monospace, monospace;\n    font-size: 0.85rem;\n    white-space: pre-wrap;\n    color: #d4d4d4;\n    display: none;\n    user-select: text;\n  }\n  #show-solution-btn {\n    cursor: pointer;\n    border: none;\n    background: #6f42c1;\n    color: white;\n    font-weight: 600;\n    border-radius: 6px;\n    padding: 0.4rem 1rem;\n    margin: 0 1rem;\n    user-select: none;\n    transition: background-color 0.3s ease;\n  }\n\n  /* Scrollbar for output and test results */\n  #output::-webkit-scrollbar, #test-results::-webkit-scrollbar {\n    width: 8px;\n  }\n  #output::-webkit-scrollbar-thumb, #test-results::-webkit-scrollbar-thumb {\n    background: #555;\n    border-radius: 4px;\n  }\n\n  /* Responsive layout adjustments */\n  @media (max-width: 767px) {\n    #container {\n      flex-direction: column;\n    }\n    #editor-container, #right-panel {\n      flex: none;\n      min-width: 100%;\n      height: 40vh;\n    }\n    #output {\n      max-height: 30vh;\n      margin: 0 1rem 1rem 1rem;\n    }\n    #test-results {\n      max-height: none;\n      margin: 0 1rem 1rem 1rem;\n    }\n    #code-input {\n      height: 200px !important;\n    }\n  }\n\n  /* Teacher annotation style */\n  .teacher-annotation {\n    box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);\n  }\n</style>\n<!-- CodeMirror 6 Dependencies -->\n<script>function createLessonEditor(parent, code) {\n const input=document.createElement('textarea'); input.value=code; input.spellcheck=false;\n input.setAttribute('aria-label','Python code editor');\n input.style.cssText='display:block;width:100%;min-height:320px;box-sizing:border-box;background:#171722;color:#e8e8ee;font:14px/1.6 monospace;padding:16px;border:1px solid #666;resize:vertical;white-space:pre;overflow:auto';\n parent.replaceChildren(input);\n const editor={getValue:()=>input.value,setValue:value=>input.value=value,focus:()=>input.focus(),dispatch:tr=>{const ch=tr.changes;if(ch)input.value=input.value.slice(0,ch.from)+ch.insert+input.value.slice(ch.to);}};\n Object.defineProperty(editor,'state',{get:()=>({doc:{toString:()=>input.value,length:input.value.length},update:tr=>tr})});\n return editor;\n}\nwindow.createEditor=createLessonEditor;</script>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<header>Hands-On: Cloning a 40 GB Model with Git LFS - Python Playground</header>\n<div id=\"container\">\n  <section id=\"editor-container\" aria-label=\"Code editor\">\n    <div id=\"code-input\" role=\"textbox\" aria-multiline=\"true\" aria-label=\"Code editor\"></div>\n  </section>\n  <section id=\"right-panel\" aria-label=\"Output and controls\">\n    <div id=\"controls\">\n      <button id=\"run-btn\" aria-label=\"Run code\" disabled>Run</button>\n      <span id=\"status\" aria-live=\"polite\" aria-atomic=\"true\">Loading Python environment…</span>\n    </div>\n    <section id=\"description\" aria-label=\"Challenge description\">\n      <p>In this hands-on exercise, you will learn to install and use Git Large File Storage (Git LFS) to clone a very large repository: the Meta-Llama-3-8B model (~40 GB). This dynamic technique allows handling of large AI model weights that exceed typical Git repository size limits by storing them efficiently on remote servers while managing small pointer files locally.</p>\n      <p>You will simulate command-line operations for installing Git LFS, initializing it within your Git configuration, cloning the remote repository with automatic filtering of large files, and inspecting the downloaded model files stored as <code>.safetensors</code>. This practical knowledge is crucial when dealing with state-of-the-art large language models (LLMs) distributed via repository hosting platforms.</p>\n    </section>\n    <label for=\"terminal-input\">Simulated commands (one per line; no files are downloaded)</label><textarea id=\"terminal-input\" rows=\"5\" style=\"width:100%;box-sizing:border-box\">git lfs install\ngit clone https://huggingface.co/meta-llama/Meta-Llama-3-8B\nls -lh Meta-Llama-3-8B/model/\nexit</textarea><pre id=\"output\" tabindex=\"0\" aria-live=\"polite\" aria-atomic=\"true\" aria-label=\"Program output\"></pre>\n    <section id=\"test-results\" aria-live=\"polite\" aria-atomic=\"true\" aria-label=\"Test case results\"></section>\n    <button id=\"show-solution-btn\" aria-expanded=\"false\" aria-controls=\"solution\" aria-label=\"Show solution code\">Show solution</button>\n    <pre id=\"solution\" tabindex=\"0\" aria-label=\"Solution code\"><code>import time\n\ndef simulate_command(command: str) -> str:\n    \"\"\"\n    Simulates terminal command responses related to Git LFS install and cloning the Meta-Llama-3-8B model repository.\n\n    Parameters\n    ----------\n    command : str\n        The command entered by the user.\n\n    Returns\n    -------\n    str\n        The simulated terminal output corresponding to the command.\n    \"\"\"\n    command = command.strip().lower()\n    if command == \"git lfs install\":\n        return (\n            \"Git LFS initialized.\\n\"\n            \"Tracking *.safetensors files.\\n\"\n            \"Smudge and clean filters configured.\\n\"\n            \"Git LFS is now enabled for this repository.\"\n        )\n    if command.startswith(\"git clone\"):\n        if \"meta-llama-3-8b\" not in command:\n            return \"fatal: repository not found.\"\n        return (\n            \"Cloning into 'Meta-Llama-3-8B'...\\n\"\n            \"Git LFS: (0 of 30 files, 0 skipped) 0 B / 40.0 GB\\n\"\n            \"Filtering content: 100% (30/30), 40.00 GB | 45.00 MB/s\\n\"\n            \"Check out the latest commit: abc123def456\\n\"\n            \"Clone completed successfully.\\n\"\n            \"Large files downloaded via Git LFS.\"\n        )\n    if command == \"ls -lh meta-llama-3-8b/model/\":\n        # Show sample list of .safetensors files and their sizes\n        return (\n            \"total 40G\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_1.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_2.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_3.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_4.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_5.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_6.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_7.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_8.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_9.safetensors\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_10.safetensors\\n\"\n        )\n    return f\"-bash: {command}: command not found\"\n\nprint(\"# Welcome to your interactive shell simulation.\")\nprint(\"Type your commands below. Supported commands for this exercise are:\")\nprint(\" - git lfs install\")\nprint(\" - git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B\")\nprint(\" - ls -lh Meta-Llama-3-8B/model/\")\n\nwhile True:\n    try:\n        user_input = input(\"➜ $ \")\n        if user_input.lower() in {\"exit\", \"quit\"}:\n            print(\"Exiting simulation.\")\n            break\n        output = simulate_command(user_input)\n        print(output)\n    except EOFError:\n        print(\"\\nExiting simulation.\")\n        break\n</code></pre>\n    <div id=\"hints\" aria-label=\"Hints\">\n      <button id=\"hint-btn\" aria-expanded=\"false\" aria-controls=\"hints-list\" aria-label=\"Reveal next hint\">Show Hint</button>\n      <ul id=\"hints-list\" style=\"display:none;\"></ul>\n    </div>\n  </section>\n</div>\n\n<script type=\"module\">\n  const starterCode = `\\\nprint(\"# Welcome to your interactive shell simulation.\")\nprint(\"Type your commands below. Supported commands for this exercise are:\")\nprint(\" - git lfs install\")\nprint(\" - git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B\")\nprint(\" - ls -lh Meta-Llama-3-8B/model/\")\n\ndef simulate_command(command: str) -> str:\n    \\\"\"\"\n    Simulates terminal command responses related to Git LFS install and cloning the Meta-Llama-3-8B model repository.\n\n    Parameters\n    ----------\n    command : str\n        The command entered by the user.\n\n    Returns\n    -------\n    str\n        The simulated terminal output corresponding to the command.\n    \\\"\"\"\n    command = command.strip().lower()\n    if command == \"git lfs install\":\n        return (\n            \"Git LFS initialized.\\\\n\"\n            \"Tracking *.safetensors files.\\\\n\"\n            \"Smudge and clean filters configured.\\\\n\"\n            \"Git LFS is now enabled for this repository.\"\n        )\n    if command.startswith(\"git clone\"):\n        if \"meta-llama-3-8b\" not in command:\n            return \"fatal: repository not found.\"\n        return (\n            \"Cloning into 'Meta-Llama-3-8B'...\\\\n\"\n            \"Git LFS: (0 of 30 files, 0 skipped) 0 B / 40.0 GB\\\\n\"\n            \"Filtering content: 100% (30/30), 40.00 GB | 45.00 MB/s\\\\n\"\n            \"Check out the latest commit: abc123def456\\\\n\"\n            \"Clone completed successfully.\\\\n\"\n            \"Large files downloaded via Git LFS.\"\n        )\n    if command == \"ls -lh meta-llama-3-8b/model/\":\n        # Show sample list of .safetensors files and their sizes\n        return (\n            \"total 40G\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_1.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_2.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_3.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_4.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_5.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_6.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_7.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_8.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_9.safetensors\\\\n\"\n            \"-rw-r--r-- 1 user user 4.0G Feb 25 12:00 model_part_10.safetensors\\\\n\"\n        )\n    return f\"-bash: {command}: command not found\"\n\nwhile True:\n    try:\n        user_input = input(\"➜ $ \")\n        if user_input.lower() in {\"exit\", \"quit\"}:\n            print(\"Exiting simulation.\")\n            break\n        output = simulate_command(user_input)\n        print(output)\n    except EOFError:\n        print(\"\\\\nExiting simulation.\")\n        break\n`;\n\n  const hints = [\n    \"Git LFS (Large File Storage) is a Git extension designed to handle large files efficiently.\",\n    \"Before cloning a repository with large files, run 'git lfs install' to initialize Git LFS tracking locally.\",\n    \"The 'git clone' command automatically downloads large files through Git LFS if the repository is configured correctly.\",\n    \"Files tracked with Git LFS are replaced by pointer files in the repository, reducing storage and bandwidth.\",\n    \"Use 'ls -lh' on the repository's model directory to verify downloaded large files, typically stored with the '.safetensors' extension.\"\n  ];\n\n  let currentHintIndex = 0;\n\n  const hintBtn = document.getElementById(\"hint-btn\");\n  const hintsList = document.getElementById(\"hints-list\");\n\n  hintBtn.addEventListener(\"click\", () => {\n    if (currentHintIndex === 0) {\n      hintsList.style.display = \"block\";\n      hintBtn.setAttribute(\"aria-expanded\", \"true\");\n    }\n    if (currentHintIndex < hints.length) {\n      const li = document.createElement(\"li\");\n      li.textContent = hints[currentHintIndex];\n      hintsList.appendChild(li);\n      currentHintIndex += 1;\n      if (currentHintIndex === hints.length) {\n        hintBtn.disabled = true;\n        hintBtn.textContent = \"All hints revealed\";\n      }\n    }\n  });\n\n  // Initialize CodeMirror editor\n  const editorHost = document.getElementById(\"code-input\");\n  window.editor = createEditor(editorHost, starterCode);\n\n  // Pyodide loading and setup\n  let pyodide = null;\n  const runBtn = document.getElementById(\"run-btn\");\n  const status = document.getElementById(\"status\");\n  const outputElem = document.getElementById(\"output\");\n  const testResultsElem = document.getElementById(\"test-results\");\n  const showSolutionBtn = document.getElementById(\"show-solution-btn\");\n  const solutionElem = document.getElementById(\"solution\");\n\n  showSolutionBtn.addEventListener(\"click\", () => {\n    if (solutionElem.style.display === \"none\") {\n      solutionElem.style.display = \"\";\n      showSolutionBtn.textContent = \"Hide solution\";\n      showSolutionBtn.setAttribute(\"aria-expanded\", \"true\");\n      // Reveal the solution panel on demand for postMessage compatibility\n      window.dispatchEvent(new MessageEvent('message', {data: {type: 'REVEAL_ELEMENT', target: '#solution'}}));\n    } else {\n      solutionElem.style.display = \"none\";\n      showSolutionBtn.textContent = \"Show solution\";\n      showSolutionBtn.setAttribute(\"aria-expanded\", \"false\");\n    }\n  });\n\n  async function initPyodide() {\n    try {\n      status.textContent = \"Initializing Python runtime...\";\n      pyodide = await loadPyodide({indexURL : \"https://cdn.jsdelivr.net/pyodide/v0.23.4/full/\"});\n      // No additional packages needed for simulation, but if we did, load like this:\n      // await pyodide.loadPackage(['numpy']);\n      runBtn.disabled = false;\n      status.textContent = \"Python environment ready\";\n    } catch (e) {\n      status.textContent = \"Failed to load Python environment\";\n      outputElem.textContent = \"Error during Pyodide initialization:\\n\" + e.message;\n    }\n  }\n  initPyodide();\n\n  async function runCode() {\n    if (!pyodide) {\n      alert(\"Python environment not ready\");\n      return;\n    }\n    runBtn.disabled = true;\n    status.textContent = \"Running code...\";\n    outputElem.textContent = \"\";\n    testResultsElem.textContent = \"\";\n    try {\n      const code = editor.state.doc.toString();\n\n      // Setup stdout capture as per specification\n      await pyodide.runPythonAsync(`\nimport sys\nimport io\nsys.stdout = io.StringIO()\n`);\n\n      const commands = document.getElementById(\"terminal-input\").value.split(\"\\n\");\n      pyodide.setStdin({stdin: () => commands.length ? commands.shift() : null});\n      // Evaluate user code asynchronously\n      await pyodide.runPythonAsync(code);\n\n      // Retrieve stdout captured text\n      const output = pyodide.runPython('sys.stdout.getvalue()');\n      outputElem.textContent = output;\n      status.textContent = \"Execution completed\";\n\n      validateTests(code, output);\n    } catch (e) {\n      outputElem.textContent = `Error: ${e.message}`;\n      status.textContent = \"Execution failed\";\n    } finally {\n      runBtn.disabled = false;\n    }\n  }\n\n  // Since the simulation is interactive by design, tests will verify that at least\n  // the initial instructions are preserved and simulated commands function as expected.\n  // This is a pedagogic aid rather than a strict correctness criterion.\n  function validateTests(userCode, output) {\n    testResultsElem.innerHTML = \"\";\n    const tests = [\n      {\n        id: \"t1\",\n        description: \"Starter code includes prompt for 'git lfs install'\",\n        passed: /git lfs install/i.test(userCode)\n      },\n      {\n        id: \"t2\",\n        description: \"Simulate 'git lfs install' command in output\",\n        passed: output.includes(\"Git LFS initialized\")\n      },\n      {\n        id: \"t3\",\n        description: \"Simulate 'git clone' command in output\",\n        passed: output.includes(\"Cloning into 'Meta-Llama-3-8B'\") && output.includes(\"Large files downloaded via Git LFS.\")\n      },\n      {\n        id: \"t4\",\n        description: \"Simulate 'ls -lh ...' displays .safetensors files\",\n        passed: output.includes(\".safetensors\")\n      }\n    ];\n\n    for (const test of tests) {\n      const div = document.createElement(\"div\");\n      div.classList.add(\"test-case\");\n      div.classList.add(test.passed ? \"pass\" : \"fail\");\n      div.textContent = (test.passed ? \"✓ \" : \"✗ \") + test.description;\n      testResultsElem.appendChild(div);\n    }\n  }\n\n  runBtn.addEventListener(\"click\", runCode);\n\n  // Implement postMessage listener as required\n  window.addEventListener(\"message\", function(event) {\n    const { type, target, state, content } = event.data;\n\n    switch (type) {\n      case \"SET_WIDGET_STATE\":\n        // state: { code: \"...\", run: true }\n        if (state && typeof state.code === \"string\") {\n          if (typeof editor !== \"undefined\" && typeof editor.dispatch === \"function\") {\n            const transaction = editor.state.update({\n              changes: { from: 0, to: editor.state.doc.length, insert: state.code }\n            });\n            editor.dispatch(transaction);\n          } else {\n            const ta = document.getElementById(\"code-input\");\n            if (ta) ta.value = state.code;\n          }\n        }\n        if (state && state.run && typeof runCode === \"function\") {\n          runCode();\n        }\n        break;\n\n      case \"HIGHLIGHT_ELEMENT\":\n        const highlightEl = document.querySelector(target);\n        if (highlightEl) {\n          highlightEl.style.outline = \"3px solid rgba(139, 92, 246, 0.8)\";\n          highlightEl.style.outlineOffset = \"4px\";\n          highlightEl.style.animation = \"pulse-highlight 2s infinite\";\n          setTimeout(() => {\n            highlightEl.style.outline = \"\";\n            highlightEl.style.animation = \"\";\n          }, 3000);\n        }\n        break;\n\n      case \"ANNOTATE_ELEMENT\":\n        const annotateEl = document.querySelector(target);\n        if (annotateEl && content) {\n          const rect = annotateEl.getBoundingClientRect();\n          const tooltip = document.createElement(\"div\");\n          tooltip.className = \"teacher-annotation\";\n          tooltip.style.cssText = \n            \"position:fixed; top:\" + (rect.top - 40) + \"px; left:\" + rect.left + \n            \"px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;\";\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n        break;\n\n      case \"REVEAL_ELEMENT\":\n        const revealEl = document.querySelector(target);\n        if (revealEl) {\n          revealEl.style.display = \"\";\n          revealEl.style.opacity = \"1\";\n        }\n        break;\n    }\n  });\n\n  // Add global styles for highlight animations\n  const style = document.createElement(\"style\");\n  style.textContent = `\n@keyframes pulse-highlight {\n  0%, 100% { outline-color: rgba(139, 92, 246, 0.8); }\n  50% { outline-color: rgba(139, 92, 246, 0.4); }\n}\n@keyframes fadeIn {\n  from { opacity: 0; transform: translateY(10px); }\n  to { opacity: 1; transform: translateY(0); }\n}`;\n  document.head.appendChild(style);\n</script>\n\n<!-- Pyodide -->\n<script src=\"https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js\"></script>\n\n<script>\n  // Prevent form submission or lost focus on enter key in CodeMirror editor for better UX\n  document.getElementById(\"code-input\").addEventListener(\"keydown\", (e) => {\n    if (e.key === \"Enter\" && (e.ctrlKey || e.metaKey)) {\n      e.preventDefault();\n      document.getElementById(\"run-btn\").click();\n    }\n  });\n</script>\n\n<script type=\"application/json\" id=\"widget-config\" style=\"display:none\">\n{\n  \"type\": \"code\",\n  \"language\": \"python\",\n  \"description\": \"In this hands-on exercise, you will simulate the installation of Git Large File Storage (Git LFS) and cloning a large AI model's repository (~40 GB) to understand the workflow of managing large models in machine learning projects.\",\n  \"starterCode\": \"print(\\\"# Welcome to your interactive shell simulation.\\\")\\nprint(\\\"Type your commands below. Supported commands for this exercise are:\\\")\\nprint(\\\" - git lfs install\\\")\\nprint(\\\" - git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B\\\")\\nprint(\\\" - ls -lh Meta-Llama-3-8B/model/\\\")\\n\\n# (See full simulation code in the editor above)\",\n  \"testCases\": [\n    { \"id\": \"t1\", \"input\": \"contains 'git lfs install'\", \"expected\": true, \"description\": \"Starter code must mention 'git lfs install' command\" },\n    { \"id\": \"t2\", \"input\": \"'git lfs install'\", \"expected\": \"Git LFS initialized.\", \"description\": \"Simulate 'git lfs install' command output\" },\n    { \"id\": \"t3\", \"input\": \"'git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B'\", \"expected\": \"Cloning into 'Meta-Llama-3-8B'...\", \"description\": \"Simulate cloning with Git LFS filtering\" },\n    { \"id\": \"t4\", \"input\": \"'ls -lh Meta-Llama-3-8B/model/'\", \"expected\": \".safetensors\", \"description\": \"Show local safetensors model files after cloning\" }\n  ],\n  \"hints\": [\n    \"Git LFS enables tracking and management of files larger than usual Git size limits.\",\n    \"Running 'git lfs install' activates Git LFS filters on your local Git repository.\",\n    \"Git LFS replaces large files with pointers in your main repository while storing the actual data remotely.\",\n    \"Cloning a Git LFS-enabled repo downloads pointers first, then downloads actual large files behind the scenes.\",\n    \"Inspect your local clone's model directory to verify downloaded large model files, typically with .safetensors extensions.\"\n  ],\n  \"solution\": \"See the code block inside the editor titled 'solution' for the full simulation implementation in Python simulating shell commands for git lfs install, cloning, and ls.\"\n}\n</script>\n</body>\n</html>",
    "reason": "Use the actual gated model repository instead of a nonexistent GitHub/model identifier.",
    "reference": "https://huggingface.co/meta-llama/Meta-Llama-3-8B"
  },
  {
    "file": "25_huggingface-git_highschool.json",
    "path": "root.classroom.scenes[4].content.html",
    "before": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Cloning a 40GB Model Demo - Interactive Diagram</title>\n<style>\n  /* Dark background and white nodes */\n  body, html {\n    margin: 0; padding: 0; height: 100%;\n    background: #111118;\n    color: #eee;\n    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n    user-select:none;\n  }\n  #container {\n    display: flex;\n    height: 100vh;\n    overflow: hidden;\n  }\n  #sidebar {\n    background: #1f1f2f;\n    width: 320px;\n    min-width: 280px;\n    max-width: 80vw;\n    transition: transform 0.3s ease;\n    box-shadow: 2px 0 8px rgba(0,0,0,0.8);\n    display: flex;\n    flex-direction: column;\n    padding: 20px 25px 14px;\n    box-sizing: border-box;\n    overflow-y: auto;\n    z-index:10;\n  }\n  #sidebar.collapsed {\n    transform: translateX(-100%);\n  }\n  #sidebar header {\n    font-size: 1.6rem;\n    font-weight: 700;\n    margin-bottom: 12px;\n    color: #8b5cf6;\n    user-select:none;\n  }\n  #sidebar .details {\n    font-size: 1rem;\n    line-height: 1.4;\n    white-space: pre-wrap;\n    margin-bottom: 12px;\n  }\n  #sidebar .details code {\n    background: #33334d;\n    border-radius: 4px;\n    padding: 2px 5px;\n    font-family: monospace;\n    font-weight: 600;\n  }\n  #sidebar .progress-bar {\n    background: #2d2d42;\n    border-radius: 14px;\n    overflow: hidden;\n    height: 20px;\n  }\n  #sidebar .progress-bar > div {\n    height: 100%;\n    background: #8b5cf6;\n    width: 0;\n    transition: width 0.4s ease;\n  }\n  #sidebar .file-list {\n    background: #222235;\n    padding: 12px 16px;\n    border-radius: 8px;\n    font-family: monospace;\n    font-size: 0.9rem;\n    max-height: 120px;\n    overflow-y: auto;\n    color: #ccccee;\n  }\n  #sidebar .step-controls {\n    margin-top: auto;\n    display: flex;\n    justify-content: space-between;\n    gap: 8px;\n  }\n  #sidebar button {\n    background: #6d5dfc;\n    border: none;\n    border-radius: 6px;\n    color: white;\n    font-weight: 700;\n    font-size: 1rem;\n    padding: 10px 18px;\n    cursor: pointer;\n    user-select:none;\n    transition: background-color 0.2s ease;\n  }\n  #sidebar button:disabled {\n    background: #4b44b1;\n    cursor: not-allowed;\n  }\n  #toggle-sidebar {\n    position: absolute;\n    top: 14px;\n    left: 14px;\n    background: #6d5dfc;\n    border-radius: 8px;\n    width: 36px;\n    height: 36px;\n    border: none;\n    color: white;\n    font-weight: 700;\n    font-size: 1.5rem;\n    cursor: pointer;\n    z-index: 40;\n    user-select:none;\n  }\n\n  #diagram-wrapper {\n    position: relative;\n    flex-grow: 1;\n    overflow: auto;\n    /* Padding for nodes not cut on edges */\n    padding: 40px 60px 80px 60px;\n    -webkit-tap-highlight-color: transparent;\n  }\n\n  svg {\n    min-width: 100%;\n    min-height: 100%;\n  }\n\n  /* Node style */\n  .node-group {\n    cursor: pointer;\n    opacity: 0.35;\n    transition: opacity 0.3s ease;\n  }\n  .node-group.active {\n    opacity: 1;\n  }\n  .node-rect {\n    fill: #fff;\n    rx: 14;\n    ry: 14;\n    filter: drop-shadow(1px 2px 1px rgba(0,0,0,0.25));\n  }\n  .node-icon {\n    font-size: 2.5rem;\n    user-select:none;\n  }\n  .node-label {\n    fill: #111118;\n    font-weight: 700;\n    font-size: 1.1rem;\n    user-select:none;\n  }\n  .node-internal-label {\n    fill: #444458;\n    font-size: 0.85rem;\n    pointer-events: none;\n  }\n\n  /* Edge style */\n  .edge-line {\n    stroke: #aaaadc88;\n    stroke-width: 2;\n    fill: none;\n  }\n  .edge-arrow {\n    fill: #cccceeff;\n  }\n  .edge-label {\n    fill: #cccceeff;\n    font-size: 0.8rem;\n    user-select:none;\n    pointer-events:none;\n    font-style: italic;\n  }\n\n  /* Tooltip in sidebar – show details upon clicking node */\n  #node-details {\n    white-space: pre-wrap;\n    margin-top: 10px;\n    color: #ddddee;\n  }\n\n  /* Responsive tweaks */\n  @media (max-width: 700px) {\n    #sidebar {\n      position: fixed;\n      top: 0;\n      left: 0;\n      height: 100%;\n      z-index: 30;\n    }\n    #diagram-wrapper {\n      padding: 20px 20px 80px 20px;\n    }\n    #toggle-sidebar {\n      top: 10px;\n      left: 10px;\n    }\n  }\n\n  /* Animation for highlight from postMessage */\n  @keyframes pulse-highlight {\n    0%, 100% { outline-color: rgba(139, 92, 246, 0.8); }\n    50% { outline-color: rgba(139, 92, 246, 0.4); }\n  }\n  @keyframes fadeIn {\n    from { opacity: 0; transform: translateY(10px); }\n    to { opacity: 1; transform: translateY(0); }\n  }\n\n  /* Teacher annotation style */\n  .teacher-annotation {\n    user-select:none;\n    pointer-events:none;\n  }\n</style>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<button id=\"toggle-sidebar\" aria-label=\"Toggle sidebar\" title=\"Toggle sidebar\">☰</button>\n<div id=\"container\" role=\"main\" aria-label=\"Cloning a 40GB Model Demo interactive diagram container\">\n  <aside id=\"sidebar\" role=\"region\" aria-labelledby=\"sidebarTitle\" tabindex=\"-1\">\n    <h2 id=\"sidebarTitle\">Step Details</h2>\n    <div id=\"sidebar-content\" tabindex=\"0\">\n      <div id=\"node-icon-large\" aria-hidden=\"true\" style=\"font-size:4.2rem; margin-bottom: 6px; color:#8b5cf6;\">🎯</div>\n      <h3 id=\"node-label\" style=\"margin-top:0; margin-bottom:6px; color:#8b5cf6; font-weight:700;\">Loading...</h3>\n      <div id=\"node-details\" aria-live=\"polite\" aria-atomic=\"true\">Please select a step or use the buttons below to navigate.</div>\n      <div id=\"progress-container\" style=\"margin-top: 14px; display: none;\">\n        <label for=\"progress-bar\" style=\"font-weight:700; font-size:1rem; color:#aaaaff;\">Downloading files progress:</label>\n        <div class=\"progress-bar\" aria-label=\"Download progress\">\n          <div id=\"progress-bar\"></div>\n        </div>\n      </div>\n      <div id=\"file-list-container\" style=\"margin-top:14px; display:none;\">\n        <div class=\"file-list\" aria-label=\"List of model files downloaded\" tabindex=\"0\"></div>\n      </div>\n    </div>\n    <nav class=\"step-controls\" aria-label=\"Step navigation controls\">\n      <button id=\"btn-prev\" aria-label=\"Previous step\" disabled>← Previous</button>\n      <button id=\"btn-next\" aria-label=\"Next step\">Next →</button>\n    </nav>\n  </aside>\n  <div id=\"diagram-wrapper\" role=\"img\" aria-label=\"Diagram illustrating the cloning process of a large model repository\">\n    <svg id=\"diagramSVG\" width=\"100%\" height=\"100%\" viewBox=\"0 0 960 600\" role=\"presentation\" aria-hidden=\"true\"></svg>\n  </div>\n</div>\n\n<script type=\"application/json\" id=\"widget-config\">\n{\n  \"nodes\": [\n    {\n      \"id\": \"install-lfs\",\n      \"label\": \"Install Git LFS\",\n      \"icon\": \"🛠️\",\n      \"details\": \"Git LFS stands for Git Large File Storage.\\n\\nIt helps you handle very big files like models, videos, or game assets.\\n\\nThink of it as a special backpack in a video game that stores your biggest weapons so your inventory doesn’t get full!\\n\\nCommand:\\n`git lfs install`\"\n    },\n    {\n      \"id\": \"init-clone\",\n      \"label\": \"Clone Meta-Llama-3-8B Repo\",\n      \"icon\": \"📥\",\n      \"details\": \"To get the entire model, you use the regular git clone command.\\n\\nIt’s like downloading a photo album from social media — except this album is super huge (40GB!).\\n\\nCommand:\\n`git clone https://huggingface.co/meta-llama/Meta-Llama-3-8b`\"\n    },\n    {\n      \"id\": \"download-files\",\n      \"label\": \"Downloading Files\",\n      \"icon\": \"📂\",\n      \"details\": \"Git LFS downloads the huge files separately, like waiting for game patches to finish downloading in the background.\\n\\nYou’ll see progress bars showing how much has downloaded.\\n\\nDownloading big files might take minutes to hours depending on your internet speed!\"\n    },\n    {\n      \"id\": \"files-ready\",\n      \"label\": \"Files Ready!\",\n      \"icon\": \"✅\",\n      \"details\": \"All files are downloaded and ready.\\n\\nYou can now load the model and start experimenting or coding!\\n\\nIt’s just like unboxing your brand new gaming console or software and powering it on.\\n\\nHere is a list of main files and their sizes below.\"\n    }\n  ],\n  \"edges\": [\n    {\"from\": \"install-lfs\", \"to\": \"init-clone\", \"label\": \"next\"},\n    {\"from\": \"init-clone\", \"to\": \"download-files\", \"label\": \"next\"},\n    {\"from\": \"download-files\", \"to\": \"files-ready\", \"label\": \"next\"}\n  ],\n  \"revealOrder\": [\"install-lfs\", \"init-clone\", \"download-files\", \"files-ready\"]\n}\n</script>\n\n<script>\n(() => {\n  const NODE_WIDTH = 180;\n  const NODE_HEIGHT = 70;\n  const ARROW_OFFSET = 10;\n\n  // Parse config\n  const config = JSON.parse(document.getElementById('widget-config').textContent);\n  const { nodes, edges, revealOrder } = config;\n\n  // Map nodes by id\n  const nodesMap = {};\n  nodes.forEach(n => nodesMap[n.id] = {...n});\n\n  // Compute layout positions (simple horizontal flow)\n  // We'll spread nodes horizontally with spacing, vertically centered\n  // Make sure edges do not overlap nodes - simple line draw with arrow heads\n  // Diagram size: width: 960, height: 600\n\n  /*\n   Layout approach:\n   Place nodes evenly horizontally, Y fixed at 300:\n   - Distance between nodes about 220 px horizontally\n   - Center vertical at 300px mid\n  */\n  const diagramWidth = 960;\n  const diagramHeight = 600;\n  const centerY = diagramHeight / 2;\n  const spacingX = 220;\n  const startX = (diagramWidth - spacingX * (nodes.length - 1)) / 2;\n\n  revealOrder.forEach((id, i) => {\n    nodesMap[id].x = startX + i * spacingX;\n    nodesMap[id].y = centerY;\n  });\n\n  // SVG container\n  const SVG_NS = \"http://www.w3.org/2000/svg\";\n  const svg = document.getElementById('diagramSVG');\n\n  // Clear any existing children\n  while(svg.firstChild) {\n    svg.removeChild(svg.firstChild);\n  }\n\n  // Define arrow marker for edges\n  const defs = document.createElementNS(SVG_NS, \"defs\");\n  defs.innerHTML = `\n    <marker id=\"arrowhead\" markerWidth=\"10\" markerHeight=\"7\" refX=\"10\" refY=\"3.5\" orient=\"auto\" markerUnits=\"strokeWidth\">\n      <path d=\"M 0 0 L 10 3.5 L 0 7 z\" fill=\"#cccceeff\" />\n    </marker>`;\n  svg.appendChild(defs);\n\n  // Draw edges first so they appear below nodes\n  edges.forEach(({from, to, label}) => {\n    const fromNode = nodesMap[from];\n    const toNode = nodesMap[to];\n    if (!fromNode || !toNode) return;\n\n    // Calculate points following rules provided\n    const dx = toNode.x - fromNode.x, dy = toNode.y - fromNode.y;\n    let sx, sy, ex, ey;\n    if (Math.abs(dy) > Math.abs(dx)) { // vertical\n      sx = fromNode.x;\n      sy = dy > 0 ? fromNode.y + NODE_HEIGHT/2 : fromNode.y - NODE_HEIGHT/2;\n      ex = toNode.x;\n      ey = dy > 0 ? toNode.y - NODE_HEIGHT/2 - ARROW_OFFSET : toNode.y + NODE_HEIGHT/2 + ARROW_OFFSET;\n    } else { // horizontal\n      sx = dx > 0 ? fromNode.x + NODE_WIDTH/2 : fromNode.x - NODE_WIDTH/2;\n      sy = fromNode.y;\n      ex = dx > 0 ? toNode.x - NODE_WIDTH/2 - ARROW_OFFSET : toNode.x + NODE_WIDTH/2 + ARROW_OFFSET;\n      ey = toNode.y;\n    }\n\n    // Draw path line\n    const path = document.createElementNS(SVG_NS, \"path\");\n    path.setAttribute(\"class\", \"edge-line\");\n    path.setAttribute(\"d\", `M ${sx} ${sy} L ${ex} ${ey}`);\n    path.setAttribute(\"marker-end\", \"url(#arrowhead)\");\n    svg.appendChild(path);\n\n    // Edge label (placed midpoint with slight offset)\n    const labelEl = document.createElementNS(SVG_NS, \"text\");\n    labelEl.setAttribute('class', 'edge-label');\n    labelEl.setAttribute('id', `edge-${from}-${to}`);\n    const midX = (sx + ex) / 2;\n    const midY = (sy + ey) / 2;\n    const offset = 14;\n    let labelX = midX;\n    let labelY = midY - offset;\n    labelEl.setAttribute('x', labelX);\n    labelEl.setAttribute('y', labelY);\n    labelEl.textContent = label;\n    svg.appendChild(labelEl);\n  });\n\n  // Draw nodes on top\n  nodes.forEach(({id, label, icon, x, y}) => {\n    const g = document.createElementNS(SVG_NS, \"g\");\n    g.classList.add('node-group');\n    g.setAttribute('id', `node-${id}`);\n    g.setAttribute('data-node', id);\n    g.setAttribute('tabindex', '0');\n    g.setAttribute('role', 'button');\n    g.setAttribute('aria-pressed', 'false');\n    g.setAttribute('aria-label', `Step: ${label}. Click to view details.`);\n\n    g.style.transformOrigin = `${x}px ${y}px`;\n    g.style.transformBox = 'fill-box';\n\n    // Position the group (use translate)\n    g.setAttribute('transform', `translate(${x},${y})`);\n\n    // Rectangle background:\n    const rect = document.createElementNS(SVG_NS, \"rect\");\n    rect.setAttribute('class', 'node-rect');\n    rect.setAttribute('x', -NODE_WIDTH/2);\n    rect.setAttribute('y', -NODE_HEIGHT/2);\n    rect.setAttribute('width', NODE_WIDTH);\n    rect.setAttribute('height', NODE_HEIGHT);\n    g.appendChild(rect);\n\n    // Icon centered left\n    const iconText = document.createElementNS(SVG_NS, \"text\");\n    iconText.setAttribute('class', 'node-icon');\n    iconText.setAttribute('x', -NODE_WIDTH/2 + 28);\n    iconText.setAttribute('y', 10);\n    iconText.setAttribute('dominant-baseline', 'middle');\n    iconText.setAttribute('text-anchor', 'middle');\n    iconText.textContent = icon;\n    g.appendChild(iconText);\n\n    // Label right to icon\n    const labelText = document.createElementNS(SVG_NS, \"text\");\n    labelText.setAttribute('class', 'node-label');\n    labelText.setAttribute('x', -NODE_WIDTH/2 + 80);\n    labelText.setAttribute('y', 6);\n    labelText.setAttribute('text-anchor', 'start');\n    labelText.setAttribute('dominant-baseline', 'baseline');\n    labelText.textContent = label;\n    g.appendChild(labelText);\n\n    svg.appendChild(g);\n  });\n\n  // Interaction logic\n  let currentStepIndex = 0;\n\n  const nodeGroups = revealOrder.map(id => document.getElementById('node-' + id));\n  const sidebar = document.getElementById('sidebar');\n  const nodeIconLarge = document.getElementById('node-icon-large');\n  const nodeLabelEl = document.getElementById('node-label');\n  const nodeDetailsEl = document.getElementById('node-details');\n  const btnNext = document.getElementById('btn-next');\n  const btnPrev = document.getElementById('btn-prev');\n  const progressContainer = document.getElementById('progress-container');\n  const progressBar = document.getElementById('progress-bar');\n  const fileListContainer = document.getElementById('file-list-container');\n  const fileListEl = fileListContainer.querySelector('.file-list');\n\n  const toggleSidebarBtn = document.getElementById('toggle-sidebar');\n\n  // Demo file list for final step\n  const modelFiles = [\n    'meta-llama-3-8b-config.json (12 KB)',\n    'pytorch_model-00001-of-00002.bin (19 GB)',\n    'pytorch_model-00002-of-00002.bin (21 GB)',\n    'tokenizer.model (2 MB)',\n    'README.md (1 KB)'\n  ];\n\n  // Show step details in sidebar for given node id\n  function showStepDetails(id){\n    const node = nodesMap[id];\n    if (!node) return;\n\n    // Update icons and text\n    nodeIconLarge.textContent = node.icon;\n    nodeLabelEl.textContent = node.label;\n    nodeDetailsEl.textContent = node.details;\n\n    // Reset sidebar scroll top with smooth scroll\n    sidebar.querySelector('#sidebar-content').scrollTo({ top: 0, behavior: 'smooth' });\n\n    // Reset aria-pressed on all nodes, set on current:\n    nodeGroups.forEach((g, i) => {\n      const isCurrent = (revealOrder[i] === id);\n      g.setAttribute('aria-pressed', isCurrent ? 'true' : 'false');\n      if (isCurrent) {\n        g.classList.add('active');\n        g.style.opacity = '1';\n      } else {\n        g.classList.remove('active');\n        g.style.opacity = '0.35';\n      }\n    });\n\n    // Show/hide download progress or file list for relevant steps\n    if (id === 'download-files') {\n      progressContainer.style.display = 'block';\n      progressBar.style.width = '0%';\n      fileListContainer.style.display = 'none';\n      simulateFileDownloadProgress();\n    } else if (id === 'files-ready') {\n      progressContainer.style.display = 'none';\n      fileListContainer.style.display = 'block';\n      // Populate file list\n      fileListEl.textContent = '';\n      modelFiles.forEach(f => {\n        const li = document.createElement('div');\n        li.textContent = \"• \" + f;\n        fileListEl.appendChild(li);\n      });\n    } else {\n      progressContainer.style.display = 'none';\n      fileListContainer.style.display = 'none';\n    }\n\n    // Announce step for screen readers (aria-live region is nodeDetailsEl)\n  }\n\n  // Simulated download progress for demo (update every 450ms)\n  let downloadProgressInterval = null;\n  let currentProgress = 0;\n  function simulateFileDownloadProgress(){\n    if (downloadProgressInterval) {\n      clearInterval(downloadProgressInterval);\n      downloadProgressInterval = null;\n    }\n    currentProgress = 0;\n    progressBar.style.width = '0%';\n    downloadProgressInterval = setInterval(() => {\n      currentProgress += Math.random() * 10 + 5; // +5% to +15%\n      if (currentProgress >= 100) {\n        currentProgress = 100;\n        progressBar.style.width = '100%';\n        clearInterval(downloadProgressInterval);\n        downloadProgressInterval = null;\n        btnNext.disabled = false;\n        btnNext.focus();\n      } else {\n        progressBar.style.width = currentProgress.toFixed(1) + '%';\n      }\n    }, 450);\n  }\n\n  // Show current step details on load\n  function setCurrentStep(index) {\n    currentStepIndex = Math.min(Math.max(0, index), revealOrder.length - 1);\n\n    // Update button states\n    btnPrev.disabled = currentStepIndex === 0;\n    btnNext.disabled = false;\n    // For download step we disable next until simulated download done\n    if (revealOrder[currentStepIndex] === 'download-files') btnNext.disabled = true;\n\n    showStepDetails(revealOrder[currentStepIndex]);\n    // Center the current node in SVG viewport for better focus on large screens\n    centerNodeInView(revealOrder[currentStepIndex]);\n  }\n\n  // Center the diagram wrapper view to the chosen node\n  function centerNodeInView(id) {\n    const nodeEl = document.getElementById('node-' + id);\n    if (!nodeEl) return;\n    const diagramWrapper = document.getElementById('diagram-wrapper');\n    const rect = nodeEl.getBoundingClientRect();\n    const wrapperRect = diagramWrapper.getBoundingClientRect();\n\n    // Calculate center of SVG relative to wrapper\n    const scrollX = (rect.left + rect.right) / 2 - wrapperRect.left - wrapperRect.width/2;\n    const scrollY = (rect.top + rect.bottom) / 2 - wrapperRect.top - wrapperRect.height/2;\n\n    diagramWrapper.scrollBy({ left: scrollX, top: scrollY, behavior: 'smooth' });\n  }\n\n  // Event listeners for navigation buttons\n  btnPrev.addEventListener('click', () => {\n    setCurrentStep(currentStepIndex - 1);\n  });\n  btnNext.addEventListener('click', () => {\n    if (currentStepIndex === revealOrder.length -1) {\n      // On last step, wrap around to first step for fun\n      setCurrentStep(0);\n    } else {\n      setCurrentStep(currentStepIndex + 1);\n    }\n  });\n\n  // Click or keyboard interaction on nodes to show details and set active step\n  nodeGroups.forEach((nodeEl, i) => {\n    nodeEl.addEventListener('click', () => {\n      setCurrentStep(i);\n    });\n    nodeEl.addEventListener('keydown', e => {\n      if (e.key === \"Enter\" || e.key === \" \"){\n        e.preventDefault();\n        setCurrentStep(i);\n      }\n    });\n  });\n\n  // Sidebar toggle for mobile\n  toggleSidebarBtn.addEventListener('click', () => {\n    sidebar.classList.toggle('collapsed');\n    if (!sidebar.classList.contains('collapsed')){\n      sidebar.querySelector('#sidebar-content').focus();\n    }\n  });\n\n  // Start sidebar collapsed on small widths for better mobile UX\n  function checkSidebarOnResize(){\n    if (window.innerWidth < 720){\n      sidebar.classList.add('collapsed');\n    } else {\n      sidebar.classList.remove('collapsed');\n    }\n  }\n  window.addEventListener('resize', checkSidebarOnResize);\n  checkSidebarOnResize();\n\n  // Initialize - show first step\n  setCurrentStep(0);\n\n  // PostMessage listener as required\n  window.addEventListener('message', function(event) {\n    const { type, target, state, content } = event.data;\n\n    switch (type) {\n      case 'SET_WIDGET_STATE':\n        if (state) {\n          Object.entries(state).forEach(([key, value]) => {\n            const node = document.getElementById('node-' + key) || document.querySelector('[data-node=\"' + key + '\"]');\n            if (node) {\n              node.style.opacity = value ? '1' : '0.35';\n              node.classList.toggle('active', !!value);\n            }\n          });\n        }\n        break;\n\n      case 'HIGHLIGHT_ELEMENT':\n        const highlightEl = document.querySelector(target);\n        if (highlightEl) {\n          highlightEl.style.outline = '3px solid rgba(139, 92, 246, 0.8)';\n          highlightEl.style.outlineOffset = '4px';\n          highlightEl.style.animation = 'pulse-highlight 2s infinite';\n          setTimeout(() => {\n            highlightEl.style.outline = '';\n            highlightEl.style.animation = '';\n          }, 3000);\n        }\n        break;\n\n      case 'ANNOTATE_ELEMENT':\n        const annotateEl = document.querySelector(target);\n        if (annotateEl && content) {\n          const rect = annotateEl.getBoundingClientRect();\n          const tooltip = document.createElement('div');\n          tooltip.className = 'teacher-annotation';\n          tooltip.style.cssText = 'position:fixed; top:' + (rect.top - 40) + 'px; left:' + rect.left + 'px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;';\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n        break;\n\n      case 'REVEAL_ELEMENT':\n        const revealEl = document.querySelector(target);\n        if (revealEl) {\n          revealEl.style.display = '';\n          revealEl.style.opacity = '1';\n        }\n        break;\n    }\n  });\n\n})();\n</script>\n</body>\n</html>",
    "after": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Cloning a 40GB Model Demo - Interactive Diagram</title>\n<style>\n  /* Dark background and white nodes */\n  body, html {\n    margin: 0; padding: 0; height: 100%;\n    background: #111118;\n    color: #eee;\n    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n    user-select:none;\n  }\n  #container {\n    display: flex;\n    height: 100vh;\n    overflow: hidden;\n  }\n  #sidebar {\n    background: #1f1f2f;\n    width: 320px;\n    min-width: 280px;\n    max-width: 80vw;\n    transition: transform 0.3s ease;\n    box-shadow: 2px 0 8px rgba(0,0,0,0.8);\n    display: flex;\n    flex-direction: column;\n    padding: 20px 25px 14px;\n    box-sizing: border-box;\n    overflow-y: auto;\n    z-index:10;\n  }\n  #sidebar.collapsed {\n    transform: translateX(-100%);\n  }\n  #sidebar header {\n    font-size: 1.6rem;\n    font-weight: 700;\n    margin-bottom: 12px;\n    color: #8b5cf6;\n    user-select:none;\n  }\n  #sidebar .details {\n    font-size: 1rem;\n    line-height: 1.4;\n    white-space: pre-wrap;\n    margin-bottom: 12px;\n  }\n  #sidebar .details code {\n    background: #33334d;\n    border-radius: 4px;\n    padding: 2px 5px;\n    font-family: monospace;\n    font-weight: 600;\n  }\n  #sidebar .progress-bar {\n    background: #2d2d42;\n    border-radius: 14px;\n    overflow: hidden;\n    height: 20px;\n  }\n  #sidebar .progress-bar > div {\n    height: 100%;\n    background: #8b5cf6;\n    width: 0;\n    transition: width 0.4s ease;\n  }\n  #sidebar .file-list {\n    background: #222235;\n    padding: 12px 16px;\n    border-radius: 8px;\n    font-family: monospace;\n    font-size: 0.9rem;\n    max-height: 120px;\n    overflow-y: auto;\n    color: #ccccee;\n  }\n  #sidebar .step-controls {\n    margin-top: auto;\n    display: flex;\n    justify-content: space-between;\n    gap: 8px;\n  }\n  #sidebar button {\n    background: #6d5dfc;\n    border: none;\n    border-radius: 6px;\n    color: white;\n    font-weight: 700;\n    font-size: 1rem;\n    padding: 10px 18px;\n    cursor: pointer;\n    user-select:none;\n    transition: background-color 0.2s ease;\n  }\n  #sidebar button:disabled {\n    background: #4b44b1;\n    cursor: not-allowed;\n  }\n  #toggle-sidebar {\n    position: absolute;\n    top: 14px;\n    left: 14px;\n    background: #6d5dfc;\n    border-radius: 8px;\n    width: 36px;\n    height: 36px;\n    border: none;\n    color: white;\n    font-weight: 700;\n    font-size: 1.5rem;\n    cursor: pointer;\n    z-index: 40;\n    user-select:none;\n  }\n\n  #diagram-wrapper {\n    position: relative;\n    flex-grow: 1;\n    overflow: auto;\n    /* Padding for nodes not cut on edges */\n    padding: 40px 60px 80px 60px;\n    -webkit-tap-highlight-color: transparent;\n  }\n\n  svg {\n    min-width: 100%;\n    min-height: 100%;\n  }\n\n  /* Node style */\n  .node-group {\n    cursor: pointer;\n    opacity: 0.35;\n    transition: opacity 0.3s ease;\n  }\n  .node-group.active {\n    opacity: 1;\n  }\n  .node-rect {\n    fill: #fff;\n    rx: 14;\n    ry: 14;\n    filter: drop-shadow(1px 2px 1px rgba(0,0,0,0.25));\n  }\n  .node-icon {\n    font-size: 2.5rem;\n    user-select:none;\n  }\n  .node-label {\n    fill: #111118;\n    font-weight: 700;\n    font-size: 1.1rem;\n    user-select:none;\n  }\n  .node-internal-label {\n    fill: #444458;\n    font-size: 0.85rem;\n    pointer-events: none;\n  }\n\n  /* Edge style */\n  .edge-line {\n    stroke: #aaaadc88;\n    stroke-width: 2;\n    fill: none;\n  }\n  .edge-arrow {\n    fill: #cccceeff;\n  }\n  .edge-label {\n    fill: #cccceeff;\n    font-size: 0.8rem;\n    user-select:none;\n    pointer-events:none;\n    font-style: italic;\n  }\n\n  /* Tooltip in sidebar – show details upon clicking node */\n  #node-details {\n    white-space: pre-wrap;\n    margin-top: 10px;\n    color: #ddddee;\n  }\n\n  /* Responsive tweaks */\n  @media (max-width: 700px) {\n    #sidebar {\n      position: fixed;\n      top: 0;\n      left: 0;\n      height: 100%;\n      z-index: 30;\n    }\n    #diagram-wrapper {\n      padding: 20px 20px 80px 20px;\n    }\n    #toggle-sidebar {\n      top: 10px;\n      left: 10px;\n    }\n  }\n\n  /* Animation for highlight from postMessage */\n  @keyframes pulse-highlight {\n    0%, 100% { outline-color: rgba(139, 92, 246, 0.8); }\n    50% { outline-color: rgba(139, 92, 246, 0.4); }\n  }\n  @keyframes fadeIn {\n    from { opacity: 0; transform: translateY(10px); }\n    to { opacity: 1; transform: translateY(0); }\n  }\n\n  /* Teacher annotation style */\n  .teacher-annotation {\n    user-select:none;\n    pointer-events:none;\n  }\n</style>\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js\"></script>\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n    const katexOptions = {\n        delimiters: [\n            {left: '\\\\[', right: '\\\\]', display: true},\n            {left: '\\\\(', right: '\\\\)', display: false},\n            {left: '$$', right: '$$', display: true},\n            {left: '$', right: '$', display: false}\n        ],\n        throwOnError: false,\n        strict: false,\n        trust: true\n    };\n\n    let renderTimeout;\n    function safeRender() {\n        if (renderTimeout) clearTimeout(renderTimeout);\n        renderTimeout = setTimeout(() => {\n            renderMathInElement(document.body, katexOptions);\n        }, 100);\n    }\n\n    renderMathInElement(document.body, katexOptions);\n\n    const observer = new MutationObserver((mutations) => {\n        let shouldRender = false;\n        mutations.forEach((mutation) => {\n            if (mutation.target &&\n                mutation.target.className &&\n                typeof mutation.target.className === 'string' &&\n                mutation.target.className.includes('katex')) {\n                return;\n            }\n            shouldRender = true;\n        });\n\n        if (shouldRender) {\n            safeRender();\n        }\n    });\n\n    observer.observe(document.body, {\n        childList: true,\n        subtree: true,\n        characterData: true\n    });\n\n    setInterval(() => {\n        const text = document.body.innerText;\n        if (text.includes('\\\\(') || text.includes('$$')) {\n            safeRender();\n        }\n    }, 2000);\n});\n</script>\n</head>\n<body>\n<button id=\"toggle-sidebar\" aria-label=\"Toggle sidebar\" title=\"Toggle sidebar\">☰</button>\n<div id=\"container\" role=\"main\" aria-label=\"Cloning a 40GB Model Demo interactive diagram container\">\n  <aside id=\"sidebar\" role=\"region\" aria-labelledby=\"sidebarTitle\" tabindex=\"-1\">\n    <h2 id=\"sidebarTitle\">Step Details</h2>\n    <div id=\"sidebar-content\" tabindex=\"0\">\n      <div id=\"node-icon-large\" aria-hidden=\"true\" style=\"font-size:4.2rem; margin-bottom: 6px; color:#8b5cf6;\">🎯</div>\n      <h3 id=\"node-label\" style=\"margin-top:0; margin-bottom:6px; color:#8b5cf6; font-weight:700;\">Loading...</h3>\n      <div id=\"node-details\" aria-live=\"polite\" aria-atomic=\"true\">Please select a step or use the buttons below to navigate.</div>\n      <div id=\"progress-container\" style=\"margin-top: 14px; display: none;\">\n        <label for=\"progress-bar\" style=\"font-weight:700; font-size:1rem; color:#aaaaff;\">Downloading files progress:</label>\n        <div class=\"progress-bar\" aria-label=\"Download progress\">\n          <div id=\"progress-bar\"></div>\n        </div>\n      </div>\n      <div id=\"file-list-container\" style=\"margin-top:14px; display:none;\">\n        <div class=\"file-list\" aria-label=\"List of model files downloaded\" tabindex=\"0\"></div>\n      </div>\n    </div>\n    <nav class=\"step-controls\" aria-label=\"Step navigation controls\">\n      <button id=\"btn-prev\" aria-label=\"Previous step\" disabled>← Previous</button>\n      <button id=\"btn-next\" aria-label=\"Next step\">Next →</button>\n    </nav>\n  </aside>\n  <div id=\"diagram-wrapper\" role=\"img\" aria-label=\"Diagram illustrating the cloning process of a large model repository\">\n    <svg id=\"diagramSVG\" width=\"100%\" height=\"100%\" viewBox=\"0 0 960 600\" role=\"presentation\" aria-hidden=\"true\"></svg>\n  </div>\n</div>\n\n<script type=\"application/json\" id=\"widget-config\">\n{\n  \"nodes\": [\n    {\n      \"id\": \"install-lfs\",\n      \"label\": \"Install Git LFS\",\n      \"icon\": \"🛠️\",\n      \"details\": \"Git LFS stands for Git Large File Storage.\\n\\nIt helps you handle very big files like models, videos, or game assets.\\n\\nThink of it as a special backpack in a video game that stores your biggest weapons so your inventory doesn’t get full!\\n\\nCommand:\\n`git lfs install`\"\n    },\n    {\n      \"id\": \"init-clone\",\n      \"label\": \"Clone Meta-Llama-3-8B Repo\",\n      \"icon\": \"📥\",\n      \"details\": \"To get the entire model, you use the regular git clone command.\\n\\nIt’s like downloading a photo album from social media — except this album is super huge (40GB!).\\n\\nCommand:\\n`git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B`\"\n    },\n    {\n      \"id\": \"download-files\",\n      \"label\": \"Downloading Files\",\n      \"icon\": \"📂\",\n      \"details\": \"Git LFS downloads the huge files separately, like waiting for game patches to finish downloading in the background.\\n\\nYou’ll see progress bars showing how much has downloaded.\\n\\nDownloading big files might take minutes to hours depending on your internet speed!\"\n    },\n    {\n      \"id\": \"files-ready\",\n      \"label\": \"Files Ready!\",\n      \"icon\": \"✅\",\n      \"details\": \"All files are downloaded and ready.\\n\\nYou can now load the model and start experimenting or coding!\\n\\nIt’s just like unboxing your brand new gaming console or software and powering it on.\\n\\nHere is a list of main files and their sizes below.\"\n    }\n  ],\n  \"edges\": [\n    {\"from\": \"install-lfs\", \"to\": \"init-clone\", \"label\": \"next\"},\n    {\"from\": \"init-clone\", \"to\": \"download-files\", \"label\": \"next\"},\n    {\"from\": \"download-files\", \"to\": \"files-ready\", \"label\": \"next\"}\n  ],\n  \"revealOrder\": [\"install-lfs\", \"init-clone\", \"download-files\", \"files-ready\"]\n}\n</script>\n\n<script>\n(() => {\n  const NODE_WIDTH = 180;\n  const NODE_HEIGHT = 70;\n  const ARROW_OFFSET = 10;\n\n  // Parse config\n  const config = JSON.parse(document.getElementById('widget-config').textContent);\n  const { nodes, edges, revealOrder } = config;\n\n  // Map nodes by id\n  const nodesMap = {};\n  nodes.forEach(n => nodesMap[n.id] = {...n});\n\n  // Compute layout positions (simple horizontal flow)\n  // We'll spread nodes horizontally with spacing, vertically centered\n  // Make sure edges do not overlap nodes - simple line draw with arrow heads\n  // Diagram size: width: 960, height: 600\n\n  /*\n   Layout approach:\n   Place nodes evenly horizontally, Y fixed at 300:\n   - Distance between nodes about 220 px horizontally\n   - Center vertical at 300px mid\n  */\n  const diagramWidth = 960;\n  const diagramHeight = 600;\n  const centerY = diagramHeight / 2;\n  const spacingX = 220;\n  const startX = (diagramWidth - spacingX * (nodes.length - 1)) / 2;\n\n  revealOrder.forEach((id, i) => {\n    nodesMap[id].x = startX + i * spacingX;\n    nodesMap[id].y = centerY;\n  });\n\n  // SVG container\n  const SVG_NS = \"http://www.w3.org/2000/svg\";\n  const svg = document.getElementById('diagramSVG');\n\n  // Clear any existing children\n  while(svg.firstChild) {\n    svg.removeChild(svg.firstChild);\n  }\n\n  // Define arrow marker for edges\n  const defs = document.createElementNS(SVG_NS, \"defs\");\n  defs.innerHTML = `\n    <marker id=\"arrowhead\" markerWidth=\"10\" markerHeight=\"7\" refX=\"10\" refY=\"3.5\" orient=\"auto\" markerUnits=\"strokeWidth\">\n      <path d=\"M 0 0 L 10 3.5 L 0 7 z\" fill=\"#cccceeff\" />\n    </marker>`;\n  svg.appendChild(defs);\n\n  // Draw edges first so they appear below nodes\n  edges.forEach(({from, to, label}) => {\n    const fromNode = nodesMap[from];\n    const toNode = nodesMap[to];\n    if (!fromNode || !toNode) return;\n\n    // Calculate points following rules provided\n    const dx = toNode.x - fromNode.x, dy = toNode.y - fromNode.y;\n    let sx, sy, ex, ey;\n    if (Math.abs(dy) > Math.abs(dx)) { // vertical\n      sx = fromNode.x;\n      sy = dy > 0 ? fromNode.y + NODE_HEIGHT/2 : fromNode.y - NODE_HEIGHT/2;\n      ex = toNode.x;\n      ey = dy > 0 ? toNode.y - NODE_HEIGHT/2 - ARROW_OFFSET : toNode.y + NODE_HEIGHT/2 + ARROW_OFFSET;\n    } else { // horizontal\n      sx = dx > 0 ? fromNode.x + NODE_WIDTH/2 : fromNode.x - NODE_WIDTH/2;\n      sy = fromNode.y;\n      ex = dx > 0 ? toNode.x - NODE_WIDTH/2 - ARROW_OFFSET : toNode.x + NODE_WIDTH/2 + ARROW_OFFSET;\n      ey = toNode.y;\n    }\n\n    // Draw path line\n    const path = document.createElementNS(SVG_NS, \"path\");\n    path.setAttribute(\"class\", \"edge-line\");\n    path.setAttribute(\"d\", `M ${sx} ${sy} L ${ex} ${ey}`);\n    path.setAttribute(\"marker-end\", \"url(#arrowhead)\");\n    svg.appendChild(path);\n\n    // Edge label (placed midpoint with slight offset)\n    const labelEl = document.createElementNS(SVG_NS, \"text\");\n    labelEl.setAttribute('class', 'edge-label');\n    labelEl.setAttribute('id', `edge-${from}-${to}`);\n    const midX = (sx + ex) / 2;\n    const midY = (sy + ey) / 2;\n    const offset = 14;\n    let labelX = midX;\n    let labelY = midY - offset;\n    labelEl.setAttribute('x', labelX);\n    labelEl.setAttribute('y', labelY);\n    labelEl.textContent = label;\n    svg.appendChild(labelEl);\n  });\n\n  // Draw nodes on top\n  nodes.forEach(({id, label, icon, x, y}) => {\n    const g = document.createElementNS(SVG_NS, \"g\");\n    g.classList.add('node-group');\n    g.setAttribute('id', `node-${id}`);\n    g.setAttribute('data-node', id);\n    g.setAttribute('tabindex', '0');\n    g.setAttribute('role', 'button');\n    g.setAttribute('aria-pressed', 'false');\n    g.setAttribute('aria-label', `Step: ${label}. Click to view details.`);\n\n    g.style.transformOrigin = `${x}px ${y}px`;\n    g.style.transformBox = 'fill-box';\n\n    // Position the group (use translate)\n    g.setAttribute('transform', `translate(${x},${y})`);\n\n    // Rectangle background:\n    const rect = document.createElementNS(SVG_NS, \"rect\");\n    rect.setAttribute('class', 'node-rect');\n    rect.setAttribute('x', -NODE_WIDTH/2);\n    rect.setAttribute('y', -NODE_HEIGHT/2);\n    rect.setAttribute('width', NODE_WIDTH);\n    rect.setAttribute('height', NODE_HEIGHT);\n    g.appendChild(rect);\n\n    // Icon centered left\n    const iconText = document.createElementNS(SVG_NS, \"text\");\n    iconText.setAttribute('class', 'node-icon');\n    iconText.setAttribute('x', -NODE_WIDTH/2 + 28);\n    iconText.setAttribute('y', 10);\n    iconText.setAttribute('dominant-baseline', 'middle');\n    iconText.setAttribute('text-anchor', 'middle');\n    iconText.textContent = icon;\n    g.appendChild(iconText);\n\n    // Label right to icon\n    const labelText = document.createElementNS(SVG_NS, \"text\");\n    labelText.setAttribute('class', 'node-label');\n    labelText.setAttribute('x', -NODE_WIDTH/2 + 80);\n    labelText.setAttribute('y', 6);\n    labelText.setAttribute('text-anchor', 'start');\n    labelText.setAttribute('dominant-baseline', 'baseline');\n    labelText.textContent = label;\n    g.appendChild(labelText);\n\n    svg.appendChild(g);\n  });\n\n  // Interaction logic\n  let currentStepIndex = 0;\n\n  const nodeGroups = revealOrder.map(id => document.getElementById('node-' + id));\n  const sidebar = document.getElementById('sidebar');\n  const nodeIconLarge = document.getElementById('node-icon-large');\n  const nodeLabelEl = document.getElementById('node-label');\n  const nodeDetailsEl = document.getElementById('node-details');\n  const btnNext = document.getElementById('btn-next');\n  const btnPrev = document.getElementById('btn-prev');\n  const progressContainer = document.getElementById('progress-container');\n  const progressBar = document.getElementById('progress-bar');\n  const fileListContainer = document.getElementById('file-list-container');\n  const fileListEl = fileListContainer.querySelector('.file-list');\n\n  const toggleSidebarBtn = document.getElementById('toggle-sidebar');\n\n  // Demo file list for final step\n  const modelFiles = [\n    'meta-llama-3-8b-config.json (12 KB)',\n    'pytorch_model-00001-of-00002.bin (19 GB)',\n    'pytorch_model-00002-of-00002.bin (21 GB)',\n    'tokenizer.model (2 MB)',\n    'README.md (1 KB)'\n  ];\n\n  // Show step details in sidebar for given node id\n  function showStepDetails(id){\n    const node = nodesMap[id];\n    if (!node) return;\n\n    // Update icons and text\n    nodeIconLarge.textContent = node.icon;\n    nodeLabelEl.textContent = node.label;\n    nodeDetailsEl.textContent = node.details;\n\n    // Reset sidebar scroll top with smooth scroll\n    sidebar.querySelector('#sidebar-content').scrollTo({ top: 0, behavior: 'smooth' });\n\n    // Reset aria-pressed on all nodes, set on current:\n    nodeGroups.forEach((g, i) => {\n      const isCurrent = (revealOrder[i] === id);\n      g.setAttribute('aria-pressed', isCurrent ? 'true' : 'false');\n      if (isCurrent) {\n        g.classList.add('active');\n        g.style.opacity = '1';\n      } else {\n        g.classList.remove('active');\n        g.style.opacity = '0.35';\n      }\n    });\n\n    // Show/hide download progress or file list for relevant steps\n    if (id === 'download-files') {\n      progressContainer.style.display = 'block';\n      progressBar.style.width = '0%';\n      fileListContainer.style.display = 'none';\n      simulateFileDownloadProgress();\n    } else if (id === 'files-ready') {\n      progressContainer.style.display = 'none';\n      fileListContainer.style.display = 'block';\n      // Populate file list\n      fileListEl.textContent = '';\n      modelFiles.forEach(f => {\n        const li = document.createElement('div');\n        li.textContent = \"• \" + f;\n        fileListEl.appendChild(li);\n      });\n    } else {\n      progressContainer.style.display = 'none';\n      fileListContainer.style.display = 'none';\n    }\n\n    // Announce step for screen readers (aria-live region is nodeDetailsEl)\n  }\n\n  // Simulated download progress for demo (update every 450ms)\n  let downloadProgressInterval = null;\n  let currentProgress = 0;\n  function simulateFileDownloadProgress(){\n    if (downloadProgressInterval) {\n      clearInterval(downloadProgressInterval);\n      downloadProgressInterval = null;\n    }\n    currentProgress = 0;\n    progressBar.style.width = '0%';\n    downloadProgressInterval = setInterval(() => {\n      currentProgress += Math.random() * 10 + 5; // +5% to +15%\n      if (currentProgress >= 100) {\n        currentProgress = 100;\n        progressBar.style.width = '100%';\n        clearInterval(downloadProgressInterval);\n        downloadProgressInterval = null;\n        btnNext.disabled = false;\n        btnNext.focus();\n      } else {\n        progressBar.style.width = currentProgress.toFixed(1) + '%';\n      }\n    }, 450);\n  }\n\n  // Show current step details on load\n  function setCurrentStep(index) {\n    currentStepIndex = Math.min(Math.max(0, index), revealOrder.length - 1);\n\n    // Update button states\n    btnPrev.disabled = currentStepIndex === 0;\n    btnNext.disabled = false;\n    // For download step we disable next until simulated download done\n    if (revealOrder[currentStepIndex] === 'download-files') btnNext.disabled = true;\n\n    showStepDetails(revealOrder[currentStepIndex]);\n    // Center the current node in SVG viewport for better focus on large screens\n    centerNodeInView(revealOrder[currentStepIndex]);\n  }\n\n  // Center the diagram wrapper view to the chosen node\n  function centerNodeInView(id) {\n    const nodeEl = document.getElementById('node-' + id);\n    if (!nodeEl) return;\n    const diagramWrapper = document.getElementById('diagram-wrapper');\n    const rect = nodeEl.getBoundingClientRect();\n    const wrapperRect = diagramWrapper.getBoundingClientRect();\n\n    // Calculate center of SVG relative to wrapper\n    const scrollX = (rect.left + rect.right) / 2 - wrapperRect.left - wrapperRect.width/2;\n    const scrollY = (rect.top + rect.bottom) / 2 - wrapperRect.top - wrapperRect.height/2;\n\n    diagramWrapper.scrollBy({ left: scrollX, top: scrollY, behavior: 'smooth' });\n  }\n\n  // Event listeners for navigation buttons\n  btnPrev.addEventListener('click', () => {\n    setCurrentStep(currentStepIndex - 1);\n  });\n  btnNext.addEventListener('click', () => {\n    if (currentStepIndex === revealOrder.length -1) {\n      // On last step, wrap around to first step for fun\n      setCurrentStep(0);\n    } else {\n      setCurrentStep(currentStepIndex + 1);\n    }\n  });\n\n  // Click or keyboard interaction on nodes to show details and set active step\n  nodeGroups.forEach((nodeEl, i) => {\n    nodeEl.addEventListener('click', () => {\n      setCurrentStep(i);\n    });\n    nodeEl.addEventListener('keydown', e => {\n      if (e.key === \"Enter\" || e.key === \" \"){\n        e.preventDefault();\n        setCurrentStep(i);\n      }\n    });\n  });\n\n  // Sidebar toggle for mobile\n  toggleSidebarBtn.addEventListener('click', () => {\n    sidebar.classList.toggle('collapsed');\n    if (!sidebar.classList.contains('collapsed')){\n      sidebar.querySelector('#sidebar-content').focus();\n    }\n  });\n\n  // Start sidebar collapsed on small widths for better mobile UX\n  function checkSidebarOnResize(){\n    if (window.innerWidth < 720){\n      sidebar.classList.add('collapsed');\n    } else {\n      sidebar.classList.remove('collapsed');\n    }\n  }\n  window.addEventListener('resize', checkSidebarOnResize);\n  checkSidebarOnResize();\n\n  // Initialize - show first step\n  setCurrentStep(0);\n\n  // PostMessage listener as required\n  window.addEventListener('message', function(event) {\n    const { type, target, state, content } = event.data;\n\n    switch (type) {\n      case 'SET_WIDGET_STATE':\n        if (state) {\n          Object.entries(state).forEach(([key, value]) => {\n            const node = document.getElementById('node-' + key) || document.querySelector('[data-node=\"' + key + '\"]');\n            if (node) {\n              node.style.opacity = value ? '1' : '0.35';\n              node.classList.toggle('active', !!value);\n            }\n          });\n        }\n        break;\n\n      case 'HIGHLIGHT_ELEMENT':\n        const highlightEl = document.querySelector(target);\n        if (highlightEl) {\n          highlightEl.style.outline = '3px solid rgba(139, 92, 246, 0.8)';\n          highlightEl.style.outlineOffset = '4px';\n          highlightEl.style.animation = 'pulse-highlight 2s infinite';\n          setTimeout(() => {\n            highlightEl.style.outline = '';\n            highlightEl.style.animation = '';\n          }, 3000);\n        }\n        break;\n\n      case 'ANNOTATE_ELEMENT':\n        const annotateEl = document.querySelector(target);\n        if (annotateEl && content) {\n          const rect = annotateEl.getBoundingClientRect();\n          const tooltip = document.createElement('div');\n          tooltip.className = 'teacher-annotation';\n          tooltip.style.cssText = 'position:fixed; top:' + (rect.top - 40) + 'px; left:' + rect.left + 'px; background:rgba(139,92,246,0.95); color:white; padding:8px 12px; border-radius:8px; font-size:14px; z-index:1000; animation:fadeIn 0.3s;';\n          tooltip.textContent = content;\n          document.body.appendChild(tooltip);\n          setTimeout(() => tooltip.remove(), 4000);\n        }\n        break;\n\n      case 'REVEAL_ELEMENT':\n        const revealEl = document.querySelector(target);\n        if (revealEl) {\n          revealEl.style.display = '';\n          revealEl.style.opacity = '1';\n        }\n        break;\n    }\n  });\n\n})();\n</script>\n</body>\n</html>",
    "reason": "Use the actual gated model repository instead of a nonexistent GitHub/model identifier.",
    "reference": "https://huggingface.co/meta-llama/Meta-Llama-3-8B"
  },
  {
    "file": "25_huggingface-git_highschool.json",
    "path": "root.classroom.scenes[4].content.widgetConfig.nodes[1].details",
    "before": "To get the entire model, you use the regular git clone command.\n\nIt’s like downloading a photo album from social media — except this album is super huge (40GB!).\n\nCommand:\n`git clone https://huggingface.co/meta-llama/Meta-Llama-3-8b`",
    "after": "To get the entire model, you use the regular git clone command.\n\nIt’s like downloading a photo album from social media — except this album is super huge (40GB!).\n\nCommand:\n`git clone https://huggingface.co/meta-llama/Meta-Llama-3-8B`",
    "reason": "Use the actual gated model repository instead of a nonexistent GitHub/model identifier.",
    "reference": "https://huggingface.co/meta-llama/Meta-Llama-3-8B"
  }
]