Skip to content

Open the effect-scorer registry with an EffectScorer Protocol #24

Description

@bamdadd

Context

metrics.EFFECT_SCORERS is a plain dict[str, Callable[[str], float]] that a contributor must edit in place to add a concept scorer. That closes the module to extension: a downstream user (for example introspection-scaling) cannot register a new effect scorer without patching steerbench. An open-closed Protocol plus a registration hook keeps the existing scorers working while letting new ones plug in.

Proposal

Introduce an EffectScorer Protocol (a callable taking str and returning float, documenting direction and range) and a register_effect_scorer(name, scorer) entry point, with EFFECT_SCORERS populated through it. The three shipped scorers keep their current behaviour and signatures.

Acceptance criteria

  • Add an EffectScorer Protocol in src/steerbench/metrics.py; formality_score, sentiment_score, verbosity_score satisfy it (verified by mypy, no runtime change).
  • Add register_effect_scorer(name: str, scorer: EffectScorer) -> None; duplicate names raise ValueError naming the existing entry.
  • effect_score(concept, text) resolves through the registry unchanged for the three shipped concepts.
  • CPU-only unit test in tests/test_metrics.py: register a fake scorer, resolve it via effect_score, and assert a duplicate registration raises. No model download.
  • ruff check ., ruff format --check ., mypy src, pytest -q all pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions