Skip to content

Multiple scores from a single Scorer#125

Merged
David Elner (delner) merged 1 commit intomainfrom
feature/mutiple_scores_from_scorer
Mar 19, 2026
Merged

Multiple scores from a single Scorer#125
David Elner (delner) merged 1 commit intomainfrom
feature/mutiple_scores_from_scorer

Conversation

@delner
Copy link
Collaborator

Scorers can now return multiple named metrics in one call by returning an array of score hashes. This is useful when several dimensions of quality can be computed together — sharing one LLM call or one pass over the output — rather than running separate scorers for each metric.

There are no breaking changes: existing scorers that return a single value or {score:, metadata:} hash continue to work.

Usage

Return an Array of hashes instead of a single value. Each hash requires :name and :score; :metadata is optional:

Braintrust::Scorer.new("summary_quality") do |output:, expected:|
  words = output.downcase.split
  key_terms = expected[:key_terms]
  covered = key_terms.count { |t| words.include?(t) }

  [
    {name: "coverage",    score: covered.to_f / key_terms.size, metadata: {missing: key_terms - words}},
    {name: "conciseness", score: words.size <= expected[:max_words] ? 1.0 : 0.0}
  ]
end

Each metric appears as its own score column in the Braintrust UI.

@delner David Elner (delner) force-pushed the feature/mutiple_scores_from_scorer branch from d1691e6 to ea8ee11 Compare March 19, 2026 14:17
@delner David Elner (delner) merged commit 750f153 into main Mar 19, 2026
7 checks passed
@delner David Elner (delner) deleted the feature/mutiple_scores_from_scorer branch March 19, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants