Claude With Amazon Bedrock
← All lessons
Lesson 17Claude With Amazon Bedrock

Model based grading

Summary audio

Spoken summary — press play to read along: the line being spoken stays near the top.

Study notes

Prompt Evaluation Workflow: Grading Systems

  • Purpose of a Grader: To take model output and provide an objective signal (e. g. , a number or true/false) regarding the quality of the response.
  • Common Scoring: Scores are frequently given on a scale of 1 to 10 (1 = low quality, 10 = high quality).

Three Types of Graders

  • Code-Based Graders:
  • Mechanism: Feed model output into a custom snippet of code.
  • Checks: Programmatic verification of length (too long/too short), presence/absence of specific words, syntax validation (for JSON or code), and readability scores.
  • Requirement: Must return a usable signal.
  • Model-Based Graders:
  • Mechanism: Feed model output into an additional model (a separate API request).
  • Flexibility: Can evaluate general quality, instruction following, completeness, or adherence to specific criteria.
  • Requirement: Must return an objective signal (usually 1 to 10).
  • Human-Based Grading:
  • Mechanism: A person manually evaluates the model output.
  • Flexibility: Can evaluate for any imaginable metric.
  • Drawback: Highly time-consuming and tedious.

Defining Evaluation Criteria

  • Upfront Decision: Before grading, you must define exactly what aspects of the response you are focusing on.
  • Example Criteria:
  • Format: Is the output only Python, JSON, or regular expression, with no extra explanation?
  • Syntax: Does the generated code/JSON have valid syntax (no typos)?
  • Task Following: Does the model clearly address the user's task with generally accurate code?

Implementation Strategy

  • Code Grader Use: Best for format and syntax checks (e. g. , ensuring valid JSON or Python).
  • Model Grader Use: Best for subjective or complex checks (e. g. , general task following and accuracy).

Model Grader Implementation Details

  • Prompt Engineering: The grading prompt must clearly set a role, state the task, list the model's solution, and provide specific directions on how to respond.
  • Improving Score Quality: To avoid generic scores (like 6), ask the model to provide specific strengths, weaknesses, and reasoning. This forces a more concrete evaluation.
  • Process:
  • Call the additional grading model.
  • Ensure the model returns a structured JSON object.
  • Parse the returned JSON to extract the score and reasoning.

Final Workflow Step

  • Objective Metric: After running the evaluation, calculate the average score across all test cases to establish a final, objective metric for the prompt's performance.

Takeaways

  • The primary purpose of a grader is to provide an objective signal (e. g. , a score on a scale of 1 to 10) regarding the quality of model output.
  • There are three main types of graders: Code-Based (verifies syntax and format), Model-Based (evaluates general quality and instruction following), and Human-Based (most flexible but time-consuming).
  • Evaluation criteria (e. g. , format, syntax, task following) must be defined upfront before any grading begins.
  • Code Graders are best suited for objective checks (like valid JSON or Python syntax), while Model Graders are best for subjective or complex checks (like overall accuracy).
  • To improve the quality of scores from a Model Grader, the grading prompt must be highly structured and require the model to provide specific strengths, weaknesses, and reasoning.
Flashcards 9 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions