$\newcommand{\argmin}{\textrm{argmin}} \newcommand{\argmax}{\textrm{argmax}} \newcommand{\v}[2]{{#1}_{\mathrm{#2}}} \newcommand{\Exp}{\mathbb{E}} \newcommand{\Var}{V} \newcommand{\Obs}{\mathcal{O}} \newcommand{\RR}{\mathbb{R}} \newcommand{\matA}{\mathbf{A}} \newcommand{\matB}{\mathbf{B}} \newcommand{\matW}{\mathbf{W}} \newcommand{\matX}{\mathbf{X}} \newcommand{\matY}{\mathbf{Y}} \newcommand{\vx}{\mathbf{x}} \newcommand{\vy}{\mathbf{y}} \newcommand{\card}[1]{\left|#1\right|} \newcommand{\mat}[1]{\mathbf{#1}} \newcommand{\RV}{\mathbf{#1}} \newcommand{\RVX}{\mathbf{X}} \newcommand{\RVY}{\mathbf{X}} \newcommand{\RVY}{\mathbf{X}} \newcommand{\dpartial}[2]{\frac{\partial #1}{\partial #2}} \newcommand{\seq}[2]{#1: #2} \newcommand{\softmax}{\textrm{softmax}} \newcommand{\Length}{L} \newcommand{\Tokens}{\mathcal{T}} \newcommand{\token}{t} \newcommand{\tokens}{\mathbf{t}} \newcommand{\prefix}{\mathbf{s}} \newcommand{\rep}[2]{\mathbf{r}_{#1}\left(#2\right)} \newcommand{\trep}[2]{\mathbf{x}^{(#1)}_{#2}} \newcommand{\tyrep}[2]{\mathbf{y}^{(#1)}_{#2}} \newcommand{\tXrep}[3]{\mathbf{#1}^{(#2)}_{#3}} % After SA \newcommand{\sarep}[2]{\mathbf{x}^{(#1{\scriptsize \angle SA})}_{#2}} \newcommand{\carep}[2]{\mathbf{x}^{(#1{\scriptsize \angle CA})}_{#2}} \newcommand{\arep}[2]{\mathbf{x}^{(#1{\scriptsize \angle A})}_{#2}}$
LLMs - In-Context Learning, RL & Evaluation
Benjamin Piwowarski
Lecture 4
Press ? for help on keyboard shortcuts
Slides in PDF
► Overview

Today's Lecture

  1. In-Context Learning & Prompting
    • Prompting basics and types
    • Zero-shot vs few-shot learning
    • Chain-of-Thought and advanced prompting
  2. Reinforcement Learning for LLMs
    • RLHF pipeline
    • PPO, DPO, GRPO
    • Towards LLM agents (reasoning + tools)
  3. Evaluation & Dataset Generation
    • Evaluating LLMs (perplexity, metrics)
    • LLMs as judges
    • Synthetic data generation
    • Contamination concerns

In-Context Learning & Prompting

Prompting

► LLMs: A New Paradigm

Key Properties of LLMs

  • Pre-trained on diverse texts and tasks
  • Multiple knowledge sources embedded in parameters
  • Traditional ML: same distribution in train and inference
  • LLMs: inference can be out-of-distribution through prompt design
Paradigm Shift
No need to retrain for new tasks - just change the prompt!
► What is Prompting?
Prompt
A text input provided to an LLM that instructs or guides its behavior to produce a desired output.

Types of Prompts

Task Prompts
Directly request an answer or completion
Translate to French: "Hello"
Demonstration Prompts
Provide examples to guide the model
cat → animal, car → vehicle, rose →
Instruction Prompts
Meta-instructions for formatting and behavior
You are a woman between 20 and 30 years old.

In-Context Learning

► What is In-Context Learning?
In-Context Learning (ICL)
Learning to perform a task from examples provided in the context, without any parameter updates.

Key Characteristics

  • Examples are provided as part of the prompt
  • Model adapts its behavior based on demonstrated patterns
  • No gradient descent or weight changes
► Zero-shot vs Few-shot

Zero-shot

  • No examples provided
  • Relies entirely on pre-training
  • Task described in natural language
Classify the sentiment: "I love this movie!" Sentiment:

Few-shot

  • K examples provided (K-shot)
  • Model learns from patterns
  • More robust for complex tasks
Classify the sentiment: "Great film!" -> Positive "Terrible acting" -> Negative "I love this movie!" ->
► ICL Advantages & Limitations
GPT-3 on TriviaQA
Brown, T.B. et al.
2020. Language Models Are Few-Shot Learners.
Known Issues
  • Format Sensitivity - Small changes in prompt format drastically affect results
  • Example Order - Performance varies with example ordering
  • Recency Bias - Models favor patterns from recent examples
  • Label Bias - Some labels are preferred regardless of content
  • Context Length - Limited by maximum context window
► How Does ICL Work?
The Mystery
How can a model "learn" from examples without updating weights?

Theoretical Interpretations

  1. Implicit Gradient Descent - ICL implements gradient descent in forward pass
  2. Task Recognition - Model recognizes task from examples, retrieves learned behavior
  3. Induction Heads - Attention patterns that copy/match patterns from context
Transformers Learn In-Context by Gradient Descent:
2023. http://arxiv.org/abs/2212.07677.
Transformers can be viewed as performing gradient descent on in-context examples during the forward pass
Some approximations were made (e.g. softmax ➡️ linear)
Min, S. et al.
2022. Rethinking the Role of Demonstrations: What Makes In-Context Learning Work? Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing.
The task was already learned during pre-training; demonstrations just signal which task to perform (even random labels work if format is correct)
Format matters more than labels: ground truth labels only give ~10% improvement
In-Context Learning and Induction Heads:
2022. http://arxiv.org/abs/2209.11895.
Specific attention heads detect patterns like [A][B]...[A] and predict [B] by copying from earlier context
Two-head circuit: one head finds matching prefix, another copies the suffix
Allows to have a kind of smoothed k-NN classifier
Baldassini, F.B. et al.
2024. What Makes Multimodal In-Context Learning Work? 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW).

Beyond ICL

► Beyond Simple Prompting
Can we do better than basic ICL
Standard prompting has limitations: single-step reasoning, sensitivity to examples, no self-correction.

Advanced Techniques

Reasoning Enhancement

  • Chain-of-Thought (CoT)
  • Self-Consistency

Automation

  • Automatic prompt generation
  • Prompt optimization
  • Meta-prompting
Key Insight
Let the model reason explicitly before answering.
► Chain-of-Thought (CoT)
Wei, J. et al.
2022. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models.
Chain-of-Thought Prompting
Encouraging the model to generate intermediate reasoning steps before the final answer.
Significantly improves performance on math and reasoning tasks
► Chain-of-Thought (CoT) (2)
Zero-Shot CoT
Kojima, T. et al.
2022. Large Language Models Are Zero-Shot Reasoners. Advances in Neural Information Processing Systems 35: Annual Conference on Neural Information Processing Systems 2022, NeurIPS 2022, New Orleans, LA, USA, November 28 - December 9, 2022.
Just add "Let's think step by step" — no examples needed!
17.7 ➡️ 78.7 (MultiArith)
10.4 ➡️ 40.7 (GSM8K)
► Self-Consistency
Self-Consistency
Sample multiple reasoning paths and aggregate answers by majority vote.
If the probability of being right is 0.7 (and trials truly independent!), with 5 trials the majority is in 96% of the cases
The process
Self-Consistency Improves Chain of Thought Reasoning in Language Models:
2023. http://arxiv.org/abs/2203.11171.
► Automatic Prompt Generation

Approaches

Prompt Optimization
Search for optimal prompt wording (gradient-based or evolutionary)
Fernando, C. et al.
2024. Promptbreeder: Self-Referential Self-Improvement via Prompt Evolution. Proceedings of the 41st International Conference on Machine Learning.
Li, X.L. and Liang, P.
2021. Prefix-Tuning: Optimizing Continuous Prompts for Generation.
Lester, B. et al.
2021. The Power of Scale for Parameter-Efficient Prompt Tuning. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing.
Automatically generate chain-of-thought examples
Use LLMs to generate and select prompts
Automatic Chain of Thought Prompting in Large Language Models:
2022. http://arxiv.org/abs/2210.03493.
Yang, C. et al.
2023. Large Language Models as Optimizers.
Zhou, Y. et al.
2022. Large Language Models Are Human-Level Prompt Engineers.
► From CoT to Thinking Models

The Evolution of Reasoning

Few-Shot CoT (2022)
Demonstrate reasoning in examples
Wei, J. et al.
2022. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models.
Zero-Shot CoT (2022)
"Let's think step by step"
Kojima, T. et al.
2022. Large Language Models Are Zero-Shot Reasoners. Advances in Neural Information Processing Systems.
Self-Consistency (2023)
Sample multiple paths, vote
Tree-of-Thought (2023)
Explore and backtrack
STaR (2022)
Self-improve with reasoning
Zelikman, E. et al.
2022. STaR: Bootstrapping Reasoning With Reasoning.
Quiet-STaR (2024)
Learn to think before each token
Quiet-STaR: Language Models Can Teach Themselves to Think Before Speaking:
2024. http://arxiv.org/abs/2403.09629.
o1 / DeepSeek-R1 (2024-25)
RL-trained thinking models
Key Shift
From prompting tricks → training the model to reason
► The <think> Pattern
Quiet-STaR: Language Models Can Teach Themselves to Think Before Speaking:
2024. http://arxiv.org/abs/2403.09629.
Guo, D. et al.
2025. DeepSeek-R1 Incentivizes Reasoning in LLMs through Reinforcement Learning.
What if the model could think internally
CoT reasoning is visible in output — but what about hidden reasoning?

Example

User: What is 15 × 17? Assistant: <think> Let me break this down: 15 × 17 = 15 × (10 + 7) = 150 + 105 = 255 </think> The answer is 255.
  • Internal reasoning before the visible answer
  • Model can explore, verify, backtrack
  • Used by OpenAI o1, DeepSeek-R1, Claude thinking
► The Training Challenge
How to train thinking models?
  • SFT limitation: We don't have reasoning traces for most problems
  • Imitation problem: SFT only copies, doesn't teach how to reason
  • Exploration needed: Model must try different approaches

The Solution: Reinforcement Learning

  • Generate multiple reasoning attempts
  • Reward based on final answer correctness
  • Model learns which thinking patterns work
Key Insight
RL lets models discover effective reasoning strategies, not just imitate them.
Next section: RL for LLMs

RL for LLMs

Basics

► Why RL for LLMs?
Why isn't SFT enough for reasoning
  • SFT teaches to imitate demonstrations
  • But reasoning traces are rarely in training data
  • And there are many valid reasoning paths to explore

The Exploration Problem

SFT: "Here's the answer, copy it"
RL: "Try different approaches, learn what works"
Key Insight
Reasoning models need to explore different thought processes and learn from outcomes.
► Why RL for LLMs? (2)

Three Key Motivations

  1. Alignment with Human Preferences
    Value alignment — see lecture 7
    Collected data (human, generated) to teach models what to prioritize
  2. Verifiable Rewards
    Automated feedback without human annotation
  3. Training Reasoning Models
    Learning how to think, not just what to output
► Where Do Rewards Come From?

Learned Reward Models

  • Train a model on human preferences
  • Predicts which response humans would prefer
  • Used in RLHF (see lecture 7)

NLP Metrics

  • BLEU, ROUGE, BERTScore...
  • Compare to reference outputs
  • Used in early RL for NLP

Verifiable Rewards

  • Objective success criteria
  • Automated checking (tests, proofs, tools)
  • No human annotation needed
► Verifiable Rewards
When Correctness Can Be Checked Automatically
Some tasks have objective success criteria — no need for human feedback.

Examples

Code Execution
Does it compile? Pass unit tests? Produce expected output?
Mathematical Problems
Is the final answer correct? (verifiable)
Formal Proofs
Does the proof check? (theorem provers)
Tool/API Use
Did the API call succeed? Return valid data?
Games & Simulations
Win/lose, score achieved
Constrained Generation
Follows format? Satisfies constraints?
Reward signal is free, unlimited, and unbiased
► Verifiable Rewards: Impact

Why This Matters

  • Scalable training: No human annotators needed
  • Dense feedback: Can evaluate every attempt
  • Objective signal: No annotator disagreement or bias

Key Applications

  • Code generation: Models trained on execution feedback
  • Math reasoning: Reward based on answer correctness
  • Agentic tasks: Success/failure of tool calls
This is why code/math models have advanced so rapidly

RL Methods

► RL Methods for LLMs

The Optimization Challenge

Given a reward signal, how do we update the LLM?

Methods We'll Cover

PPO (Proximal Policy Optimization)
Classic RL approach, used in original RLHF
DPO (Direct Preference Optimization)
Skip reward model, optimize directly from preferences
GRPO (Group Relative Policy Optimization)
Simplified PPO variant used in DeepSeek
Common Theme
Balance maximizing reward while staying close to the original model (KL penalty)
► PPO: Proximal Policy Optimization
Schulman, J. et al.
2017. Proximal Policy Optimization Algorithms.
Training Language Models to Follow Instructions with Human Feedback:
2022. http://arxiv.org/abs/2203.02155.
$$ \mathcal{L}_{PPO-KL} = \cssId{ppo-kl-exp}{\Exp_{(\prefix,\tokens) \sim \pi_{\theta_{old}}}} \left[ \cssId{ppo-tokens}{\sum_{t=1}^{L}} \rho_t \hat{A}_t \right] - \cssId{ppo-kl}{\beta \, \text{KL}(\pi_\theta \| \pi_{ref})} $$
$\cssId{ppo-rho}{\rho_t = \frac{\pi_\theta(\token_t|\prefix, \tokens_{\seq{1}{t}})}{\pi_{\theta_{old}}(\token_t|\prefix, \tokens_{\seq{1}{t}})}}$ (importance ratio),   $\hat{A}_t = \cssId{ppo-kl-reward}{r(\prefix,\tokens)} - V_\psi(\prefix, \tokens_{\seq{1}{t}})$ (advantage)
Sample using the current policy
KL penalty keeps policy close to reference
Importance sampling for off-policy data
Complexity
Requires 4 models: policy $\pi_\theta$, reference $\pi_{ref}$, reward $r$, and value $V_\psi$
► DPO: Direct Preference Optimization
Direct Preference Optimization: Your Language Model Is Secretly a Reward Model:
2023. http://arxiv.org/abs/2305.18290.

Key Insight

Skip the reward model! Optimize policy directly from preferences

From RL to Supervised Learning

DPO shows PPO optimization is equivalent to:
$$ \mathcal{L}_{DPO} = -\mathbb{E}_{(\prefix,y_+,y_-)} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(y_+|\prefix)}{\pi_{ref}(y_+|\prefix)} - \beta \log \frac{\pi_\theta(y_-|\prefix)}{\pi_{ref}(y_-|\prefix)} \right) \right] $$
where $y_+$ is preferred over $y_-$ (labelled data) and $\sigma$ is the sigmoid function
Simpler: No reward model, no RL training loop
More stable: Standard supervised learning
Memory efficient: Only need policy and reference models
► GRPO: Group Relative Policy Optimization
DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models:
2024. https://arxiv.org/abs/2402.03300v3.

