AI Engineer Portal
Your personal operating system for career transition.
Exercise
Implement A/B evaluation framework for prompt variants
Implement A/B Evaluation for Prompt Variants
Before shipping a prompt change you need evidence it improves the metric that matters, not just anecdotal inspection of a few examples.
What to build
Implement PromptABTest:
-
Constructor:
variant_a_fn,variant_b_fn(bothCallable[[str], str]),score_fn: Callable[[str, str], float](response + reference),pass_threshold=0.7. -
run(cases: list[dict]) -> dict— Each case has"input"and"reference". Returns{"a_avg_score", "b_avg_score", "score_delta"(B-A),"a_pass_rate", "b_pass_rate", "b_win_rate", "tie_rate", "a_win_rate", "recommendation"}. Recommendation:"deploy_b"if delta >= 0.05,"keep_a"if <= -0.05, else"inconclusive". Ties within 0.01. -
per_case_results(cases) -> list[dict]— Returns{"input", "a_score", "b_score", "winner"}per case.
Constraints
- Standard library only.
Evaluation / medium / Step 22 of 36
Evaluation and review loops
Separate the scoring logic from the interpretation logic. Your goal is not just a number; it is a useful next action.
- - Produces a useful signal, not decorative output
- - Makes regression review easier
- - Would support a benchmark or observability loop
- - Would this output help decide what to fix next?
- - Are important failure modes visible?
- - Does the score hide any ambiguity I should record?
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.