textopt 0.0.0 → 0.1.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/README.md +44 -22
- package/dist/bootstrap-search/index.cjs +153 -73
- package/dist/bootstrap-search/index.d.cts +32 -10
- package/dist/bootstrap-search/index.d.mts +32 -10
- package/dist/bootstrap-search/index.mjs +144 -66
- package/dist/{demos-B0pVQjYC.d.mts → demos-1b7JiUue.d.mts} +10 -3
- package/dist/{demos-BTuzFNsp.d.cts → demos-CU9dy2oT.d.cts} +10 -3
- package/dist/demos-D2o0qSSo.cjs +244 -0
- package/dist/demos-DE2oxNWX.mjs +215 -0
- package/dist/file-cache.cjs +11 -3
- package/dist/file-cache.mjs +11 -3
- package/dist/gepa/index.cjs +76 -71
- package/dist/gepa/index.d.cts +12 -6
- package/dist/gepa/index.d.mts +12 -6
- package/dist/gepa/index.mjs +49 -46
- package/dist/index.cjs +129 -27
- package/dist/index.d.cts +145 -7
- package/dist/index.d.mts +145 -7
- package/dist/index.mjs +113 -15
- package/dist/{math-COOofUyv.cjs → math-BhlziRPc.cjs} +60 -9
- package/dist/math-Dqme4rYz.mjs +123 -0
- package/dist/mipro/index.cjs +98 -70
- package/dist/mipro/index.d.cts +17 -14
- package/dist/mipro/index.d.mts +17 -14
- package/dist/mipro/index.mjs +84 -58
- package/dist/opro/index.cjs +130 -51
- package/dist/opro/index.d.cts +17 -9
- package/dist/opro/index.d.mts +17 -9
- package/dist/opro/index.mjs +115 -38
- package/dist/{optimizer-B7SpRwl7.d.cts → optimizer-Bh5DPRMH.d.cts} +50 -4
- package/dist/{optimizer-DqCoth_w.d.mts → optimizer-Ck6-e_8o.d.mts} +50 -4
- package/dist/random-search/index.cjs +93 -49
- package/dist/random-search/index.d.cts +15 -13
- package/dist/random-search/index.d.mts +15 -13
- package/dist/random-search/index.mjs +83 -41
- package/dist/{reflection-CQToe-5B.d.cts → reflection-Dt3QrXhM.d.cts} +7 -11
- package/dist/{reflection-Cr_upzU0.d.mts → reflection-LRaAZP4e.d.mts} +7 -11
- package/dist/{evaluation-OZOp6TB7.cjs → reporting-CNHzbJC-.cjs} +165 -5
- package/dist/reporting-DQbAohc9.d.cts +240 -0
- package/dist/reporting-DQbAohc9.d.mts +240 -0
- package/dist/{evaluation-BV0nSZVx.mjs → reporting-DY-DC4HG.mjs} +124 -6
- package/dist/simba/index.cjs +210 -83
- package/dist/simba/index.d.cts +32 -11
- package/dist/simba/index.d.mts +32 -11
- package/dist/simba/index.mjs +200 -75
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +5 -3
- package/dist/testing.d.mts +5 -3
- package/dist/testing.mjs +1 -1
- package/package.json +4 -3
- package/dist/demos-B9BJiNKz.cjs +0 -143
- package/dist/demos-Degx6UmP.mjs +0 -126
- package/dist/math-DhrDmpFS.mjs +0 -78
- package/dist/types-CWv4IQFF.d.cts +0 -129
- package/dist/types-CWv4IQFF.d.mts +0 -129
package/dist/mipro/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_reporting = require("../reporting-CNHzbJC-.cjs");
|
|
3
3
|
const require_concurrency = require("../concurrency-C-cFzWW2.cjs");
|
|
4
|
-
const require_math = require("../math-
|
|
5
|
-
const require_demos = require("../demos-
|
|
4
|
+
const require_math = require("../math-BhlziRPc.cjs");
|
|
5
|
+
const require_demos = require("../demos-D2o0qSSo.cjs");
|
|
6
6
|
const require_text = require("../text-CK_HB3su.cjs");
|
|
7
7
|
const require_rng = require("../rng-DbA_rPIo.cjs");
|
|
8
8
|
const require_sampling = require("../sampling-Dars7ctR.cjs");
|
|
@@ -212,10 +212,14 @@ var MiproOptimizer = class {
|
|
|
212
212
|
this.#config = config;
|
|
213
213
|
}
|
|
214
214
|
async optimize(task) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
try {
|
|
216
|
+
return await runMipro({
|
|
217
|
+
config: this.#config,
|
|
218
|
+
task
|
|
219
|
+
});
|
|
220
|
+
} finally {
|
|
221
|
+
await require_reporting.flushReporters(task.reporters ?? []);
|
|
222
|
+
}
|
|
219
223
|
}
|
|
220
224
|
};
|
|
221
225
|
function buildMiproPrompt(args) {
|
|
@@ -274,9 +278,10 @@ function buildDatasetSummaryPrompt(examples) {
|
|
|
274
278
|
async function runMipro(args) {
|
|
275
279
|
const { config, task } = args;
|
|
276
280
|
const { instructionsPerComponent = DEFAULT_INSTRUCTIONS, minibatchSize = DEFAULT_MINIBATCH_SIZE, maxTrials = DEFAULT_MAX_TRIALS, startupTrials, gamma, surrogateSamples, multivariate, fullEvalInterval = DEFAULT_FULL_EVAL_INTERVAL, demoSets = DEFAULT_DEMO_SETS, maxDemos = DEFAULT_MAX_DEMOS, demoMinScore, exemplars = DEFAULT_EXEMPLARS, datasetSummary = true, summaryExamples = DEFAULT_SUMMARY_EXAMPLES, concurrency = 1, seed = 0, buildPrompt = buildMiproPrompt, tips = DEFAULT_TIPS, trackBestOutputs = false, checkpointCache = true } = config;
|
|
277
|
-
const { seedCandidate, trainingSet, validationSet = trainingSet, testSet, adapter, reflect, componentOptions, demoComponents, renderDemo, goldOutput, maxMetricCalls, renderDatum = renderDefault, batchSampler = require_sampling.createEpochShuffledSampler({ minibatchSize }), cache, cacheNamespace, retry, maxCostUsd, maxWallClockMs, instanceId = defaultInstanceId,
|
|
278
|
-
const
|
|
279
|
-
const
|
|
281
|
+
const { seedCandidate, trainingSet, validationSet = trainingSet, testSet, adapter, reflect, componentOptions, demoComponents, renderDemo, goldOutput, maxMetricCalls, renderDatum = renderDefault, batchSampler = require_sampling.createEpochShuffledSampler({ minibatchSize }), cache, cacheNamespace, retry, maxCostUsd, maxWallClockMs, instanceId = require_reporting.defaultInstanceId, reporters = [], onCheckpoint, resumeFrom, signal } = task;
|
|
282
|
+
const emit = require_reporting.createEmitter(reporters);
|
|
283
|
+
const deadline = require_reporting.createDeadline({ maxWallClockMs });
|
|
284
|
+
const components = require_reporting.componentNames(seedCandidate);
|
|
280
285
|
if (trainingSet.length === 0) throw new Error("optimize requires a non-empty trainingSet");
|
|
281
286
|
if (validationSet.length === 0) throw new Error("optimize requires a non-empty validationSet");
|
|
282
287
|
if (components.length === 0) throw new Error("optimize requires a seed candidate with at least one component");
|
|
@@ -294,24 +299,24 @@ async function runMipro(args) {
|
|
|
294
299
|
datum,
|
|
295
300
|
index
|
|
296
301
|
})) ?? [];
|
|
297
|
-
const fingerprint =
|
|
302
|
+
const fingerprint = require_reporting.runFingerprint({
|
|
298
303
|
seedCandidate,
|
|
299
304
|
trainingIds,
|
|
300
305
|
validationIds,
|
|
301
306
|
seed,
|
|
302
307
|
...cacheNamespace === void 0 ? {} : { cacheNamespace }
|
|
303
308
|
});
|
|
304
|
-
|
|
309
|
+
require_reporting.assertResumable({
|
|
305
310
|
fingerprint,
|
|
306
311
|
...resumeFrom === void 0 ? {} : { snapshot: resumeFrom }
|
|
307
312
|
});
|
|
308
313
|
const rng = require_rng.createSeededRng(seed, resumeFrom?.rngState);
|
|
309
|
-
const budget =
|
|
314
|
+
const budget = require_reporting.createBudget({
|
|
310
315
|
maxMetricCalls,
|
|
311
316
|
spent: resumeFrom?.metricCalls ?? 0
|
|
312
317
|
});
|
|
313
|
-
const evaluationCache = cache === false ? void 0 : cache ??
|
|
314
|
-
const evaluator =
|
|
318
|
+
const evaluationCache = cache === false ? void 0 : cache ?? require_reporting.createMemoryCache();
|
|
319
|
+
const evaluator = require_reporting.createEvaluator({
|
|
315
320
|
adapter,
|
|
316
321
|
budget,
|
|
317
322
|
...retry === void 0 ? {} : { retry },
|
|
@@ -319,15 +324,16 @@ async function runMipro(args) {
|
|
|
319
324
|
...evaluationCache === void 0 ? {} : { cache: evaluationCache },
|
|
320
325
|
trackOutputs: trackBestOutputs,
|
|
321
326
|
cacheHits: resumeFrom?.cacheHits ?? 0,
|
|
327
|
+
...resumeFrom?.usage === void 0 ? {} : { usage: resumeFrom.usage },
|
|
322
328
|
...signal === void 0 ? {} : { signal },
|
|
323
|
-
onEvaluation: (event) =>
|
|
329
|
+
onEvaluation: (event) => emit({
|
|
324
330
|
type: "evaluation",
|
|
325
331
|
...event
|
|
326
332
|
})
|
|
327
333
|
});
|
|
328
334
|
evaluator.restore(resumeFrom?.cache ?? []);
|
|
329
335
|
if (resumeFrom?.sampler !== void 0) batchSampler.restore?.(resumeFrom.sampler);
|
|
330
|
-
|
|
336
|
+
emit({
|
|
331
337
|
type: "start",
|
|
332
338
|
components,
|
|
333
339
|
validationSetSize: validationSet.length
|
|
@@ -374,20 +380,26 @@ async function runMipro(args) {
|
|
|
374
380
|
for (let index = 0; index < demoSets; index += 1) {
|
|
375
381
|
const affordable = Math.min(trainingSet.length, budget.remaining() - validationSet.length);
|
|
376
382
|
if (affordable < 1) break;
|
|
383
|
+
if (require_reporting.costExhausted({
|
|
384
|
+
usage: evaluator.usage(),
|
|
385
|
+
maxCostUsd
|
|
386
|
+
})) break;
|
|
377
387
|
const requested = demoSets === 1 ? maxDemos : Math.round(1 + index * (maxDemos - 1) / (demoSets - 1));
|
|
378
|
-
const harvest = await require_demos.
|
|
388
|
+
const harvest = await require_demos.harvestFewShotExamples({
|
|
379
389
|
adapter,
|
|
380
390
|
candidate: seedCandidate,
|
|
381
391
|
trainingSet,
|
|
382
392
|
...demoMinScore === void 0 ? {} : { minScore: demoMinScore },
|
|
383
393
|
maxDemos: requested,
|
|
384
394
|
maxMetricCalls: affordable,
|
|
395
|
+
...maxCostUsd === void 0 ? {} : { maxCostUsd: maxCostUsd - evaluator.usage().costUsd },
|
|
385
396
|
rng,
|
|
386
397
|
...renderDemo === void 0 ? {} : { renderDemo },
|
|
387
398
|
...signal === void 0 ? {} : { signal }
|
|
388
399
|
});
|
|
389
400
|
bootstrapMetricCalls += harvest.metricCalls;
|
|
390
401
|
budget.reserve(harvest.metricCalls);
|
|
402
|
+
evaluator.absorbUsage(harvest.usage);
|
|
391
403
|
if (harvest.demos.length > 0) blocks.push(require_demos.formatDemos(harvest.demos, renderDemo === void 0 ? {} : { render: renderDemo }));
|
|
392
404
|
}
|
|
393
405
|
return [.../* @__PURE__ */ new Set([
|
|
@@ -432,7 +444,7 @@ async function runMipro(args) {
|
|
|
432
444
|
});
|
|
433
445
|
menu[name] = [seedCandidate[name], ...drawn.filter((text) => text.length > 0)];
|
|
434
446
|
}
|
|
435
|
-
|
|
447
|
+
emit({
|
|
436
448
|
type: "menu",
|
|
437
449
|
menu,
|
|
438
450
|
reflectionCalls
|
|
@@ -462,11 +474,20 @@ async function runMipro(args) {
|
|
|
462
474
|
});
|
|
463
475
|
}
|
|
464
476
|
const seedEvaluation = resumeFrom === void 0 ? await fullSweep(seedCandidate, "seed") : void 0;
|
|
465
|
-
const seedScore = seedEvaluation === void 0 ? resumeFrom.seedScore :
|
|
477
|
+
const seedScore = seedEvaluation === void 0 ? resumeFrom.seedScore : require_reporting.requireMeasuredMean({
|
|
466
478
|
batch: seedEvaluation,
|
|
467
479
|
phase: "seed"
|
|
468
480
|
});
|
|
469
481
|
if (seedEvaluation !== void 0) fullEvaluations += 1;
|
|
482
|
+
if (seedEvaluation !== void 0) emit({
|
|
483
|
+
type: "candidateAccepted",
|
|
484
|
+
trial: 0,
|
|
485
|
+
candidateId: 0,
|
|
486
|
+
candidate: seedCandidate,
|
|
487
|
+
aggregateScore: seedScore,
|
|
488
|
+
instanceScores: require_reporting.instanceRow(seedEvaluation),
|
|
489
|
+
...trackBestOutputs ? { outputs: seedEvaluation.outputs } : {}
|
|
490
|
+
});
|
|
470
491
|
if (resumeFrom === void 0) surrogateInput.push({
|
|
471
492
|
choices: menuSizes.map(() => 0),
|
|
472
493
|
score: seedScore
|
|
@@ -474,6 +495,7 @@ async function runMipro(args) {
|
|
|
474
495
|
let best = resumeFrom?.best ?? seedCandidate;
|
|
475
496
|
let bestScore = resumeFrom?.bestScore ?? seedScore;
|
|
476
497
|
/** Absent on a resumed run until a sweep wins: outputs are not checkpointed. */
|
|
498
|
+
let acceptedCandidates = resumeFrom?.acceptedCandidates ?? 0;
|
|
477
499
|
let bestOutputs = seedEvaluation?.outputs;
|
|
478
500
|
const readings = new Map(resumeFrom?.readings ?? []);
|
|
479
501
|
const swept = new Set(resumeFrom?.swept ?? []);
|
|
@@ -493,6 +515,8 @@ async function runMipro(args) {
|
|
|
493
515
|
bootstrapMetricCalls,
|
|
494
516
|
metricCalls: budget.spent(),
|
|
495
517
|
cacheHits: evaluator.cacheHits(),
|
|
518
|
+
usage: evaluator.usage(),
|
|
519
|
+
acceptedCandidates,
|
|
496
520
|
rngState: rng.state(),
|
|
497
521
|
observations: [...observations],
|
|
498
522
|
surrogateInput: surrogateInput.map((entry) => ({
|
|
@@ -535,12 +559,12 @@ async function runMipro(args) {
|
|
|
535
559
|
try {
|
|
536
560
|
evaluation = await fullSweep(candidate, "validation");
|
|
537
561
|
} catch (err) {
|
|
538
|
-
if (err instanceof
|
|
562
|
+
if (err instanceof require_reporting.BudgetExhausted) return "budgetExhausted";
|
|
539
563
|
if (signal?.aborted) return "aborted";
|
|
540
564
|
throw err;
|
|
541
565
|
}
|
|
542
566
|
fullEvaluations += 1;
|
|
543
|
-
const score =
|
|
567
|
+
const score = require_reporting.measuredMean(evaluation);
|
|
544
568
|
if (score === void 0) return "swept";
|
|
545
569
|
surrogateInput.push({
|
|
546
570
|
choices,
|
|
@@ -554,11 +578,15 @@ async function runMipro(args) {
|
|
|
554
578
|
best = candidate;
|
|
555
579
|
bestScore = score;
|
|
556
580
|
bestOutputs = evaluation.outputs;
|
|
557
|
-
|
|
558
|
-
|
|
581
|
+
acceptedCandidates += 1;
|
|
582
|
+
emit({
|
|
583
|
+
type: "candidateAccepted",
|
|
559
584
|
trial,
|
|
560
|
-
|
|
561
|
-
|
|
585
|
+
candidateId: acceptedCandidates,
|
|
586
|
+
candidate,
|
|
587
|
+
aggregateScore: score,
|
|
588
|
+
instanceScores: require_reporting.instanceRow(evaluation),
|
|
589
|
+
...trackBestOutputs ? { outputs: evaluation.outputs } : {}
|
|
562
590
|
});
|
|
563
591
|
}
|
|
564
592
|
return "swept";
|
|
@@ -568,7 +596,7 @@ async function runMipro(args) {
|
|
|
568
596
|
stopReason = "aborted";
|
|
569
597
|
break;
|
|
570
598
|
}
|
|
571
|
-
if (
|
|
599
|
+
if (require_reporting.costExhausted({
|
|
572
600
|
usage: evaluator.usage(),
|
|
573
601
|
maxCostUsd
|
|
574
602
|
})) {
|
|
@@ -613,9 +641,9 @@ async function runMipro(args) {
|
|
|
613
641
|
candidateId: null,
|
|
614
642
|
iteration: trial
|
|
615
643
|
});
|
|
616
|
-
minibatchScore =
|
|
644
|
+
minibatchScore = require_reporting.measuredMean(evaluation);
|
|
617
645
|
} catch (err) {
|
|
618
|
-
if (err instanceof
|
|
646
|
+
if (err instanceof require_reporting.BudgetExhausted) {
|
|
619
647
|
stopReason = "budgetExhausted";
|
|
620
648
|
break;
|
|
621
649
|
}
|
|
@@ -625,47 +653,44 @@ async function runMipro(args) {
|
|
|
625
653
|
}
|
|
626
654
|
throw err;
|
|
627
655
|
}
|
|
628
|
-
if (minibatchScore
|
|
629
|
-
|
|
630
|
-
|
|
656
|
+
if (minibatchScore !== void 0) {
|
|
657
|
+
surrogateInput.push({
|
|
658
|
+
choices,
|
|
659
|
+
score: minibatchScore
|
|
660
|
+
});
|
|
661
|
+
const key = choices.join(",");
|
|
662
|
+
readings.set(key, [...readings.get(key) ?? [], minibatchScore]);
|
|
663
|
+
const observation = {
|
|
664
|
+
trial,
|
|
665
|
+
choices,
|
|
666
|
+
minibatchScore,
|
|
667
|
+
promoted: false
|
|
668
|
+
};
|
|
669
|
+
observations.push(observation);
|
|
670
|
+
emit({
|
|
671
|
+
type: "trial",
|
|
672
|
+
trial,
|
|
673
|
+
choices,
|
|
674
|
+
minibatchScore,
|
|
675
|
+
promoted: false
|
|
676
|
+
});
|
|
631
677
|
}
|
|
632
|
-
surrogateInput.push({
|
|
633
|
-
choices,
|
|
634
|
-
score: minibatchScore
|
|
635
|
-
});
|
|
636
|
-
const key = choices.join(",");
|
|
637
|
-
readings.set(key, [...readings.get(key) ?? [], minibatchScore]);
|
|
638
|
-
const observation = {
|
|
639
|
-
trial,
|
|
640
|
-
choices,
|
|
641
|
-
minibatchScore,
|
|
642
|
-
promoted: false
|
|
643
|
-
};
|
|
644
|
-
observations.push(observation);
|
|
645
|
-
onEvent?.({
|
|
646
|
-
type: "trial",
|
|
647
|
-
trial,
|
|
648
|
-
choices,
|
|
649
|
-
minibatchScore,
|
|
650
|
-
promoted: false
|
|
651
|
-
});
|
|
652
678
|
trial += 1;
|
|
653
|
-
|
|
679
|
+
let cadenceStop;
|
|
654
680
|
if (trial % fullEvalInterval === 0) {
|
|
655
681
|
const outcome = await sweepBestUnswept();
|
|
656
|
-
if (outcome === "budgetExhausted" || outcome === "aborted")
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
}
|
|
682
|
+
if (outcome === "budgetExhausted" || outcome === "aborted") cadenceStop = outcome;
|
|
683
|
+
if (outcome === "unaffordable") cadenceStop = "budgetExhausted";
|
|
684
|
+
}
|
|
685
|
+
await checkpoint();
|
|
686
|
+
if (cadenceStop !== void 0) {
|
|
687
|
+
stopReason = cadenceStop;
|
|
688
|
+
break;
|
|
664
689
|
}
|
|
665
690
|
}
|
|
666
691
|
if (stopReason === "maxTrials" && !signal?.aborted) await sweepBestUnswept();
|
|
667
692
|
if (signal?.aborted) stopReason = "aborted";
|
|
668
|
-
const
|
|
693
|
+
const heldOut = testSet === void 0 ? void 0 : await evaluator.evaluate({
|
|
669
694
|
candidate: best,
|
|
670
695
|
batch: testSet,
|
|
671
696
|
ids: testIds,
|
|
@@ -674,13 +699,17 @@ async function runMipro(args) {
|
|
|
674
699
|
candidateId: null,
|
|
675
700
|
iteration: trial,
|
|
676
701
|
charge: false
|
|
677
|
-
})
|
|
678
|
-
|
|
702
|
+
});
|
|
703
|
+
const testScore = heldOut === void 0 ? void 0 : require_reporting.measuredMean(heldOut);
|
|
704
|
+
emit({
|
|
679
705
|
type: "finish",
|
|
680
706
|
reason: stopReason,
|
|
707
|
+
bestCandidateId: acceptedCandidates,
|
|
681
708
|
bestScore,
|
|
682
709
|
metricCalls: budget.spent(),
|
|
683
|
-
...testScore === void 0 ? {} : { testScore }
|
|
710
|
+
...testScore === void 0 ? {} : { testScore },
|
|
711
|
+
...heldOut === void 0 ? {} : { testInstanceScores: require_reporting.instanceRow(heldOut) },
|
|
712
|
+
...heldOut === void 0 || !trackBestOutputs ? {} : { testOutputs: heldOut.outputs }
|
|
684
713
|
});
|
|
685
714
|
return {
|
|
686
715
|
snapshot: takeSnapshot(),
|
|
@@ -691,7 +720,8 @@ async function runMipro(args) {
|
|
|
691
720
|
...trackBestOutputs ? { bestOutputs } : {},
|
|
692
721
|
...testScore === void 0 ? {} : {
|
|
693
722
|
testScore,
|
|
694
|
-
testMetricCalls: evaluator.unchargedCalls()
|
|
723
|
+
testMetricCalls: evaluator.unchargedCalls(),
|
|
724
|
+
testUsage: evaluator.unchargedUsage()
|
|
695
725
|
},
|
|
696
726
|
trials: trial,
|
|
697
727
|
menu,
|
|
@@ -729,11 +759,9 @@ function assertConfig(config) {
|
|
|
729
759
|
if (config.gamma !== void 0 && (!Number.isFinite(config.gamma) || config.gamma <= 0 || config.gamma > 1)) throw new Error(`gamma must be within (0, 1], received ${config.gamma}`);
|
|
730
760
|
if (config.tips !== void 0 && config.tips.length === 0) throw new Error("tips must not be empty");
|
|
731
761
|
}
|
|
732
|
-
function defaultInstanceId(args) {
|
|
733
|
-
const hash = require_evaluation.stableHash(args.datum);
|
|
734
|
-
return hash === "" ? String(args.index) : hash;
|
|
735
|
-
}
|
|
736
762
|
//#endregion
|
|
737
763
|
exports.MiproOptimizer = MiproOptimizer;
|
|
738
764
|
exports.buildMiproPrompt = buildMiproPrompt;
|
|
765
|
+
exports.isCandidateAccepted = require_reporting.isCandidateAccepted;
|
|
766
|
+
exports.isRunFinished = require_reporting.isRunFinished;
|
|
739
767
|
exports.proposeConfiguration = proposeConfiguration;
|
package/dist/mipro/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as TextModel, a as RunFinished, c as Adapter, i as Reporter, l as Candidate, n as OptimizerEvent, o as isCandidateAccepted, r as ReportableEvent, s as isRunFinished, t as CandidateAccepted, v as UsageTotals } from "../reporting-DQbAohc9.cjs";
|
|
2
2
|
import { n as EvaluationCache, t as CachedScore } from "../cache-CuSo0NJ8.cjs";
|
|
3
3
|
import { t as Rng } from "../rng-BR5MOedA.cjs";
|
|
4
|
-
import { r as DemoRenderer } from "../demos-
|
|
5
|
-
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-
|
|
4
|
+
import { r as DemoRenderer } from "../demos-CU9dy2oT.cjs";
|
|
5
|
+
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-Bh5DPRMH.cjs";
|
|
6
6
|
import { t as BatchSampler } from "../sampling-axOwfZf5.cjs";
|
|
7
7
|
//#region src/mipro/optimize.d.ts
|
|
8
8
|
type MiproPromptBuilder = (args: {
|
|
@@ -131,6 +131,13 @@ interface MiproSnapshot {
|
|
|
131
131
|
bootstrapMetricCalls: number;
|
|
132
132
|
metricCalls: number;
|
|
133
133
|
cacheHits: number;
|
|
134
|
+
/** Usage already spent, so a resumed run reports totals and honours ceilings. */
|
|
135
|
+
usage?: UsageTotals;
|
|
136
|
+
/**
|
|
137
|
+
* Candidates accepted so far. Reporters key rows by this id, so restarting it
|
|
138
|
+
* at zero makes a resumed run collide with the run it continues.
|
|
139
|
+
*/
|
|
140
|
+
acceptedCandidates?: number;
|
|
134
141
|
rngState: number;
|
|
135
142
|
observations: MiproObservation[];
|
|
136
143
|
/** What the surrogate was fitted on: one entry per measured trial. */
|
|
@@ -187,7 +194,8 @@ interface MiproTask<Datum, Trajectory = unknown, Output = unknown, K extends str
|
|
|
187
194
|
}) => string;
|
|
188
195
|
/** Pass `false` to disable caching entirely. */
|
|
189
196
|
cache?: EvaluationCache | false;
|
|
190
|
-
|
|
197
|
+
/** Observers of the run. Every one sees every event; none can fail it. */
|
|
198
|
+
reporters?: readonly Reporter<MiproEvent<NoInfer<K>>>[];
|
|
191
199
|
/**
|
|
192
200
|
* Called with a resumable snapshot once the menus are built and after every
|
|
193
201
|
* trial. Persist it and a killed run costs the last trial, not the menus.
|
|
@@ -214,18 +222,13 @@ type MiproEvent<K extends string = string> = {
|
|
|
214
222
|
minibatchScore: number;
|
|
215
223
|
/** True when the trial earned a full validation sweep. */
|
|
216
224
|
promoted: boolean;
|
|
217
|
-
} | {
|
|
218
|
-
type: "
|
|
225
|
+
} | ({
|
|
226
|
+
type: "candidateAccepted";
|
|
219
227
|
trial: number;
|
|
220
|
-
|
|
221
|
-
score: number;
|
|
222
|
-
} | {
|
|
228
|
+
} & CandidateAccepted<K>) | ({
|
|
223
229
|
type: "finish";
|
|
224
230
|
reason: MiproStopReason;
|
|
225
|
-
|
|
226
|
-
metricCalls: number;
|
|
227
|
-
testScore?: number;
|
|
228
|
-
};
|
|
231
|
+
} & RunFinished);
|
|
229
232
|
interface MiproObservation {
|
|
230
233
|
trial: number;
|
|
231
234
|
choices: number[];
|
|
@@ -369,4 +372,4 @@ declare function proposeConfiguration(args: {
|
|
|
369
372
|
rng: Rng;
|
|
370
373
|
}): number[];
|
|
371
374
|
//#endregion
|
|
372
|
-
export { type MiproConfig, type MiproEvent, type MiproObservation, MiproOptimizer, type MiproPromptBuilder, type MiproResult, type MiproSnapshot, type MiproStopReason, type MiproTask, type Observation, buildMiproPrompt, proposeConfiguration };
|
|
375
|
+
export { type CandidateAccepted, type MiproConfig, type MiproEvent, type MiproObservation, MiproOptimizer, type MiproPromptBuilder, type MiproResult, type MiproSnapshot, type MiproStopReason, type MiproTask, type Observation, type OptimizerEvent, type ReportableEvent, type Reporter, type RunFinished, buildMiproPrompt, isCandidateAccepted, isRunFinished, proposeConfiguration };
|
package/dist/mipro/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as TextModel, a as RunFinished, c as Adapter, i as Reporter, l as Candidate, n as OptimizerEvent, o as isCandidateAccepted, r as ReportableEvent, s as isRunFinished, t as CandidateAccepted, v as UsageTotals } from "../reporting-DQbAohc9.mjs";
|
|
2
2
|
import { n as EvaluationCache, t as CachedScore } from "../cache-CuSo0NJ8.mjs";
|
|
3
3
|
import { t as Rng } from "../rng-BR5MOedA.mjs";
|
|
4
|
-
import { r as DemoRenderer } from "../demos-
|
|
5
|
-
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-
|
|
4
|
+
import { r as DemoRenderer } from "../demos-1b7JiUue.mjs";
|
|
5
|
+
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-Ck6-e_8o.mjs";
|
|
6
6
|
import { t as BatchSampler } from "../sampling-DFo_7RNJ.mjs";
|
|
7
7
|
//#region src/mipro/optimize.d.ts
|
|
8
8
|
type MiproPromptBuilder = (args: {
|
|
@@ -131,6 +131,13 @@ interface MiproSnapshot {
|
|
|
131
131
|
bootstrapMetricCalls: number;
|
|
132
132
|
metricCalls: number;
|
|
133
133
|
cacheHits: number;
|
|
134
|
+
/** Usage already spent, so a resumed run reports totals and honours ceilings. */
|
|
135
|
+
usage?: UsageTotals;
|
|
136
|
+
/**
|
|
137
|
+
* Candidates accepted so far. Reporters key rows by this id, so restarting it
|
|
138
|
+
* at zero makes a resumed run collide with the run it continues.
|
|
139
|
+
*/
|
|
140
|
+
acceptedCandidates?: number;
|
|
134
141
|
rngState: number;
|
|
135
142
|
observations: MiproObservation[];
|
|
136
143
|
/** What the surrogate was fitted on: one entry per measured trial. */
|
|
@@ -187,7 +194,8 @@ interface MiproTask<Datum, Trajectory = unknown, Output = unknown, K extends str
|
|
|
187
194
|
}) => string;
|
|
188
195
|
/** Pass `false` to disable caching entirely. */
|
|
189
196
|
cache?: EvaluationCache | false;
|
|
190
|
-
|
|
197
|
+
/** Observers of the run. Every one sees every event; none can fail it. */
|
|
198
|
+
reporters?: readonly Reporter<MiproEvent<NoInfer<K>>>[];
|
|
191
199
|
/**
|
|
192
200
|
* Called with a resumable snapshot once the menus are built and after every
|
|
193
201
|
* trial. Persist it and a killed run costs the last trial, not the menus.
|
|
@@ -214,18 +222,13 @@ type MiproEvent<K extends string = string> = {
|
|
|
214
222
|
minibatchScore: number;
|
|
215
223
|
/** True when the trial earned a full validation sweep. */
|
|
216
224
|
promoted: boolean;
|
|
217
|
-
} | {
|
|
218
|
-
type: "
|
|
225
|
+
} | ({
|
|
226
|
+
type: "candidateAccepted";
|
|
219
227
|
trial: number;
|
|
220
|
-
|
|
221
|
-
score: number;
|
|
222
|
-
} | {
|
|
228
|
+
} & CandidateAccepted<K>) | ({
|
|
223
229
|
type: "finish";
|
|
224
230
|
reason: MiproStopReason;
|
|
225
|
-
|
|
226
|
-
metricCalls: number;
|
|
227
|
-
testScore?: number;
|
|
228
|
-
};
|
|
231
|
+
} & RunFinished);
|
|
229
232
|
interface MiproObservation {
|
|
230
233
|
trial: number;
|
|
231
234
|
choices: number[];
|
|
@@ -369,4 +372,4 @@ declare function proposeConfiguration(args: {
|
|
|
369
372
|
rng: Rng;
|
|
370
373
|
}): number[];
|
|
371
374
|
//#endregion
|
|
372
|
-
export { type MiproConfig, type MiproEvent, type MiproObservation, MiproOptimizer, type MiproPromptBuilder, type MiproResult, type MiproSnapshot, type MiproStopReason, type MiproTask, type Observation, buildMiproPrompt, proposeConfiguration };
|
|
375
|
+
export { type CandidateAccepted, type MiproConfig, type MiproEvent, type MiproObservation, MiproOptimizer, type MiproPromptBuilder, type MiproResult, type MiproSnapshot, type MiproStopReason, type MiproTask, type Observation, type OptimizerEvent, type ReportableEvent, type Reporter, type RunFinished, buildMiproPrompt, isCandidateAccepted, isRunFinished, proposeConfiguration };
|