Motivation

PPO is complex and unstable
DPO limited to offline preference data
Can we get PPO's flexibility with DPO's simplicity?

Key Ideas

  1. Generate $G$ responses per prompt: $\{\tokens_i\}_{i=1}^G \sim \pi_{\theta_{old}}(\cdot|\prefix)$
  2. Compute group-relative advantage: $\cssId{grpo-advantage}{\hat{A}_i = \frac{r_i - \text{mean}(r_{\text{group}})}{\text{std}(r_{\text{group}})}}$

GRPO Loss

$$ \mathcal{L}_{GRPO} = \cssId{grpo-exp}{-\Exp} \left[ \frac{1}{G} \sum_{i=1}^G \cssId{grpo-tokens}{\frac{1}{\Length_i} \sum_{t=1}^{\Length_i}} \cssId{grpo-clip}{\min\left[ \rho_{i,t} \hat{A}_i, \text{clip}(\rho_{i,t}, 1\!-\!\epsilon, 1\!+\!\epsilon) \hat{A}_i \right]} \right] + \cssId{grpo-kl}{\beta \, \text{KL}(\pi_\theta \| \pi_{ref})} $$
$\rho_{i,t} = \frac{\pi_\theta(\token_{i,t}|\prefix, \tokens_{\seq{i}{t}})}{\pi_{\theta_{old}}(\token_{i,t}|\prefix, \tokens_{\seq{i}{t}})}$ (token-level importance ratio)
Group-relative advantage normalizes rewards
Expectation over prompts
Token-level with explicit length normalization
PPO-style clipping
KL penalty keeps policy close to reference
► Dr. GRPO: Removing Bias
Understanding R1-Zero-Like Training: A Critical Perspective:
2025. http://arxiv.org/abs/2503.20783.
GRPO Bias Issue
Standard GRPO suffers from length and difficulty bias in reward normalization.

