方寸 Portal

AI Engineer Portal

Your personal operating system for career transition.

Private mode

Exercise

Implement an evaluation configuration loader

Implement an Evaluation Configuration Loader

Eval pipelines need configuration: which metrics to run, what thresholds to enforce, which model to use as the judge, and which categories to include. Hard-coding these values makes the pipeline difficult to adapt. A configuration loader centralises them in one place.

What to build

Implement EvalConfig (a Pydantic-style dataclass):

Fields: metrics: list[str] (default ["faithfulness", "relevance"]), pass_threshold: float (default 0.7), regression_threshold: float (default 0.10), judge_model: str (default "gpt-4o-mini"), categories: list[str] (default empty = all), max_cases: int | None (default None = unlimited), sample_rate: float (default 1.0, clamped to 0.0-1.0).

Implement load_eval_config(source: dict | None = None) -> EvalConfig:

  • Accepts a dict (from JSON file, env vars, CLI args).
  • Unknown keys are silently ignored.
  • Invalid float ranges raise ValueError with a descriptive message.
  • Missing keys use defaults.

Implement EvalConfig.to_dict() -> dict returning all fields.

Constraints

  • Standard library only. No Pydantic. Use dataclasses and manual validation.

Evaluation / easy / Step 33 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?

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.