Claude With The Anthropic Api
← All lessons
Lesson 20Claude With The Anthropic Api

Model based grading

Summary audio

No audio recap for this lesson.

Study notes

Overview of Graders

  • A grader takes model output and returns an objective signal (commonly a number between 1-10, where 10 = high quality, 1 = low quality)
  • Output can be any format: numbers, true/false, or other signals

Three Types of Graders

Code-Based Graders

  • Author custom code snippets to evaluate model output
  • Can perform programmatic checks: length validation, keyword verification, syntax validation for JSON/code
  • Can implement complex checks like readability scores
  • Must return an objective signal

Model-Based Graders

  • Feed model output to an additional model via API call
  • Provides flexibility to evaluate on any criteria: general quality, instruction-following, completeness, etc.
  • Model must return a hard objective signal (usually 1-10 scale)
  • Useful when evaluation criteria are complex or subjective

Human-Based Graders

  • Have actual people evaluate responses
  • Extremely flexible for any evaluation metric
  • Major downside: time-consuming and tedious

Setting Evaluation Criteria

  • Define upfront exactly what aspects of responses you will focus on
  • Example criteria: correct format (Python/JSON/regex only), valid syntax, task completion and accuracy

Implementation Tips for Model Graders

  • Write detailed prompts that set a role and clearly explain the evaluation task
  • Ask model to provide strengths, weaknesses, and reasoning alongside scores
  • Requesting reasoning prevents middling scores (like always scoring 6) by forcing the model to be more concrete
  • Use JSON output format with pre-filled assistant messages and stop sequences for clean extraction

Measuring Overall Performance

  • Calculate average score across all test cases to get an objective metric for prompt quality
  • Use this metric to track improvements when iterating on prompts

Takeaways

  • A grader evaluates model output and returns an objective signal (typically 1-10) to measure quality
  • Three grader types exist: code-based (programmatic checks), model-based (API calls to evaluate), and human-based (manual evaluation)
  • Define evaluation criteria upfront (format, syntax, accuracy, etc. ) before building graders
  • Model-based graders work best when you request reasoning alongside scores, which prevents vague middle-range scoring
  • Calculate average scores across test cases to objectively track prompt quality improvements
Flashcards 10 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 5 questions