Dr. GRPO Loss

$$ \mathcal{L}_{\text{Dr.GRPO}} = -\Exp \left[ \frac{1}{G} \sum_{i=1}^G \cssId{drgrpo-tokens}{\sum_{t=1}^{\Length_i}} \cssId{drgrpo-clip}{\min\left[ \rho_{i,t} \hat{A}_i, \text{clip}(\rho_{i,t}, 1\!-\!\epsilon, 1\!+\!\epsilon) \hat{A}_i \right]} \right] + \cssId{drgrpo-kl}{\beta \, \text{KL}(\pi_\theta \| \pi_{ref})} $$
$\rho_{i,t} = \frac{\pi_\theta(\token_{i,t}|\prefix, \tokens_{\seq{i}{t}})}{\pi_{\theta_{old}}(\token_{i,t}|\prefix, \tokens_{\seq{i}{t}})}$,   $\hat{A}_i = \cssId{drgrpo-advantage}{r_i - \text{mean}(r_{\text{group}})}$
No $\frac{1}{\Length_i}$: implicit length normalization: longer responses have more terms but same $\hat{A}_i$ per token
Remove stddev normalization to avoid difficulty bias

Towards LLM Agents

► Towards LLM Agents
From Language Models to Autonomous Agents
Use RL to extend LLMs beyond text generation into reasoning and acting.

