Skip to content

Feature: Allow scorer functions to return arrays of scores #304

@mihilmy

Description

@mihilmy

Feature Request: Allow scorer functions to return arrays of scores

Problem

Currently, scorer functions can only return a single Score object. However, some use cases involve LLM graders that assess multiple criteria in a single call and return multiple pass/fail results.

Use Case

I have an LLM grader that performs a one-shot assessment of multiple criteria and returns a pass/fail for each criterion. For example, evaluating if a response is accurate, complete, and clear - all in a single LLM call for efficiency.

Currently, I need to either:

  • Make separate LLM calls for each criterion (inefficient and costly)
  • Write custom logic to split the results into multiple scorer calls
  • Use only a single aggregate score

Proposed Solution

Allow scorers to return either a single Score or an array of Score[], which would be flattened into the final scores array.

This appears to be achievable with a simple .flat() here:

const scores = await Promise.all(
(plus type changes to allow Score | Score[]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions