# LLM-as-a-Judge: How to Grade AI Agents | Stanford CS329Z Lecture 13 with John Yang

## Executive summary

This lecture explores the methodology of using Large Language Models (LLMs) as judges to evaluate AI agents, covering the three primary grading types: unit tests, human annotation, and LLM-as-a-Judge. Key challenges discussed include LLM biases (e.g., positional or length bias) and non-determinism in agentic tasks. The session details advanced metrics like pass@k and pass^k to accurately report performance across multiple rollouts, emphasizing that the choice of metric is highly dependent on the task's nature.

## Key takeaways

- Three Types of Graders: Evaluation methods fall into three categories: deterministic unit tests (fast, cheap, but limited in nuance), human annotation (expensive, but high fidelity), and LLM-as-a-Judge (a scalable stand-in for human effort).
- LLM-as-a-Judge Lineage: The use of LLMs for grading evolved from replacing traditional NLP metrics (like Blue Score) to simulating human actions (e.g., GDP Val, MT-Bench) and, most recently, acting as an agent to grade trajectories (e.g., Web Voyager).
- Handling Non-Determinism: For agentic tasks with multiple rollouts, reporting performance requires metrics beyond simple averaging. Pass@k measures the likelihood of solving the task at least once within k trials, while pass^k requires success on every single trial.

## Technical details

- Evaluation Biases: LLM judges exhibit biases, such as positional bias (favoring Answer A over Answer B) and length bias (favoring verbose completions), which necessitates mitigation strategies like applying length penalties to the post-training objective.
- Benchmarking Paradigms: Benchmarks like SWE-bench and Terminal Bench rely on programmatic, deterministic unit tests. In contrast, tasks like Chatbot Arena and GDP Val require human or LLM judgment due to the large, non-exact solution space.
- Agentic Grading (LLM as Agent): In complex domains (e.g., web or OS interaction), the LLM can be used as an agent to generate a grading trajectory (e.g., a random walk on a website) which serves as verification, replacing the need for original source code.
- Reward Modeling: The process of training a reward model involves collecting human preference data (tuples of Output A vs. Output B) and training the model to predict which output the human preferred, thereby removing the human from the training loop.

## Practical implications

- When designing an AI agent evaluation pipeline, developers must choose a verification method (unit test, human, or LLM judge) that matches the task's solution space (exact vs. open-ended).
- To improve model robustness, post-training objectives must account for biases (e.g., length) by applying penalties during training.
- For complex, non-deterministic tasks, performance reporting should utilize metrics like pass@k or pass^k instead of simple averages to accurately reflect reliability.
- LLM-as-a-Judge provides a scalable method to operationalize human preferences, allowing the creation of automated reward models for training.

## Topics

AI Agent Evaluation, LLM Grading, Reinforcement Learning from Human Feedback (RLHF), Benchmarking, Non-Determinism, Grace et al., “Demystifying Evals for AI Agents,” Anthropic, Zheng et al., “Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena,” NeurIPS, Ryan et al., “AutoMetrics: Approximate Human Judgements with Automatically Generated Evaluators,” ICLR

Source: https://www.youtube.com/watch?v=J61-q-mk9y0