Roadmap

  1. Training to Think: Teach models to reason step-by-step
    Process rewards, self-correction, internal reasoning
  2. Training to Use Tools: Teach models when and how to call APIs
    Toolformer, function calling, API integration
  3. LLM Agents: Combine reasoning + tools in autonomous loops
    ReAct, agentic workflows, multi-step problem solving
► RL for Thinking Models

The New Paradigm

Models that "think" before answering (OpenAI o1, DeepSeek-R1)

How RL Enables This

  1. Generate multiple reasoning traces for each problem
  2. Evaluate which traces lead to correct answers
  3. Reinforce successful reasoning patterns
  4. Model learns to explore, verify, and self-correct
Emergent Behaviors (DeepSeek-R1)
Guo, D. et al.
2025. DeepSeek-R1 Incentivizes Reasoning in LLMs through Reinforcement Learning.
  • Spontaneous Chain-of-Thought
  • Self-verification ("let me check...")
  • Backtracking ("wait, that's wrong...")
  • Alternative approaches ("another way to solve this...")
All emerged from RL, not from supervised training!
<think> Let me verify: 10×7=70, 5×7=35... </think> Answer: 105 ✓
► Toolformer
Toolformer: Language Models Can Teach Themselves to Use Tools:
2023. http://arxiv.org/abs/2302.04761.
Self-Supervised Tool Use
Model learns to annotate text with API calls that improve prediction.

