shikumi-optimize
Safe HaskellNone
LanguageGHC2024

Shikumi.Optimize.Ensemble

Description

M4 — ensemble search. Run an inner optimizer several times on different bootstrap resamples of the training set (sampling with replacement, the classic bagging trick that makes the resulting candidates complementary), collect the candidate programs, and combine them into one program with EP-5's ensemble combinator under a majority-vote reducer. The ensemble runs all members on the input and returns their modal answer, which is correct more often than any single member when the members err on different inputs.

Resampling is deterministic (a fixed linear-congruential stream seeded by the member index), so the search is reproducible run to run.

The returned artifact is structure-changing: it is an Ensemble combinator over the optimized members, not just a parameter rewrite of the student. The member parameters are persisted by encodeCompiled, but the reducer closure and exact member structure live in the program template held in code. Load saved state onto the matching ensemble template, not onto the plain student.

Synopsis

Documentation

ensembleSearch :: Eq o => Int -> Optimizer i o -> Optimizer i o Source #

Build an size-member ensemble: run inner on size bootstrap resamples of the training set and combine the resulting programs by majority vote. This changes structure by returning an Ensemble; saved state must be decoded onto a matching ensemble template.

ensembleSearchWith :: Eq o => Budget -> Int -> Optimizer i o -> Optimizer i o Source #

Build a budgeted ensemble. The budget is enforced between members using exact LLM-call counting; at least one member always runs, so the final spend may exceed the bound by one member's cost.

majorityReducer :: Eq o => [o] -> o Source #

The modal value of a non-empty list under Eq: most frequent, ties broken by first appearance. This is the ensemble's default vote. (EP-4's modal is not exported, so it is reproduced here.)