textopt 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +509 -0
- package/dist/bootstrap-search/index.cjs +308 -0
- package/dist/bootstrap-search/index.d.cts +162 -0
- package/dist/bootstrap-search/index.d.mts +162 -0
- package/dist/bootstrap-search/index.mjs +307 -0
- package/dist/cache-CuSo0NJ8.d.cts +24 -0
- package/dist/cache-CuSo0NJ8.d.mts +24 -0
- package/dist/concurrency-C-cFzWW2.cjs +44 -0
- package/dist/concurrency-D58PWeSk.mjs +39 -0
- package/dist/demos-B0pVQjYC.d.mts +88 -0
- package/dist/demos-B9BJiNKz.cjs +143 -0
- package/dist/demos-BTuzFNsp.d.cts +88 -0
- package/dist/demos-Degx6UmP.mjs +126 -0
- package/dist/evaluation-BV0nSZVx.mjs +521 -0
- package/dist/evaluation-OZOp6TB7.cjs +598 -0
- package/dist/file-cache.cjs +70 -0
- package/dist/file-cache.d.cts +21 -0
- package/dist/file-cache.d.mts +21 -0
- package/dist/file-cache.mjs +69 -0
- package/dist/gepa/index.cjs +1671 -0
- package/dist/gepa/index.d.cts +385 -0
- package/dist/gepa/index.d.mts +385 -0
- package/dist/gepa/index.mjs +1652 -0
- package/dist/index.cjs +266 -0
- package/dist/index.d.cts +221 -0
- package/dist/index.d.mts +221 -0
- package/dist/index.mjs +245 -0
- package/dist/math-COOofUyv.cjs +101 -0
- package/dist/math-DhrDmpFS.mjs +78 -0
- package/dist/mipro/index.cjs +739 -0
- package/dist/mipro/index.d.cts +372 -0
- package/dist/mipro/index.d.mts +372 -0
- package/dist/mipro/index.mjs +736 -0
- package/dist/opro/index.cjs +487 -0
- package/dist/opro/index.d.cts +230 -0
- package/dist/opro/index.d.mts +230 -0
- package/dist/opro/index.mjs +485 -0
- package/dist/optimizer-B7SpRwl7.d.cts +288 -0
- package/dist/optimizer-DqCoth_w.d.mts +288 -0
- package/dist/random-search/index.cjs +321 -0
- package/dist/random-search/index.d.cts +156 -0
- package/dist/random-search/index.d.mts +156 -0
- package/dist/random-search/index.mjs +319 -0
- package/dist/reflection-CQToe-5B.d.cts +283 -0
- package/dist/reflection-Cr_upzU0.d.mts +283 -0
- package/dist/reflection-DRfbk6hu.cjs +249 -0
- package/dist/reflection-mwMhrjs_.mjs +214 -0
- package/dist/rng-BR5MOedA.d.cts +22 -0
- package/dist/rng-BR5MOedA.d.mts +22 -0
- package/dist/rng-DbA_rPIo.cjs +67 -0
- package/dist/rng-Dtc5eZ_W.mjs +62 -0
- package/dist/sampling-CfHt7Gue.mjs +59 -0
- package/dist/sampling-DFo_7RNJ.d.mts +23 -0
- package/dist/sampling-Dars7ctR.cjs +64 -0
- package/dist/sampling-axOwfZf5.d.cts +23 -0
- package/dist/simba/index.cjs +709 -0
- package/dist/simba/index.d.cts +289 -0
- package/dist/simba/index.d.mts +289 -0
- package/dist/simba/index.mjs +700 -0
- package/dist/testing.cjs +155 -0
- package/dist/testing.d.cts +53 -0
- package/dist/testing.d.mts +53 -0
- package/dist/testing.mjs +148 -0
- package/dist/text--v4Ffbus.mjs +21 -0
- package/dist/text-CK_HB3su.cjs +26 -0
- package/dist/types-CWv4IQFF.d.cts +129 -0
- package/dist/types-CWv4IQFF.d.mts +129 -0
- package/package.json +135 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { l as ScoreResult, u as TextModel } from "../types-CWv4IQFF.mjs";
|
|
2
|
+
import { n as EvaluationCache } from "../cache-CuSo0NJ8.mjs";
|
|
3
|
+
import { r as DemoRenderer } from "../demos-B0pVQjYC.mjs";
|
|
4
|
+
import { n as OptimizerResult, r as OptimizerTask, t as Optimizer } from "../optimizer-DqCoth_w.mjs";
|
|
5
|
+
import { C as RejectedProposal, S as ReflectiveRecord, T as ValEvaluationPolicy, _ as GepaStopReason, a as buildRewritePrompt, b as ProposeArgs, c as AcceptancePolicy, d as CandidateSource, f as ComponentPatch, g as GepaSnapshot, h as GepaEvent, i as buildReflectionPrompt, l as CandidateRecord, m as GepaAdapter, n as ReflectionPromptBuilder, o as buildSimplifyPrompt, p as ComponentSelector, r as buildGeneralizePrompt, s as diverseReflectionStrategies, t as ReflectionPromptArgs, u as CandidateSelector, v as MakeReflectiveDatasetArgs, w as SelectionState, x as ReflectiveDataset, y as ParetoFrontier } from "../reflection-Cr_upzU0.mjs";
|
|
6
|
+
import { t as BatchSampler } from "../sampling-DFo_7RNJ.mjs";
|
|
7
|
+
//#region src/gepa/demos.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* A proposer that fills demonstration components from rollouts the run has
|
|
10
|
+
* already paid for.
|
|
11
|
+
*
|
|
12
|
+
* The reflective dataset carries every minibatch rollout's input, output and
|
|
13
|
+
* score, so the successful ones are a few-shot block sitting in memory. Taking
|
|
14
|
+
* them costs no rollout and no reflection call — the search buys demos as a
|
|
15
|
+
* side effect of the evaluations it was making anyway.
|
|
16
|
+
*
|
|
17
|
+
* A proposal appends to the block its parent already holds rather than
|
|
18
|
+
* replacing it: a block built from one minibatch alone would hold three or
|
|
19
|
+
* four examples and forget every earlier one. Accumulation therefore follows
|
|
20
|
+
* the accepted lineage — a demo only persists if the candidate carrying it
|
|
21
|
+
* beat its parent, which is the same bar every other component is held to.
|
|
22
|
+
*/
|
|
23
|
+
declare function createDemoProposer<K extends string = string>(args: {
|
|
24
|
+
/** Components that hold demonstrations rather than instructions. */
|
|
25
|
+
components: readonly K[];
|
|
26
|
+
/** Score a rollout must reach to be kept as a demo. Default 1. */
|
|
27
|
+
minScore?: number;
|
|
28
|
+
/** Demos a block holds before the oldest are dropped. Default 4. */
|
|
29
|
+
maxDemos?: number;
|
|
30
|
+
render?: DemoRenderer;
|
|
31
|
+
/**
|
|
32
|
+
* Handles the components not named above. Defaults to ordinary reflection,
|
|
33
|
+
* so a candidate mixing instructions and demos needs nothing else wired up.
|
|
34
|
+
*/
|
|
35
|
+
fallback?: (args: ProposeArgs<K>) => Promise<ComponentPatch<K>>;
|
|
36
|
+
}): (args: ProposeArgs<K>) => Promise<ComponentPatch<K>>;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/gepa/pipeline.d.ts
|
|
39
|
+
/** One module of the system: a component's text, applied to what reached it. */
|
|
40
|
+
interface PipelineModule<Datum, K extends string> {
|
|
41
|
+
/** The candidate component holding this module's instruction. */
|
|
42
|
+
component: K;
|
|
43
|
+
run: (args: {
|
|
44
|
+
instruction: string;
|
|
45
|
+
/** The previous module's output, or the pipeline input for the first. */
|
|
46
|
+
input: unknown;
|
|
47
|
+
datum: Datum;
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}) => Promise<unknown> | unknown;
|
|
50
|
+
}
|
|
51
|
+
interface PipelineStep {
|
|
52
|
+
component: string;
|
|
53
|
+
input: unknown;
|
|
54
|
+
output: unknown;
|
|
55
|
+
}
|
|
56
|
+
/** What each module in one rollout received and produced, in order. */
|
|
57
|
+
interface PipelineTrace {
|
|
58
|
+
steps: PipelineStep[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A GEPA adapter for a system built from several modules in sequence, where
|
|
62
|
+
* each module's instruction is its own candidate component.
|
|
63
|
+
*
|
|
64
|
+
* The work this saves is attribution. Reflection on a multi-module system is
|
|
65
|
+
* only as good as the evidence it sees, and the evidence a module needs is what
|
|
66
|
+
* *it* received and produced — not the pipeline's input and final answer, which
|
|
67
|
+
* is what an adapter written in a hurry ends up showing every component.
|
|
68
|
+
*
|
|
69
|
+
* The feedback is end-to-end, and every module sees the same string. That is
|
|
70
|
+
* the honest default rather than a shortcut: a metric scores the final output,
|
|
71
|
+
* so nothing in a score alone says which module lost the point. A caller who
|
|
72
|
+
* can attribute better should score the steps themselves — `score` is handed
|
|
73
|
+
* the whole trace for exactly that.
|
|
74
|
+
*
|
|
75
|
+
* Errors from a module are not caught. A helper cannot tell a rate limit from a
|
|
76
|
+
* bug in a module, and guessing wrong either buries the bug or fails the run
|
|
77
|
+
* over a blip. Classify inside `run` and return a transient `ScoreResult` from
|
|
78
|
+
* `score`, or let the optimizer's `raiseOnError` decide.
|
|
79
|
+
*/
|
|
80
|
+
declare function createPipelineAdapter<Datum, Output = unknown, K extends string = string>(args: {
|
|
81
|
+
modules: readonly PipelineModule<Datum, K>[];
|
|
82
|
+
/** What the first module receives. Defaults to the datum itself. */
|
|
83
|
+
input?: (datum: Datum) => unknown;
|
|
84
|
+
score: (args: {
|
|
85
|
+
datum: Datum;
|
|
86
|
+
output: Output;
|
|
87
|
+
steps: readonly PipelineStep[];
|
|
88
|
+
}) => Promise<ScoreResult> | ScoreResult;
|
|
89
|
+
/** Rollouts in flight at once. Default 1. */
|
|
90
|
+
concurrency?: number;
|
|
91
|
+
}): GepaAdapter<Datum, PipelineTrace, Output, K>;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/gepa/optimize.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* How GEPA searches. Immutable, reusable across runs, and free of both the
|
|
96
|
+
* component names and the datum type — the honest line between this and
|
|
97
|
+
* `GepaTask` is "type-free and stateless" rather than "how it searches".
|
|
98
|
+
*
|
|
99
|
+
* Holds no run state: the candidate pool, the budget spent, the position of the
|
|
100
|
+
* random stream, rejected proposals and merge bookkeeping all live in
|
|
101
|
+
* `GepaSnapshot`.
|
|
102
|
+
*/
|
|
103
|
+
interface GepaConfig {
|
|
104
|
+
minibatchSize?: number;
|
|
105
|
+
maxIterations?: number;
|
|
106
|
+
seed?: number;
|
|
107
|
+
candidateSelector?: CandidateSelector;
|
|
108
|
+
acceptance?: AcceptancePolicy;
|
|
109
|
+
/**
|
|
110
|
+
* System-aware merge. Enabled by default for multi-component candidates,
|
|
111
|
+
* where two lineages can improve different components independently.
|
|
112
|
+
*
|
|
113
|
+
* The reference defaults `use_merge=False`, and the paper reports merge as
|
|
114
|
+
* the separate GEPA+Merge variant rather than as part of GEPA — a variant
|
|
115
|
+
* that helped on most models it was tried on and hurt on one. On by default
|
|
116
|
+
* here because the case it needs, several components moving along different
|
|
117
|
+
* lineages, is the case this library is usually pointed at. The cost is that
|
|
118
|
+
* a multi-component run is GEPA+Merge unless this is turned off, which
|
|
119
|
+
* spends rollouts on merge attempts and consumes the random stream
|
|
120
|
+
* differently, so trajectories will not line up with a reference run at the
|
|
121
|
+
* same seed. Set `enabled: false` for GEPA as published.
|
|
122
|
+
*/
|
|
123
|
+
merge?: {
|
|
124
|
+
enabled?: boolean;
|
|
125
|
+
maxInvocations?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Validation instances two lineages must share before they may be merged.
|
|
128
|
+
* Default 5, GEPA's `val_overlap_floor`. A merge is judged only on
|
|
129
|
+
* instances both parents were scored on, so below this the gate deciding
|
|
130
|
+
* whether to keep the child is reading noise. A validation set smaller than the
|
|
131
|
+
* floor can never merge.
|
|
132
|
+
*/
|
|
133
|
+
valOverlapFloor?: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Skip reflection when the parent already scores `perfectScore` on every
|
|
137
|
+
* minibatch instance. There is no failure to diagnose, so the rollouts a
|
|
138
|
+
* proposal would cost are better spent elsewhere. Default true.
|
|
139
|
+
*/
|
|
140
|
+
skipPerfectScore?: boolean;
|
|
141
|
+
/** Per-instance score treated as leaving no room to improve. Default 1. */
|
|
142
|
+
perfectScore?: number;
|
|
143
|
+
/**
|
|
144
|
+
* How many rejected proposals per component are shown back to the reflection
|
|
145
|
+
* model, most recent first. 0 disables the feedback. Default 3.
|
|
146
|
+
*
|
|
147
|
+
* Not in the paper or the reference implementation, where a rejected
|
|
148
|
+
* proposal fires a callback and is otherwise forgotten: whenever a proposal
|
|
149
|
+
* has been rejected, the prompt this builds is not the published one. Set 0
|
|
150
|
+
* for GEPA as written.
|
|
151
|
+
*
|
|
152
|
+
* It is not the only default that departs from the reference — the
|
|
153
|
+
* evaluation cache and, for multi-component seeds, merge are both on here
|
|
154
|
+
* and off there. See those options.
|
|
155
|
+
*/
|
|
156
|
+
rejectedProposalMemory?: number;
|
|
157
|
+
/**
|
|
158
|
+
* How many mutations an iteration proposes, and what happens to them.
|
|
159
|
+
*
|
|
160
|
+
* One proposal per iteration is GEPA as published. Raising `perIteration`
|
|
161
|
+
* samples the reflection model more than once against the same frontier —
|
|
162
|
+
* more shots at an improvement, screened on cheap minibatches before any of
|
|
163
|
+
* them costs a validation sweep — and `concurrency` is what turns that into
|
|
164
|
+
* wall-clock savings rather than just more rollouts.
|
|
165
|
+
*/
|
|
166
|
+
proposals?: {
|
|
167
|
+
/** Proposals drawn per iteration, each with its own parent and minibatch. */
|
|
168
|
+
perIteration?: number;
|
|
169
|
+
/** How many of them may be in flight at once. Default 1. */
|
|
170
|
+
concurrency?: number;
|
|
171
|
+
/**
|
|
172
|
+
* Which improving proposals are kept. "all" accepts every proposal that
|
|
173
|
+
* beat its own parent, "best" only the largest improvement, `{ keep: n }`
|
|
174
|
+
* the strongest n. Default "all".
|
|
175
|
+
*/
|
|
176
|
+
selection?: "all" | "best" | {
|
|
177
|
+
keep: number;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Bounds on the reflection model, which no metric budget covers: reflection
|
|
182
|
+
* calls are often the most expensive part of a run and the prompt carries
|
|
183
|
+
* traces of unbounded size.
|
|
184
|
+
*/
|
|
185
|
+
reflection?: {
|
|
186
|
+
/** Hard ceiling on reflection calls. The run stops once it is reached. */
|
|
187
|
+
maxCalls?: number;
|
|
188
|
+
/** Records shown per component. The worst scoring ones are kept. */
|
|
189
|
+
maxRecords?: number;
|
|
190
|
+
/** Rough ceiling on the characters the records serialize to. */
|
|
191
|
+
maxCharacters?: number;
|
|
192
|
+
/** Replaces the default prompt template. Ignored by custom proposers. */
|
|
193
|
+
buildPrompt?: ReflectionPromptBuilder;
|
|
194
|
+
/**
|
|
195
|
+
* Prompt templates rotated one per proposal, so raising
|
|
196
|
+
* `proposals.perIteration` samples different directions rather than the
|
|
197
|
+
* same one repeatedly. `diverseReflectionStrategies()` is a ready set.
|
|
198
|
+
* Mutually exclusive with `buildPrompt`. Ignored by custom proposers.
|
|
199
|
+
*/
|
|
200
|
+
strategies?: readonly ReflectionPromptBuilder[];
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Include cached instance scores in every checkpoint. Leaving them out keeps
|
|
204
|
+
* snapshots small at the cost of a resumed run re-paying for rollouts it
|
|
205
|
+
* cannot look up. Default true.
|
|
206
|
+
*/
|
|
207
|
+
checkpointCache?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Keep what each candidate produced on the validation instances it was
|
|
210
|
+
* scored on, so the winning outputs can be read back without re-running.
|
|
211
|
+
* Costs memory proportional to the outputs of every accepted candidate.
|
|
212
|
+
*/
|
|
213
|
+
trackBestOutputs?: boolean;
|
|
214
|
+
/** Rethrow adapter failures instead of skipping the iteration. Default true. */
|
|
215
|
+
raiseOnError?: boolean;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* One run: what is being optimized, over what data, with what run-scoped state
|
|
219
|
+
* and IO.
|
|
220
|
+
*
|
|
221
|
+
* `seedCandidate` and `trainingSet` are the inference sites for the component
|
|
222
|
+
* names and the datum type; every other position is `NoInfer`, so it is checked
|
|
223
|
+
* against them instead of widening them.
|
|
224
|
+
*/
|
|
225
|
+
interface GepaTask<Datum, Trajectory = unknown, Output = unknown, K extends string = string> extends OptimizerTask<Datum, Trajectory, Output, K> {
|
|
226
|
+
adapter: GepaAdapter<Datum, Trajectory, Output, NoInfer<K>>;
|
|
227
|
+
reflect: TextModel;
|
|
228
|
+
componentSelector?: ComponentSelector<NoInfer<K>>;
|
|
229
|
+
batchSampler?: BatchSampler<NoInfer<Datum>>;
|
|
230
|
+
/**
|
|
231
|
+
* Which validation instances each candidate is scored on. Defaults to a full
|
|
232
|
+
* sweep per accepted candidate, which is what makes the frontier exact.
|
|
233
|
+
*/
|
|
234
|
+
valEvaluationPolicy?: ValEvaluationPolicy<NoInfer<Datum>, NoInfer<K>>;
|
|
235
|
+
instanceId?: (args: {
|
|
236
|
+
datum: NoInfer<Datum>;
|
|
237
|
+
index: number;
|
|
238
|
+
}) => string;
|
|
239
|
+
/**
|
|
240
|
+
* Pass `false` to disable caching entirely.
|
|
241
|
+
*
|
|
242
|
+
* On by default, where the reference defaults `cache_evaluation=False`. A
|
|
243
|
+
* cache hit is free and uncharged, so the same `maxMetricCalls` buys a
|
|
244
|
+
* longer run here than there — the budget counts fresh rollouts, which is
|
|
245
|
+
* what costs money, rather than scorings. Pass `false` to compare rollout
|
|
246
|
+
* counts against a reference run directly.
|
|
247
|
+
*/
|
|
248
|
+
cache?: EvaluationCache | false;
|
|
249
|
+
onEvent?: (event: GepaEvent<NoInfer<K>>) => void;
|
|
250
|
+
/**
|
|
251
|
+
* Called with a resumable snapshot after the seed is scored and after every
|
|
252
|
+
* iteration. Persist it and a killed run costs the last iteration, not all
|
|
253
|
+
* of them.
|
|
254
|
+
*/
|
|
255
|
+
onCheckpoint?: (snapshot: GepaSnapshot) => void | Promise<void>;
|
|
256
|
+
/** Snapshot to continue from, instead of starting at the seed candidate. */
|
|
257
|
+
resumeFrom?: GepaSnapshot;
|
|
258
|
+
}
|
|
259
|
+
interface GepaResult<K extends string = string, Output = unknown> extends OptimizerResult<K, GepaStopReason, Output> {
|
|
260
|
+
bestCandidateId: number;
|
|
261
|
+
candidates: CandidateRecord<K>[];
|
|
262
|
+
paretoFrontier: CandidateRecord<K>[];
|
|
263
|
+
/**
|
|
264
|
+
* Per objective: the best value reached and every candidate that reached it.
|
|
265
|
+
* Absent when the adapter reports no objective scores.
|
|
266
|
+
*/
|
|
267
|
+
perObjectiveBest?: Record<string, {
|
|
268
|
+
score: number;
|
|
269
|
+
candidateIds: number[];
|
|
270
|
+
}>;
|
|
271
|
+
scoreMatrix: (number | undefined)[][];
|
|
272
|
+
iterations: number;
|
|
273
|
+
/** Calls made to the reflection model, which no metric budget covers. */
|
|
274
|
+
reflectionCalls: number;
|
|
275
|
+
cacheHits: number;
|
|
276
|
+
/** State as of the last iteration, ready to hand back as `resumeFrom`. */
|
|
277
|
+
snapshot: GepaSnapshot;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Reflective prompt evolution: propose, screen on a minibatch, promote what
|
|
281
|
+
* survives, and track the Pareto frontier of everything promoted.
|
|
282
|
+
*
|
|
283
|
+
* One instance is a configured search that can be run against any number of
|
|
284
|
+
* tasks. It holds no run state, so two runs never share a shuffle position, a
|
|
285
|
+
* budget or a candidate pool.
|
|
286
|
+
*/
|
|
287
|
+
declare class GepaOptimizer implements Optimizer<GepaStopReason> {
|
|
288
|
+
#private;
|
|
289
|
+
constructor(config?: GepaConfig);
|
|
290
|
+
optimize<Datum, Trajectory = unknown, Output = unknown, const K extends string = string>(task: GepaTask<Datum, Trajectory, Output, K>): Promise<GepaResult<K, Output>>;
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/gepa/strategies.d.ts
|
|
294
|
+
/**
|
|
295
|
+
* Default parent selection: sample from the instance-wise Pareto frontier with
|
|
296
|
+
* probability proportional to how many validation instances a candidate is best
|
|
297
|
+
* on. This is what keeps GEPA from tunnelling into one lineage.
|
|
298
|
+
*
|
|
299
|
+
* `frontier` chooses what the fronts are taken over. "instance" is GEPA as
|
|
300
|
+
* published. "objective" tracks candidates leading each named objective the
|
|
301
|
+
* adapter reports, and "hybrid" pools both — a candidate then earns selection
|
|
302
|
+
* weight for every instance it wins *and* every objective it leads.
|
|
303
|
+
*/
|
|
304
|
+
declare function paretoSelector(args?: {
|
|
305
|
+
epsilon?: number;
|
|
306
|
+
frontier?: ParetoFrontier;
|
|
307
|
+
}): CandidateSelector;
|
|
308
|
+
/** Greedy hill climbing. Useful as an ablation baseline. */
|
|
309
|
+
declare function currentBestSelector(): CandidateSelector;
|
|
310
|
+
declare function epsilonGreedySelector(args: {
|
|
311
|
+
epsilon: number;
|
|
312
|
+
}): CandidateSelector;
|
|
313
|
+
/** Pareto selection restricted to the top k candidates by aggregate score. */
|
|
314
|
+
declare function topKParetoSelector(args: {
|
|
315
|
+
k: number;
|
|
316
|
+
epsilon?: number;
|
|
317
|
+
}): CandidateSelector;
|
|
318
|
+
/**
|
|
319
|
+
* Score every accepted candidate on the whole validation set. This is GEPA as
|
|
320
|
+
* published: the frontier is exact, and the cost is one full sweep per
|
|
321
|
+
* acceptance.
|
|
322
|
+
*/
|
|
323
|
+
declare function fullEvaluationPolicy<Datum = unknown, K extends string = string>(): ValEvaluationPolicy<Datum, K>;
|
|
324
|
+
/**
|
|
325
|
+
* A full sweep, with the winner chosen by a lower confidence bound on its mean
|
|
326
|
+
* rather than by the mean itself: `mean - z * standardError`, over the
|
|
327
|
+
* instances the candidate was scored on.
|
|
328
|
+
*
|
|
329
|
+
* The reference picks the highest mean. That is an argmax over every candidate
|
|
330
|
+
* a run produced, all measured on the same instances, so the winner is
|
|
331
|
+
* systematically the one whose instance-level noise happened to land in its
|
|
332
|
+
* favour — the gap this library reports between `bestScore` and `testScore`.
|
|
333
|
+
* Penalising spread prefers a candidate that was even across the set to one
|
|
334
|
+
* carried by a few instances, at the cost of sometimes returning a genuinely
|
|
335
|
+
* better but less consistent candidate. It changes only which candidate is
|
|
336
|
+
* reported, never which ones the search explores.
|
|
337
|
+
*/
|
|
338
|
+
declare function lowerBoundEvaluationPolicy<Datum = unknown, K extends string = string>(args?: {
|
|
339
|
+
z?: number;
|
|
340
|
+
}): ValEvaluationPolicy<Datum, K>;
|
|
341
|
+
/**
|
|
342
|
+
* Score each candidate on a random subset of the validation set. Cheaper per
|
|
343
|
+
* acceptance, at the cost of comparing candidates measured on different
|
|
344
|
+
* instances — coverage breaks ties, so a candidate cannot win by having been
|
|
345
|
+
* asked fewer questions.
|
|
346
|
+
*/
|
|
347
|
+
declare function subsampledEvaluationPolicy<Datum = unknown, K extends string = string>(args: {
|
|
348
|
+
size: number;
|
|
349
|
+
}): ValEvaluationPolicy<Datum, K>;
|
|
350
|
+
/**
|
|
351
|
+
* One component per selection, cycling in declaration order from the parent's
|
|
352
|
+
* own cursor. Updating a single component at a time is what makes the minibatch
|
|
353
|
+
* acceptance test attributable; keying off the parent's cursor rather than the
|
|
354
|
+
* global iteration is what guarantees every component of a rarely-selected
|
|
355
|
+
* lineage eventually gets a turn.
|
|
356
|
+
*/
|
|
357
|
+
declare function roundRobinComponentSelector<K extends string = string>(): ComponentSelector<K>;
|
|
358
|
+
/** Update every component in a single reflection call. */
|
|
359
|
+
declare function allComponentsSelector<K extends string = string>(): ComponentSelector<K>;
|
|
360
|
+
/**
|
|
361
|
+
* Accept a mutation only when it beats its parent on the same minibatch. Cheap
|
|
362
|
+
* gate that keeps full validation sweeps for candidates that showed a signal.
|
|
363
|
+
*/
|
|
364
|
+
declare function improvementAcceptance(args?: {
|
|
365
|
+
minImprovement?: number;
|
|
366
|
+
}): AcceptancePolicy;
|
|
367
|
+
/**
|
|
368
|
+
* Accepts a child only when a paired permutation test over the minibatch says
|
|
369
|
+
* its gain is unlikely to be noise. Pairs are the same instances run by both
|
|
370
|
+
* candidates, so the test is over the per-instance differences.
|
|
371
|
+
*
|
|
372
|
+
* The reference accepts on any sum improvement. On a minibatch of three that
|
|
373
|
+
* promotes a candidate one lucky rollout ahead, which is what fills a pool
|
|
374
|
+
* with children the validation sweep then discards. The cost is that small
|
|
375
|
+
* batches cannot produce small p-values at all — with three instances the
|
|
376
|
+
* smallest attainable is 0.125 — so this accepts only a clean sweep there.
|
|
377
|
+
* That is the honest reading of three rollouts, not a limitation to tune
|
|
378
|
+
* around: raise `minibatchSize` to buy the power to detect smaller gains.
|
|
379
|
+
*/
|
|
380
|
+
declare function pairedPermutationAcceptance(args?: {
|
|
381
|
+
alpha?: number;
|
|
382
|
+
maxExact?: number;
|
|
383
|
+
}): AcceptancePolicy;
|
|
384
|
+
//#endregion
|
|
385
|
+
export { type AcceptancePolicy, type CandidateRecord, type CandidateSelector, type CandidateSource, type ComponentPatch, type ComponentSelector, type GepaAdapter, type GepaConfig, type GepaEvent, GepaOptimizer, type GepaResult, type GepaSnapshot, type GepaStopReason, type GepaTask, type MakeReflectiveDatasetArgs, type PipelineModule, type PipelineStep, type PipelineTrace, type ProposeArgs, type ReflectionPromptArgs, type ReflectionPromptBuilder, type ReflectiveDataset, type ReflectiveRecord, type RejectedProposal, type SelectionState, type ValEvaluationPolicy, allComponentsSelector, buildGeneralizePrompt, buildReflectionPrompt, buildRewritePrompt, buildSimplifyPrompt, createDemoProposer, createPipelineAdapter, currentBestSelector, diverseReflectionStrategies, epsilonGreedySelector, fullEvaluationPolicy, improvementAcceptance, lowerBoundEvaluationPolicy, pairedPermutationAcceptance, paretoSelector, roundRobinComponentSelector, subsampledEvaluationPolicy, topKParetoSelector };
|