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,372 @@
|
|
|
1
|
+
import { n as Candidate, t as Adapter, u as TextModel } from "../types-CWv4IQFF.mjs";
|
|
2
|
+
import { n as EvaluationCache, t as CachedScore } from "../cache-CuSo0NJ8.mjs";
|
|
3
|
+
import { t as Rng } from "../rng-BR5MOedA.mjs";
|
|
4
|
+
import { r as DemoRenderer } from "../demos-B0pVQjYC.mjs";
|
|
5
|
+
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-DqCoth_w.mjs";
|
|
6
|
+
import { t as BatchSampler } from "../sampling-DFo_7RNJ.mjs";
|
|
7
|
+
//#region src/mipro/optimize.d.ts
|
|
8
|
+
type MiproPromptBuilder = (args: {
|
|
9
|
+
componentName: string;
|
|
10
|
+
seedText: string;
|
|
11
|
+
/** Rendered task inputs, for grounding. Empty when none were requested. */
|
|
12
|
+
exemplars: readonly string[];
|
|
13
|
+
/** A style hint, varied per draw so the menu is not four of one idea. */
|
|
14
|
+
tip: string;
|
|
15
|
+
}) => string;
|
|
16
|
+
interface MiproConfig {
|
|
17
|
+
/**
|
|
18
|
+
* Instructions generated per component, beyond the seed. Ignored for a
|
|
19
|
+
* component the caller supplied a menu for. Default 3.
|
|
20
|
+
*/
|
|
21
|
+
instructionsPerComponent?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Instances a trial is scored on. Default 35, MIPROv2's `minibatch_size`.
|
|
24
|
+
*
|
|
25
|
+
* The surrogate reads these means as evidence, so the size sets how much of
|
|
26
|
+
* what it learns is signal. Shrinking it is the cheapest way to buy trials
|
|
27
|
+
* and the fastest way to make them worthless: the good/bad split at thirty
|
|
28
|
+
* trials is three or four observations, and a lucky small minibatch is
|
|
29
|
+
* enough to put the wrong configuration among them.
|
|
30
|
+
*
|
|
31
|
+
* MIPROv2 also abandons minibatching altogether when the validation set is
|
|
32
|
+
* 50 instances or fewer (`MIN_MINIBATCH_SIZE`), evaluating every trial in
|
|
33
|
+
* full. textopt has no such mode; on a small validation set, set this to the
|
|
34
|
+
* set's size to get the same behaviour.
|
|
35
|
+
*/
|
|
36
|
+
minibatchSize?: number;
|
|
37
|
+
/** Configurations evaluated. Default 30. */
|
|
38
|
+
maxTrials?: number;
|
|
39
|
+
/** Trials drawn uniformly before the surrogate takes over. Default 10. */
|
|
40
|
+
startupTrials?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Fraction of observations the surrogate treats as good. Defaults to
|
|
43
|
+
* Optuna's rule — a tenth of them, capped at 25 — which narrows the good set
|
|
44
|
+
* as observations accumulate rather than holding a fixed share.
|
|
45
|
+
*/
|
|
46
|
+
gamma?: number;
|
|
47
|
+
/** Configurations the surrogate draws per trial. Default 24. */
|
|
48
|
+
surrogateSamples?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the surrogate models components jointly. Default true, matching
|
|
51
|
+
* MIPROv2. Set false when the components do independent jobs — see
|
|
52
|
+
* `proposeConfiguration` for the tradeoff.
|
|
53
|
+
*/
|
|
54
|
+
multivariate?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Trials between full validation sweeps. Every interval, the configuration
|
|
57
|
+
* with the best *average* minibatch reading that has not been swept yet is
|
|
58
|
+
* evaluated in full. Averaging is the point: a single minibatch is a noisy
|
|
59
|
+
* reading, and promoting on one alone lets a lucky draw decide the run.
|
|
60
|
+
* Default 5, MIPROv2's `minibatch_full_eval_steps`.
|
|
61
|
+
*
|
|
62
|
+
* MIPROv2 sweeps when `trial_num % (minibatch_full_eval_steps + 1) == 0`,
|
|
63
|
+
* which reads like every sixth trial but is not: Optuna numbers the seed
|
|
64
|
+
* baseline and each full evaluation as trials of their own, so the six slots
|
|
65
|
+
* hold five minibatch trials and one sweep. Its own budgeting says the same
|
|
66
|
+
* thing directly — `num_trials // minibatch_full_eval_steps + 1` sweeps for
|
|
67
|
+
* `num_trials` trials. This counts only minibatch trials, so 5 here and 5
|
|
68
|
+
* there describe one schedule.
|
|
69
|
+
*/
|
|
70
|
+
fullEvalInterval?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Bootstrapped demo sets generated per demo component, beyond the seed text
|
|
73
|
+
* and the zero-shot option. Default 3.
|
|
74
|
+
*/
|
|
75
|
+
demoSets?: number;
|
|
76
|
+
/** Demos in the largest generated set. Default 4. */
|
|
77
|
+
maxDemos?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Score a rollout must reach to be kept as a demo. Unset keeps every rollout
|
|
80
|
+
* the metric rewarded at all, as MIPROv2 does without a `metric_threshold`.
|
|
81
|
+
* Set 1 to demand a perfect score, which suits a boolean metric and discards
|
|
82
|
+
* most of a graded one.
|
|
83
|
+
*/
|
|
84
|
+
demoMinScore?: number;
|
|
85
|
+
/** Task inputs shown when generating instructions. Default 3. */
|
|
86
|
+
exemplars?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Summarize the training set with one reflection call and show that summary to
|
|
89
|
+
* the proposer, as MIPROv2's grounded proposer does. Default true. The
|
|
90
|
+
* summary reads more data than the exemplars can fit, so it describes the
|
|
91
|
+
* task rather than a few instances of it. Costs one reflection call, and is
|
|
92
|
+
* skipped entirely when every menu was supplied and nothing is proposed.
|
|
93
|
+
*/
|
|
94
|
+
datasetSummary?: boolean;
|
|
95
|
+
/** Trainset entries the summary is written from. Default 10. */
|
|
96
|
+
summaryExamples?: number;
|
|
97
|
+
/** How many instruction proposals may be in flight at once. Default 1. */
|
|
98
|
+
concurrency?: number;
|
|
99
|
+
seed?: number;
|
|
100
|
+
buildPrompt?: MiproPromptBuilder;
|
|
101
|
+
/** Replaces the built-in style hints. */
|
|
102
|
+
tips?: readonly string[];
|
|
103
|
+
trackBestOutputs?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Include cached instance scores in every checkpoint. Leaving them out keeps
|
|
106
|
+
* snapshots small at the cost of a resumed run re-paying for rollouts it
|
|
107
|
+
* cannot look up. Default true.
|
|
108
|
+
*/
|
|
109
|
+
checkpointCache?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Everything needed to continue a run.
|
|
113
|
+
*
|
|
114
|
+
* The menus matter most. Building them is the expensive half of a MIPRO run —
|
|
115
|
+
* a reflection call per instruction and a harvesting pass per demo set — and
|
|
116
|
+
* they are also what every trial's choice vector indexes into, so a resumed
|
|
117
|
+
* run that rebuilt them would both pay twice and reinterpret every
|
|
118
|
+
* observation it had already made.
|
|
119
|
+
*/
|
|
120
|
+
interface MiproSnapshot {
|
|
121
|
+
version: 1;
|
|
122
|
+
fingerprint: string;
|
|
123
|
+
/** Component name -> its option menu, in the order choices index it. */
|
|
124
|
+
menu: Record<string, string[]>;
|
|
125
|
+
best: Candidate;
|
|
126
|
+
bestScore: number;
|
|
127
|
+
seedScore: number;
|
|
128
|
+
trial: number;
|
|
129
|
+
fullEvaluations: number;
|
|
130
|
+
reflectionCalls: number;
|
|
131
|
+
bootstrapMetricCalls: number;
|
|
132
|
+
metricCalls: number;
|
|
133
|
+
cacheHits: number;
|
|
134
|
+
rngState: number;
|
|
135
|
+
observations: MiproObservation[];
|
|
136
|
+
/** What the surrogate was fitted on: one entry per measured trial. */
|
|
137
|
+
surrogateInput: {
|
|
138
|
+
choices: number[];
|
|
139
|
+
score: number;
|
|
140
|
+
}[];
|
|
141
|
+
/** Configuration key -> its minibatch readings so far. */
|
|
142
|
+
readings: [string, number[]][];
|
|
143
|
+
/** Configuration keys a full sweep has already bought. */
|
|
144
|
+
swept: string[];
|
|
145
|
+
/** Whatever the batch sampler reports from `state()`, when it has one. */
|
|
146
|
+
sampler?: unknown;
|
|
147
|
+
cache?: [string, CachedScore][];
|
|
148
|
+
}
|
|
149
|
+
interface MiproTask<Datum, Trajectory = unknown, Output = unknown, K extends string = string> extends OptimizerTask<Datum, Trajectory, Output, K> {
|
|
150
|
+
/**
|
|
151
|
+
* The base adapter, not `GepaAdapter`: the surrogate reads scores only, so
|
|
152
|
+
* this search never asks for traces or a reflective dataset.
|
|
153
|
+
*/
|
|
154
|
+
adapter: Adapter<Datum, Trajectory, Output, NoInfer<K>>;
|
|
155
|
+
/** Generates the menu for components no menu was supplied for. */
|
|
156
|
+
reflect: TextModel;
|
|
157
|
+
/**
|
|
158
|
+
* Menu entries for a component, used verbatim and never rewritten. This is
|
|
159
|
+
* where a bootstrapped demo block belongs: demos are harvested, not
|
|
160
|
+
* authored, and handing them to a rewriting model destroys them.
|
|
161
|
+
*/
|
|
162
|
+
componentOptions?: Partial<Record<NoInfer<K>, readonly string[]>>;
|
|
163
|
+
/**
|
|
164
|
+
* Components holding few-shot demo blocks. Their menus are bootstrapped from
|
|
165
|
+
* the trainingSet rather than written by `reflect` — MIPROv2 searches
|
|
166
|
+
* instructions and demonstrations together, and a demo is evidence a rollout
|
|
167
|
+
* actually produced, which asking a model to author would destroy.
|
|
168
|
+
*/
|
|
169
|
+
demoComponents?: readonly NoInfer<K>[];
|
|
170
|
+
/** Renders a harvested rollout as demo text. Defaults to JSON. */
|
|
171
|
+
renderDemo?: DemoRenderer<NoInfer<Datum>, NoInfer<Output>>;
|
|
172
|
+
/**
|
|
173
|
+
* The gold output for a training datum, where the caller has labels. Supply
|
|
174
|
+
* it and every demo component keeps a labels-only set on its menu, as
|
|
175
|
+
* MIPROv2 does — the one demo set that costs no rollouts at all, since the
|
|
176
|
+
* output is known rather than produced. Return `undefined` for an unlabelled
|
|
177
|
+
* datum. Nothing generic can infer this: only the caller knows which part of
|
|
178
|
+
* a datum is the answer.
|
|
179
|
+
*/
|
|
180
|
+
goldOutput?: (datum: NoInfer<Datum>) => NoInfer<Output> | undefined;
|
|
181
|
+
/** Renders a task input for the proposal prompt. Defaults to JSON. */
|
|
182
|
+
renderDatum?: (datum: NoInfer<Datum>) => string;
|
|
183
|
+
batchSampler?: BatchSampler<NoInfer<Datum>>;
|
|
184
|
+
instanceId?: (args: {
|
|
185
|
+
datum: NoInfer<Datum>;
|
|
186
|
+
index: number;
|
|
187
|
+
}) => string;
|
|
188
|
+
/** Pass `false` to disable caching entirely. */
|
|
189
|
+
cache?: EvaluationCache | false;
|
|
190
|
+
onEvent?: (event: MiproEvent<NoInfer<K>>) => void;
|
|
191
|
+
/**
|
|
192
|
+
* Called with a resumable snapshot once the menus are built and after every
|
|
193
|
+
* trial. Persist it and a killed run costs the last trial, not the menus.
|
|
194
|
+
*/
|
|
195
|
+
onCheckpoint?: (snapshot: MiproSnapshot) => void | Promise<void>;
|
|
196
|
+
/** Snapshot to continue from, instead of starting at the seed candidate. */
|
|
197
|
+
resumeFrom?: MiproSnapshot;
|
|
198
|
+
}
|
|
199
|
+
type MiproStopReason = "budgetExhausted" | "costExhausted" | "deadlineReached" | "maxTrials" | "aborted";
|
|
200
|
+
type MiproEvent<K extends string = string> = {
|
|
201
|
+
type: "start";
|
|
202
|
+
components: K[];
|
|
203
|
+
validationSetSize: number;
|
|
204
|
+
} | {
|
|
205
|
+
type: "menu";
|
|
206
|
+
menu: Record<K, string[]>;
|
|
207
|
+
reflectionCalls: number;
|
|
208
|
+
} | ({
|
|
209
|
+
type: "evaluation";
|
|
210
|
+
} & EvaluationEvent) | {
|
|
211
|
+
type: "trial";
|
|
212
|
+
trial: number;
|
|
213
|
+
choices: number[];
|
|
214
|
+
minibatchScore: number;
|
|
215
|
+
/** True when the trial earned a full validation sweep. */
|
|
216
|
+
promoted: boolean;
|
|
217
|
+
} | {
|
|
218
|
+
type: "incumbent";
|
|
219
|
+
trial: number;
|
|
220
|
+
choices: number[];
|
|
221
|
+
score: number;
|
|
222
|
+
} | {
|
|
223
|
+
type: "finish";
|
|
224
|
+
reason: MiproStopReason;
|
|
225
|
+
bestScore: number;
|
|
226
|
+
metricCalls: number;
|
|
227
|
+
testScore?: number;
|
|
228
|
+
};
|
|
229
|
+
interface MiproObservation {
|
|
230
|
+
trial: number;
|
|
231
|
+
choices: number[];
|
|
232
|
+
minibatchScore: number;
|
|
233
|
+
promoted: boolean;
|
|
234
|
+
/** The full validation score, present only on promoted trials. */
|
|
235
|
+
score?: number;
|
|
236
|
+
}
|
|
237
|
+
interface MiproResult<K extends string = string, Output = unknown> extends OptimizerResult<K, MiproStopReason, Output> {
|
|
238
|
+
/** The seed's full validation score, so the lift is readable directly. */
|
|
239
|
+
seedScore: number;
|
|
240
|
+
trials: number;
|
|
241
|
+
/** The search space that was actually explored, per component. */
|
|
242
|
+
menu: Record<K, string[]>;
|
|
243
|
+
observations: MiproObservation[];
|
|
244
|
+
/** Trials that earned a full sweep. The rest were minibatch readings only. */
|
|
245
|
+
fullEvaluations: number;
|
|
246
|
+
/** Rollouts spent harvesting demos, included in `metricCalls`. */
|
|
247
|
+
bootstrapMetricCalls: number;
|
|
248
|
+
reflectionCalls: number;
|
|
249
|
+
cacheHits: number;
|
|
250
|
+
/** State as of the last trial, ready to hand back as `resumeFrom`. */
|
|
251
|
+
snapshot: MiproSnapshot;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Joint search over a fixed menu, guided by a surrogate.
|
|
255
|
+
*
|
|
256
|
+
* The gap this fills is interaction between components. Reflective search
|
|
257
|
+
* updates one component per iteration and screens it in isolation, so a pair
|
|
258
|
+
* of components that only pay off together is invisible to it — a routing rule
|
|
259
|
+
* and the prompt it routes to, an output format and the instruction that
|
|
260
|
+
* assumes it. Merge recombines lineages after the fact but never proposes a
|
|
261
|
+
* joint move.
|
|
262
|
+
*
|
|
263
|
+
* This search proposes a menu of options per component up front, then treats
|
|
264
|
+
* the choice of one option per component as a single categorical
|
|
265
|
+
* configuration and lets a TPE decide which to spend a trial on. Trials run on
|
|
266
|
+
* minibatches; a configuration that beats the best minibatch reading earns a
|
|
267
|
+
* full sweep before it can become the incumbent, so the number reported is
|
|
268
|
+
* never a lucky minibatch.
|
|
269
|
+
*
|
|
270
|
+
* What it gives up is the ability to write text it did not think of at the
|
|
271
|
+
* start. The menu is fixed at trial one — reflective search keeps writing new
|
|
272
|
+
* text for the whole run. Neither dominates; they fail differently.
|
|
273
|
+
*/
|
|
274
|
+
declare class MiproOptimizer implements Optimizer<MiproStopReason> {
|
|
275
|
+
#private;
|
|
276
|
+
constructor(config?: MiproConfig);
|
|
277
|
+
optimize<Datum, Trajectory = unknown, Output = unknown, const K extends string = string>(task: MiproTask<Datum, Trajectory, Output, K>): Promise<MiproResult<K, Output>>;
|
|
278
|
+
}
|
|
279
|
+
declare function buildMiproPrompt(args: {
|
|
280
|
+
componentName: string;
|
|
281
|
+
seedText: string;
|
|
282
|
+
exemplars: readonly string[];
|
|
283
|
+
tip: string;
|
|
284
|
+
/** The other components' current text, so the proposal fits the system. */
|
|
285
|
+
siblings?: Readonly<Record<string, string>>;
|
|
286
|
+
/** What the trainingSet looks like as a whole, beyond the exemplars. */
|
|
287
|
+
datasetSummary?: string;
|
|
288
|
+
}): string;
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/mipro/tpe.d.ts
|
|
291
|
+
/** One configuration that was scored: an index into each component's menu. */
|
|
292
|
+
interface Observation {
|
|
293
|
+
choices: readonly number[];
|
|
294
|
+
score: number;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Tree-structured Parzen Estimator over a categorical space.
|
|
298
|
+
*
|
|
299
|
+
* The search space here is a menu index per component. A TPE splits the
|
|
300
|
+
* observations into the good ones and the rest, models the density of each,
|
|
301
|
+
* and proposes the configuration that maximizes their ratio: sample where
|
|
302
|
+
* good configurations live, prefer where bad ones do not.
|
|
303
|
+
*
|
|
304
|
+
* The densities are mixtures with one kernel centred on each observation,
|
|
305
|
+
* rather than one histogram per component. That distinction is the whole
|
|
306
|
+
* reason this optimizer exists. Per-component histograms only record how often
|
|
307
|
+
* an option appears among good trials, so a space where every option is
|
|
308
|
+
* equally common and only the *pairing* matters looks completely flat to them.
|
|
309
|
+
* A kernel centred on an observed configuration keeps its components together,
|
|
310
|
+
* so "B works, but only alongside A" survives into the proposal. It is what
|
|
311
|
+
* Optuna calls a multivariate sampler, and what MIPROv2 turns on.
|
|
312
|
+
*
|
|
313
|
+
* What this buys over sampling every combination: a candidate with five
|
|
314
|
+
* components and four options each has 1024 configurations and a budget for
|
|
315
|
+
* perhaps thirty evaluations. Per-component hill climbing cannot see
|
|
316
|
+
* interactions at all; enumerating cannot afford to. This can do both, at the
|
|
317
|
+
* cost of being an estimate.
|
|
318
|
+
*/
|
|
319
|
+
declare function proposeConfiguration(args: {
|
|
320
|
+
observations: readonly Observation[];
|
|
321
|
+
/** Menu length per component, positionally. */
|
|
322
|
+
menuSizes: readonly number[];
|
|
323
|
+
/**
|
|
324
|
+
* Fraction of observations treated as good. Defaults to Optuna's rule — a
|
|
325
|
+
* tenth of them, never more than 25 — which narrows the good set as the run
|
|
326
|
+
* goes on. A fixed fraction keeps admitting weaker observations as evidence
|
|
327
|
+
* accumulates, which is backwards: the more you have measured, the less a
|
|
328
|
+
* middling result should count as something to aim at.
|
|
329
|
+
*/
|
|
330
|
+
gamma?: number;
|
|
331
|
+
/** Configurations drawn before the best is chosen. Default 24. */
|
|
332
|
+
samples?: number;
|
|
333
|
+
/** Observations required before the model is trusted at all. Default 10. */
|
|
334
|
+
startupTrials?: number;
|
|
335
|
+
/**
|
|
336
|
+
* Total weight of the uniform prior, shared out across the kernels. Optuna's
|
|
337
|
+
* `prior_weight`. Each kernel carries `priorWeight / kernelCount` of it, so
|
|
338
|
+
* an observed option stands at `1 + kernelCount / priorWeight` against one
|
|
339
|
+
* beside it — twice as likely under a single kernel, and progressively
|
|
340
|
+
* sharper as observations accumulate.
|
|
341
|
+
*/
|
|
342
|
+
priorWeight?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Model components jointly rather than one at a time. Default true, as
|
|
345
|
+
* MIPROv2 sets on Optuna.
|
|
346
|
+
*
|
|
347
|
+
* Joint modelling is the only way to represent "this option works, but only
|
|
348
|
+
* beside that one", and it costs something where no such dependency exists.
|
|
349
|
+
* Kernels sit on observed *combinations*, so evidence does not carry across
|
|
350
|
+
* to combinations nobody has drawn; independent histograms generalize from
|
|
351
|
+
* far fewer trials but cannot express a dependency at all.
|
|
352
|
+
*
|
|
353
|
+
* Measured on a chained objective, where a component pays off only when the
|
|
354
|
+
* one before it is also right — the dependency independent histograms cannot
|
|
355
|
+
* represent. On five components of five options, 3125 configurations against
|
|
356
|
+
* 60 trials over 15 seeds, joint reaches a mean best of 0.91 and solves 10
|
|
357
|
+
* runs where independent reaches 0.80 and solves 6. On a 16-configuration
|
|
358
|
+
* space that 30 trials nearly enumerate, joint solves 20 runs of 20 against
|
|
359
|
+
* independent's 16.
|
|
360
|
+
*
|
|
361
|
+
* Joint led on the small space only once the kernels were given Optuna's
|
|
362
|
+
* smoothing. While each kernel stayed as wide as it was on the first trial,
|
|
363
|
+
* joint lost that case 15 runs to 16, and the default was argued for on the
|
|
364
|
+
* grounds that the case it lost was the one that needed a surrogate least.
|
|
365
|
+
* It no longer loses it, so that argument is retired: re-measure before
|
|
366
|
+
* repeating either number.
|
|
367
|
+
*/
|
|
368
|
+
multivariate?: boolean;
|
|
369
|
+
rng: Rng;
|
|
370
|
+
}): number[];
|
|
371
|
+
//#endregion
|
|
372
|
+
export { type MiproConfig, type MiproEvent, type MiproObservation, MiproOptimizer, type MiproPromptBuilder, type MiproResult, type MiproSnapshot, type MiproStopReason, type MiproTask, type Observation, buildMiproPrompt, proposeConfiguration };
|