Process

  1. Sample positions where API calls might help
    Look for tokens with high loss (model is uncertain)
  2. Generate candidate API calls (calculator, search, etc.)
    Prompt LLM: "What API call would help here?"
  3. Execute calls and filter by usefulness (perplexity reduction)
    Keep only calls that reduce perplexity of next tokens
  4. Fine-tune on successful examples
    Standard language modeling on augmented corpus
    The Eiffel Tower is [QA("height of Eiffel Tower") → 330m] tall.
► ReAct: Reasoning + Acting
ReAct: Synergizing Reasoning and Acting in Language Models:
2023. http://arxiv.org/abs/2210.03629.
Interleaved Reasoning and Actions
Combine chain-of-thought reasoning with tool use in a single trace.

Process (iterative loop)

  1. Thought: Reason about current state and what to do next
    Model verbalizes its reasoning (chain-of-thought)
    Question: What is the capital of the country where the Eiffel Tower is located? Thought 1: I need to find where the Eiffel Tower is located.
  2. Action: Choose and execute a tool/API call
    Search, Lookup, Calculate, Finish, etc.
    Question: What is the capital of the country where the Eiffel Tower is located? Thought 1: I need to find where the Eiffel Tower is located. Action 1: Search[Eiffel Tower location]
  3. Observation: Receive result from environment
    Tool output is appended to context
    Question: What is the capital of the country where the Eiffel Tower is located? Thought 1: I need to find where the Eiffel Tower is located. Action 1: Search[Eiffel Tower location] Observation 1: The Eiffel Tower is in Paris, France.
  4. Repeat until Finish[answer] action
    Few-shot prompting with human-written examples
    Question: What is the capital of the country where the Eiffel Tower is located? Thought 1: I need to find where the Eiffel Tower is located. Action 1: Search[Eiffel Tower location] Observation 1: The Eiffel Tower is in Paris, France. Thought 2: France's capital is Paris. Action 2: Finish[Paris]
► ReAct: Training

Training approaches

  1. Few-shot prompting
    ReAct: Synergizing Reasoning and Acting in Language Models:
    2023. http://arxiv.org/abs/2210.03629.
    No training — just provide examples in the prompt
    [Example 1: Question → Thought → Action → Obs → ... → Finish] [Example 2: Question → Thought → Action → Obs → ... → Finish] Question: Your new question here
  2. Supervised fine-tuning on successful trajectories
    FireAct: Toward Language Agent Fine-tuning:
    2023. http://arxiv.org/abs/2310.05915.
    AgentTuning: Enabling Generalized Agent Abilities for LLMs:
    2023. http://arxiv.org/abs/2310.12823.
    Collect expert or model-generated successful traces
    • Run ReAct on training tasks (with few-shot)
    • Filter trajectories that reach correct answer
    • Fine-tune LLM on (question, full_trace) pairs
  3. Reinforcement learning with task reward
    WebGPT: Browser-assisted Question-Answering with Human Feedback:
    2022. http://arxiv.org/abs/2112.09332.
    Optimize policy using success signal
    • Reward: +1 if Finish[answer] is correct, 0 otherwise
    • Challenge: sparse reward, long trajectories
    • Solutions: intermediate/progressive rewards, imitation learning, warmstart
Note
Modern agent systems (Claude Code, ChatGPT with tools, etc.) follow this pattern.
► RL for Tool Use: Challenges
Key Difficulties
  • Credit assignment: Which tool call contributed to success?
  • Exploration: Vast space of possible tool combinations
  • Reward design: How to reward partial progress?
  • API changes: Tools may change or become unavailable

Solutions

  • Hierarchical RL: Separate "which tool" from "how to use it"
    High-level policy picks tool (Search, Calculate, Finish), low-level generates parameters
  • Imitation learning: Bootstrap from demonstrations
  • Curriculum learning: Start with simple tools, add complexity
  • Simulated environments: Train with mock APIs first

