AI Engineer Portal
Your personal operating system for career transition.
Private mode
Exercise
Implement A/B evaluation for prompt variants
Implement A/B Evaluation for Prompt Variants
Changing a prompt without measuring the impact is one of the most common mistakes in applied AI engineering. Build a rigorous A/B evaluation pipeline that compares two prompt variants on the same golden dataset.
What you are building
Implement an ABEvaluator that:
- Runs both variants -- for each test case, generates responses using
variant_a_fnandvariant_b_fn. - Scores both responses -- using a provided
score_fn(response, expected) -> float. - Computes win/loss/tie statistics -- a "win" for B is when B's score exceeds A's by more than
margin(default 0.05). - Identifies regressions -- any case where B scores more than 0.10 lower than A.
- Returns a recommendation --
"b"if win rate > 55% AND regression rate <= 5%,"a"if A win rate > 55%, else"inconclusive".
Constraints
- Use only the Python standard library.
- Both variants receive the same input for each case.
casesis a list of dicts withcase_id,input,expected.
Evaluation / medium / Step 12 of 36
Practice stage
Evaluation and review loops
Hint
Separate the scoring logic from the interpretation logic. Your goal is not just a number; it is a useful next action.
Success criteria
- - Produces a useful signal, not decorative output
- - Makes regression review easier
- - Would support a benchmark or observability loop
Review checklist
- - Would this output help decide what to fix next?
- - Are important failure modes visible?
- - Does the score hide any ambiguity I should record?
Related lessons
Practice
Generate a variation
Generate a new exercise variation to deepen understanding or practice a related concept.
Attempt history
Recent submissions
Before you submit, decide what a strong answer should make obvious to the reviewer.
No attempts yet.