Tune.Ensemble (Tune v0.5.0)

Copy Markdown View Source

A program that runs compatible member programs and reduces their outputs.

Members must declare the same input and output fields. Each run calls every member in order inside one execution, so all members share its call allowance, step limit, and deadline. Member parameters are exposed as "m<index>.<name>", so artifacts load into a matching ensemble built by application code.

The default reducer is a majority vote over canonical JSON outputs; ties go to the earliest member. A custom reducer is trusted application code that receives the ordered list of outputs and returns an output map or {:ok, map} / {:error, reason}.

Construction makes no model calls. With :size, a seeded sample of that many members is kept, as DSPy's Ensemble does.

Summary

Functions

Majority vote with canonical equality; ties go to the earliest output.

Builds an ensemble.

Types

t()

@type t() :: %Tune.Ensemble{
  members: [Tune.Program.t()],
  reducer: :majority | ([map()] -> term())
}

Functions

majority(outputs)

@spec majority([map()]) :: map()

Majority vote with canonical equality; ties go to the earliest output.

new(members, opts \\ [])

@spec new([Tune.Program.t()], keyword()) :: {:ok, t()} | {:error, Exception.t()}

Builds an ensemble.

Options: :reducer (:majority or a 1-arity function), :size, :seed.