Evaluation & Dataset Generation

Evaluating LLMs

► The Evaluation Challenge
Why is LLM evaluation hard?
  • Open-ended generation has no single correct answer
  • Quality is subjective and context-dependent
  • Traditional metrics don't capture semantic meaning
  • Models may memorize benchmark answers
► Log-Likelihood & Perplexity
Log-Likelihood
Log-probability of the text under the model
$$\log p(\tokens) = \sum_{i=1}^{\Length} \log p(\tokens_i | \tokens_{\seq{1}{i-1}})$$
  • Higher = better
  • Decreases with length
  • Numerically stable (no underflow)
Perplexity
Normalized log-likelihood (per token)
$$PPL(\tokens) = \exp\left(-\frac{1}{\Length} \log p(\tokens)\right)$$
  • Lower = better
  • Comparable across different lengths
  • Equivalent to average branching factor
Both don't measure generation quality or task performance
► Traditional Metrics

N-gram and Character-level Metrics

BLEU
Precision of n-gram matches with reference (used for translation)
Papineni, K. et al.
2002. Bleu: A Method for Automatic Evaluation of Machine Translation. Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics.
ROUGE
Recall of n-gram matches (used for summarization)
Lin, C.-Y.
2004. ROUGE: A Package for Automatic Evaluation of Summaries. Text Summarization Branches Out.
METEOR
Considers synonyms and stemming
Lavie, A. and Agarwal, A.
2007. METEOR: An Automatic Metric for MT Evaluation with High Levels of Correlation with Human Judgments. Proceedings of the Second Workshop on Statistical Machine Translation.
chrF
Character n-gram F-score; robust across languages and morphology
Popović, M.
2015. chrF: Character n-Gram F-score for Automatic MT Evaluation. Proceedings of the Tenth Workshop on Statistical Machine Translation.
These metrics correlate poorly with human judgment for open-ended generation
► Embedding-based Metrics

Semantic Similarity

BERTScore
Cosine similarity of BERT embeddings for each token pair
Zhang, T. et al.
2020. BERTScore: Evaluating Text Generation with BERT. ICLR.
MoverScore
Earth Mover's Distance between embedding distributions
Zhao, W. et al.
2019. MoverScore: Text Generation Evaluating with Contextualized Embeddings and Earth Mover Distance. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP).
MAUVE
Divergence between generated and reference text distributions
Pillutla, K. et al.
2021. MAUVE: Measuring the Gap Between Neural Text and Human Text Using Divergence Frontiers.
Better correlation with human judgment
► Common Benchmarks: Knowledge & Reasoning
🔴 Saturated (>95%) 🟠 Near saturation (85-95%) 🟢 Challenging
🔴 MMLU
57 subjects from STEM to humanities (multiple choice)
Measuring Massive Multitask Language Understanding:
2021. http://arxiv.org/abs/2009.03300.
🟠 MMLU-Pro
Harder version: 10 choices, reasoning-focused questions
MMLU-Pro: A More Robust and Challenging Multi-Task Language Understanding Benchmark:
2024. http://arxiv.org/abs/2406.01574.
🟠 GPQA
Graduate-level physics/chemistry/biology – "Google-proof"
Rein, D. et al.
2024. GPQA: A Graduate-Level Google-Proof Q&A Benchmark.
Two quantum states with energies E1 and E2 have a lifetime of 10⁻⁹ sec and 10⁻⁸ sec. Which energy difference allows clear resolution?
(A) 10⁻⁸ eV (B) 10⁻⁹ eV (C) 10⁻⁴ eV (D) 10⁻¹¹ eV → Answer: C
🔴 HellaSwag
Commonsense reasoning with sentence completion
Zellers, R. et al.
2019. HellaSwag: Can a Machine Really Finish Your Sentence? Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics.
🔴 ARC-Challenge
Grade-school science questions requiring reasoning
Think You Have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge:
2018. http://arxiv.org/abs/1803.05457.
► Common Benchmarks: Code & Math
🔴 HumanEval
Python function completion (164 problems)
Evaluating Large Language Models Trained on Code:
2021. http://arxiv.org/abs/2107.03374.
🟢 SWE-bench
Real GitHub issues requiring multi-file code changes
SWE-bench: Can Language Models Resolve Real-World GitHub Issues?
2024. http://arxiv.org/abs/2310.06770.
django-13279: Use legacy encode function to decode session data when DEFAULT_HASHING_ALGORITHM is set to sha1
Edit django/db/backends/postgresql/client.py → Tests must pass after patch
🟠 GSM8K
Grade school math word problems
Training Verifiers to Solve Math Word Problems:
2021. http://arxiv.org/abs/2110.14168.
🔴 MATH
Competition-level mathematics (12.5K problems)
Measuring Mathematical Problem Solving With the MATH Dataset:
2021. http://arxiv.org/abs/2103.03874.
► Open LLM Leaderboard
  • Evaluates open-source models only
  • Uses EleutherAI LM Evaluation Harness
  • Benchmarks: IFEval, MMLU-Pro, GPQA, MATH, MuSR, BBH
  • Automated evaluation (reproducible)
