Dsxir.Optimizer.GEPA.Proposer.Reflective (dsxir v0.2.0)

Copy Markdown

Reflective instruction proposer. One LM call per invocation. Two flavours:

  • rewrite/4 — single parent. Given the current instruction, sampled rollouts (success + failure feedback), and the signature, the LM rewrites the instruction.
  • merge/5 — two parents. Given both parents' instructions and a small sample of feedback rollouts from each, the LM produces a hybrid.

Both return {:ok, instruction :: String.t()} | {:error, Exception.t()}. Parsing strips numbering, leading "Instruction:" labels, and surrounding quotes — same defensiveness as MIPROv2.Proposer.Grounded.

Summary

Functions

Two-parent merge. Asks the LM to produce a hybrid of instr_a and instr_b using parent A's rollouts as grounding evidence. One LM call.

Single-parent rewrite. Asks the LM to revise current_instruction in light of sampled rollouts (mix of successes and failures) and the predictor signature. One LM call.

Types

rollout()

Functions

merge(instr_a, instr_b, rollouts_a, signature, arg)

@spec merge(
  parent_a_instruction :: String.t(),
  parent_b_instruction :: String.t(),
  rollouts_a :: [rollout()],
  signature :: module(),
  lm :: {module(), keyword()}
) :: {:ok, String.t()} | {:error, Exception.t()}

Two-parent merge. Asks the LM to produce a hybrid of instr_a and instr_b using parent A's rollouts as grounding evidence. One LM call.

rewrite(current, rollouts, signature, arg)

@spec rewrite(
  current_instruction :: String.t(),
  rollouts :: [rollout()],
  signature :: module(),
  lm :: {module(), keyword()}
) :: {:ok, String.t()} | {:error, Exception.t()}

Single-parent rewrite. Asks the LM to revise current_instruction in light of sampled rollouts (mix of successes and failures) and the predictor signature. One LM call.