shikumi-optimize
Safe HaskellNone
LanguageGHC2024

Shikumi.Optimize.COPRO

Description

COPRO (EP-21): coordinate-ascent prompt optimization. Where instructionSearch is one-shot per node, COPRO improves each node's instruction over several rounds (depth), proposing several candidates per round (breadth) and feeding the scored attempt history forward so later rounds learn from what scored well. It is the principled generalization of instructionSearch (depth-1, no-history COPRO ≈ instructionSearch), kept alongside it rather than replacing it.

COPRO consumes EP-19's grounded proposer (proposeInstructions) directly: each round's call passes the node's current instruction and its scored PastInstruction history, and the proposer returns ranked candidates with the current effective instruction always retained. Keeping that candidate writes no redundant override, preserving the safety property that a node never degrades.

Output is V1's CompiledProgram via freezeProgram, invoked through optimize and serialized unchanged (integration point #4).

Synopsis

Documentation

data CoproConfig Source #

COPRO's two knobs plus the shared Budget.

Constructors

CoproConfig 

Fields

  • breadth :: !Int

    candidate instructions generated per node per round (clamped to >= 2)

  • depth :: !Int

    number of coordinate-ascent rounds (clamped to >= 1)

  • budget :: !Budget

    LM-call / candidate ceilings

Instances

Instances details
Generic CoproConfig Source # 
Instance details

Defined in Shikumi.Optimize.COPRO

Associated Types

type Rep CoproConfig 
Instance details

Defined in Shikumi.Optimize.COPRO

type Rep CoproConfig = D1 ('MetaData "CoproConfig" "Shikumi.Optimize.COPRO" "shikumi-optimize-0.2.1.2-inplace" 'False) (C1 ('MetaCons "CoproConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "breadth") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "depth") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "budget") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Budget))))
Show CoproConfig Source # 
Instance details

Defined in Shikumi.Optimize.COPRO

Eq CoproConfig Source # 
Instance details

Defined in Shikumi.Optimize.COPRO

type Rep CoproConfig Source # 
Instance details

Defined in Shikumi.Optimize.COPRO

type Rep CoproConfig = D1 ('MetaData "CoproConfig" "Shikumi.Optimize.COPRO" "shikumi-optimize-0.2.1.2-inplace" 'False) (C1 ('MetaCons "CoproConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "breadth") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "depth") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "budget") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Budget))))

defaultCoproConfig :: CoproConfig Source #

Breadth 4, depth 3, the default budget.

copro :: (ToJSON i, ToJSON o) => CoproConfig -> Optimizer i o Source #

Coordinate-ascent instruction optimization. Visits each node in foldParams order, optimizing it over depth rounds against the already-improved earlier nodes. Proposer calls and candidate scoring reserve their predicted cost through one shared Budget, so the search returns the best-so-far before the next spend would exceed either ceiling.