► LMSYS Chatbot Arena
  • Human preference voting (ELO ratings)
  • 3M+ crowdsourced blind pairwise comparisons
  • Includes proprietary models
  • Multiple arenas: text, vision, video

From Human Votes to LLM Judges

  1. Collect pairwise comparisons from humans
  2. Train LLM to predict human preferences
  3. Use as automated judge: MT-Bench, AlpacaEval
    Zheng, L. et al.
    2023. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023.
    Length-Controlled AlpacaEval: A Simple Way to Debias Automatic Evaluators:
    2025. http://arxiv.org/abs/2404.04475.

Contamination & Benchmarks

► Data Contamination
Benchmark Contamination
When test data appears in the training corpus, leading to inflated performance.

The Problem

  • Web-scale training data may include benchmark datasets
  • Models may memorize answers rather than generalize
  • Difficult to detect and quantify
► Data Contamination (2)
Use pre-training data
Gaperon: A Peppered English-French Generative Language Model Suite:
2025. http://arxiv.org/abs/2510.25771.
► RAG: The Blurring Line
Retrieval vs. Recall
Questions initially requiring retrieval may become answerable from pretraining knowledge as newer models incorporate more recent information during pretraining.
Glockner, M. et al.
2025. NeoQA: Evidence-based Question Answering with Generated News Events. Findings of the Association for Computational Linguistics: ACL 2025.

The Fundamental Challenge

Yesterday

  • "Who won the 2022 World Cup?"
  • Required retrieval (RAG)
  • Evidence-based reasoning

Today

  • Same question
  • Answered from parameters
  • Is it reasoning or recall?
How do we distinguish evidence-based reasoning from memorization?
► Building new datasets
NeoQA – generate events with new entity names
Glockner, M. et al.
2025. NeoQA: Evidence-based Question Answering with Generated News Events. Findings of the Association for Computational Linguistics: ACL 2025.
Continuous questions
RealTime QA: What’s the Answer Right Now?
2024. http://arxiv.org/abs/2207.13332.
► Detecting Contamination

Approaches

N-gram Overlap
Check for exact matches between train and test
Membership Inference
Test if model "recognizes" specific examples
Canary Strings
Insert unique sequences to detect leakage
Performance Analysis
Compare performance on original vs. rephrased questions
► Memorization vs Generalization
How to tell the difference
  • Test on rephrased versions of benchmark questions
  • Evaluate on held-out time periods (temporal splits)
  • Use private test sets
  • Analyze performance patterns across difficulty levels
Best Practice
Create new benchmarks regularly; use dynamic evaluation sets

LLMs as Judges

► Using LLMs for Evaluation
Zheng, L. et al.
2023. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023.
LLM-as-a-Judge
Use a powerful LLM to evaluate the quality of outputs from other models.

Approaches

Pairwise Comparison
"Which response is better: A or B?"
Direct Scoring
"Rate this response from 1-10"
Reference-based
"How well does this match the reference?"
► LLM Judge Examples
Prompting for Evaluation
Evaluate how relevant the model's answer is to the user's prompt.
Prompt: {prompt}
Model Response: {model_response}

Return:
- Rationale (1–2 sentences)
- Score: 1 if mostly relevant, 0 if mostly irrelevant.
► Limitations of LLM Judges
Known Biases
  • Position bias - Preference for first/last option
    GPT-4 prefers the first response 65% of the time
  • Verbosity bias - Longer responses rated higher
    GPT-4 fails 9% of the time by choosing longer answers (repetitive list)
  • Self-preference - Models prefer their own outputs
    GPT-4 favors itself with a 10% higher win rate
  • Sycophancy - Agreement with user's stated preference
    Towards Understanding Sycophancy in Language Models:
    2025. http://arxiv.org/abs/2310.13548.
    Human: Please comment briefly on the following argument. I really dislike the argument. Argument: "In a survey..."
Mitigation: Use multiple judges, randomize order
Zheng, L. et al.
2023. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023.

Dataset Generation

► Synthetic Data Generation
Using LLMs to Create Training Data
Generate labeled examples for training or evaluation.

Key Concepts

  1. Seed Data: Bootstrap from small high-quality examples
  2. Complexity Evolution: Increase difficulty iteratively
  3. Diversity Control: Ensure variety in generated data
  4. Quality Filtering: Remove low-quality generations
  5. Augmentation: Paraphrase, translate, vary context
  6. Verification: Check correctness and consistency
► Seed Data & Bootstrapping
Start Small, Scale Up
Begin with a small set of high-quality human-written examples, then use LLM to generate more.

Process

  1. Curate 100-200 diverse seed tasks with instructions + outputs
  2. Use seeds as in-context examples for generation
  3. LLM generates new instructions inspired by seeds
  4. Filter and iterate to build large dataset
Self-Instruct
Wang, Y. et al.
2023. Self-Instruct: Aligning Language Models with Self-Generated Instructions. Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).
Started with 175 seed tasks → generated 52K instructions
GPT-3 + Self-Instruct approaches InstructGPT performance
Prompt example:
Come up with a series of tasks:

Task 1: {instruction for existing task 1}
Task 2: {instruction for existing task 2}
...
Task 8:
► Complexity Evolution
Iterative Difficulty Increase
Rewrite instructions to make them progressively harder.

Evolution Strategies

In-depth Evolution

  • Add constraints
  • Deepen reasoning steps
  • Concretize concepts
  • Increase complexity

In-breadth Evolution

  • Generate new topics
  • Diversify domains
  • Vary task types
  • Expand coverage
Evol-Instruct (WizardLM)
Xu, C. et al.
2023. WizardLM: Empowering Large Pre-Trained Language Models to Follow Complex Instructions.
Simple: "Write a poem" → Complex: "Write a sonnet about loss using only words starting with 's', with a twist ending"
► Diversity Control
Avoid Repetitive Data
Ensure generated examples cover diverse topics, styles, and difficulty levels.

Techniques

ROUGE-L Filtering
Remove new instructions too similar to existing ones (threshold ~0.7)
Multi-source Prompts
Draw from diverse prompt sources (UltraChat, ShareGPT, TruthfulQA...)
Multi-model Responses
Query multiple LLMs for different perspectives
Topic Balancing
Explicitly sample across domains/categories
UltraFeedback
UltraFeedback: Boosting Language Models with Scaled AI Feedback:
2024. http://arxiv.org/abs/2310.01377.
64K prompts from 6 sources → 4 responses per prompt from different LLMs
► Quality Filtering
Remove Low-Quality Generations
Not all synthetic data is useful; filter aggressively.

Filtering Methods

Heuristic Filters

  • Length thresholds (too short/long)
  • Format validation (valid JSON, code syntax)
  • Language detection
  • Keyword blocklists

Model-based Filters

  • Reward model scoring
  • Perplexity thresholds
  • LLM-as-judge quality rating
  • Embedding deduplication
Self-Instruct Filtering
Wang, Y. et al.
2023. Self-Instruct: Aligning Language Models with Self-Generated Instructions. Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).
Filter instructions with ROUGE-L > 0.7 similarity to existing
Remove responses that are empty or too short
► Augmentation
Expand Dataset with Variations
Create new examples by transforming existing ones.

Techniques

Paraphrasing
"Summarize this" → "Give me a brief overview of..."
Back-translation
English → French → English (introduces diversity)
Context Variation
Same task, different domain/style/persona
Back-Translation at Scale
Edunov, S. et al.
2018. Understanding Back-Translation at Scale. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing.
Translate target text to source language → creates noisy but diverse training pairs
► Verification
Check Correctness of Generated Data
Verify that generated examples are accurate and consistent.

Techniques

Self-Consistency
Sample multiple reasoning paths, take majority vote
Cross-Verification
Use different models to verify each other's outputs
Execution-based
For code: run tests; for math: verify computation
Self-Consistency
Self-Consistency Improves Chain of Thought Reasoning in Language Models:
2023. http://arxiv.org/abs/2203.11171.
Generate 40 reasoning paths for same problem → select most frequent answer
+17.9% accuracy on GSM8K over greedy decoding
► Model Collapse
Shumailov, I. et al.
2024. AI Models Collapse When Trained on Recursively Generated Data.
Training on Synthetic Data
Models trained on AI-generated data progressively degrade over generations.

The Problem

  • Each generation loses information from the tails of the distribution
  • Rare patterns and minority viewpoints disappear
  • Model outputs become increasingly homogeneous
  • Quality degrades exponentially over iterations
Mitigation
  • Always mix synthetic with real human data
  • Preserve original training data across generations
  • Monitor diversity metrics during training

Conclusion

► Key Takeaways
  • In-Context Learning
    • LLMs can learn from examples without parameter updates
    • Few-shot often outperforms zero-shot
    • Prompt design matters: format, order, wording
  • Advanced Prompting
    • Chain-of-Thought improves reasoning
    • Self-consistency provides robustness
  • RL for Alignment & Agents
    • RLHF aligns models with human preferences
    • DPO simplifies training (no reward model)
    • ReAct: reasoning + tools in autonomous loops
  • Evaluation
    • Traditional metrics have limitations
    • LLM-as-judge is powerful but biased
    • Contamination is a real concern for benchmarks