textopt 0.1.0 → 0.2.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 +24 -6
- package/dist/bootstrap-search/index.cjs +29 -23
- package/dist/bootstrap-search/index.d.cts +3 -3
- package/dist/bootstrap-search/index.d.mts +3 -3
- package/dist/bootstrap-search/index.mjs +9 -3
- package/dist/{demos-D2o0qSSo.cjs → demos-9v5ts7F3.cjs} +4 -4
- package/dist/{demos-1b7JiUue.d.mts → demos-ASsSXYXA.d.mts} +1 -1
- package/dist/{demos-DE2oxNWX.mjs → demos-Brobjfuc.mjs} +1 -1
- package/dist/{demos-CU9dy2oT.d.cts → demos-ByaLZy-Z.d.cts} +1 -1
- package/dist/file-cache.cjs +16 -5
- package/dist/file-cache.d.cts +13 -0
- package/dist/file-cache.d.mts +13 -0
- package/dist/file-cache.mjs +16 -5
- package/dist/gepa/index.cjs +87 -44
- package/dist/gepa/index.d.cts +8 -6
- package/dist/gepa/index.d.mts +8 -6
- package/dist/gepa/index.mjs +55 -12
- package/dist/index.cjs +44 -19
- package/dist/index.d.cts +37 -5
- package/dist/index.d.mts +37 -5
- package/dist/index.mjs +29 -6
- package/dist/mipro/index.cjs +31 -25
- package/dist/mipro/index.d.cts +3 -3
- package/dist/mipro/index.d.mts +3 -3
- package/dist/mipro/index.mjs +9 -3
- package/dist/opro/index.cjs +31 -25
- package/dist/opro/index.d.cts +2 -2
- package/dist/opro/index.d.mts +2 -2
- package/dist/opro/index.mjs +8 -2
- package/dist/{optimizer-Bh5DPRMH.d.cts → optimizer-4Zv-Zt2t.d.cts} +41 -2
- package/dist/{optimizer-Ck6-e_8o.d.mts → optimizer-Ds5mzYjz.d.mts} +41 -2
- package/dist/random-search/index.cjs +27 -21
- package/dist/random-search/index.d.cts +2 -2
- package/dist/random-search/index.d.mts +2 -2
- package/dist/random-search/index.mjs +8 -2
- package/dist/{reflection-LRaAZP4e.d.mts → reflection-CMezGu6u.d.mts} +32 -4
- package/dist/{reflection-Dt3QrXhM.d.cts → reflection-D0A7eahD.d.cts} +32 -4
- package/dist/{reporting-DQbAohc9.d.cts → reporting-bq007_2z.d.cts} +55 -1
- package/dist/{reporting-DQbAohc9.d.mts → reporting-bq007_2z.d.mts} +55 -1
- package/dist/simba/index.cjs +31 -25
- package/dist/simba/index.d.cts +24 -5
- package/dist/simba/index.d.mts +24 -5
- package/dist/simba/index.mjs +9 -3
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/{reporting-CNHzbJC-.cjs → warnings-CWRJF-jA.cjs} +63 -0
- package/dist/{reporting-DY-DC4HG.mjs → warnings-OxvDi9kN.mjs} +52 -1
- package/docs/adapters.md +169 -0
- package/docs/benchmark.md +90 -0
- package/docs/data-prep.md +113 -0
- package/docs/distillation.md +128 -0
- package/docs/evaluation.md +87 -0
- package/docs/metric-preflight.md +132 -0
- package/docs/optimizers.md +293 -0
- package/docs/tuning.md +130 -0
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_warnings = require("./warnings-CWRJF-jA.cjs");
|
|
3
3
|
const require_concurrency = require("./concurrency-C-cFzWW2.cjs");
|
|
4
4
|
const require_math = require("./math-BhlziRPc.cjs");
|
|
5
|
-
const require_demos = require("./demos-
|
|
5
|
+
const require_demos = require("./demos-9v5ts7F3.cjs");
|
|
6
6
|
const require_text = require("./text-CK_HB3su.cjs");
|
|
7
7
|
//#region src/compare.ts
|
|
8
8
|
const EXACT_LIMIT = 20;
|
|
@@ -239,6 +239,10 @@ function createJudge(args) {
|
|
|
239
239
|
const { model, criteria, scale = DEFAULT_SCALE, renderInput = stringify, renderOutput = stringify, buildPrompt = buildJudgePrompt } = args;
|
|
240
240
|
if (criteria.length === 0) throw new Error("createJudge requires at least one criterion");
|
|
241
241
|
if (!Number.isFinite(scale) || scale <= 0) throw new Error(`scale must be a positive number, received ${scale}`);
|
|
242
|
+
assertCriteria({
|
|
243
|
+
criteria,
|
|
244
|
+
scale
|
|
245
|
+
});
|
|
242
246
|
return async ({ input, output, expected, signal }) => {
|
|
243
247
|
return readVerdict({
|
|
244
248
|
response: await model({
|
|
@@ -282,6 +286,7 @@ function buildJudgePrompt(args) {
|
|
|
282
286
|
`Grade each criterion from 0 to ${scale}, where ${scale} is a perfect answer.`,
|
|
283
287
|
"",
|
|
284
288
|
"Then write feedback. It is read by a program that rewrites the system's instructions, not by a person reviewing this output, so say what the instructions should tell the system to do differently. Feedback about this particular answer is of no use to it.",
|
|
289
|
+
...expected === void 0 ? [] : ["", "Do not restate the expected answer, or any fact drawn from it, in the feedback. The instruction it is rewritten into is reused on inputs whose answers you have not seen: a fact copied out of the expected answer becomes an answer key memorised in the prompt, which raises the score on this input and teaches the system nothing. Name the kind of thing the answer was missing, not the thing itself."],
|
|
285
290
|
"",
|
|
286
291
|
"Reply in exactly this format and nothing else:",
|
|
287
292
|
...criteria.map((criterion) => `<score name="${criterion.name}">…</score>`),
|
|
@@ -300,6 +305,9 @@ function readVerdict(args) {
|
|
|
300
305
|
const graded = /* @__PURE__ */ new Map();
|
|
301
306
|
for (const match of response.matchAll(SCORE)) graded.set(match[1], Number(match[2]));
|
|
302
307
|
const objectiveScores = {};
|
|
308
|
+
let gated = false;
|
|
309
|
+
let weighted = 0;
|
|
310
|
+
let totalWeight = 0;
|
|
303
311
|
for (const criterion of criteria) {
|
|
304
312
|
const grade = graded.get(criterion.name);
|
|
305
313
|
if (grade === void 0 || Number.isNaN(grade)) return {
|
|
@@ -307,15 +315,30 @@ function readVerdict(args) {
|
|
|
307
315
|
feedback: `Judge did not grade "${criterion.name}".`,
|
|
308
316
|
transient: true
|
|
309
317
|
};
|
|
310
|
-
|
|
318
|
+
const normalized = clamp(grade / scale);
|
|
319
|
+
objectiveScores[criterion.name] = normalized;
|
|
320
|
+
if (criterion.gate !== void 0 && grade < criterion.gate) gated = true;
|
|
321
|
+
const weight = criterion.weight ?? 1;
|
|
322
|
+
weighted += normalized * weight;
|
|
323
|
+
totalWeight += weight;
|
|
311
324
|
}
|
|
312
|
-
const grades = Object.values(objectiveScores);
|
|
313
325
|
return {
|
|
314
|
-
score:
|
|
326
|
+
score: gated ? 0 : weighted / totalWeight,
|
|
315
327
|
feedback,
|
|
316
328
|
objectiveScores
|
|
317
329
|
};
|
|
318
330
|
}
|
|
331
|
+
function assertCriteria(args) {
|
|
332
|
+
const { criteria, scale } = args;
|
|
333
|
+
let totalWeight = 0;
|
|
334
|
+
for (const { name, weight = 1, gate } of criteria) {
|
|
335
|
+
if (!Number.isFinite(weight) || weight < 0) throw new Error(`weight on criterion "${name}" must be a non-negative number, received ${weight}`);
|
|
336
|
+
totalWeight += weight;
|
|
337
|
+
if (gate !== void 0 && (!Number.isFinite(gate) || gate <= 0)) throw new Error(`gate on criterion "${name}" must be greater than 0, received ${gate}; no grade can fall below 0`);
|
|
338
|
+
if (gate !== void 0 && gate > scale) throw new Error(`gate on criterion "${name}" is ${gate}, above the scale of ${scale}; no grade can reach it`);
|
|
339
|
+
}
|
|
340
|
+
if (totalWeight <= 0) throw new Error("criteria weights must sum to more than 0; at least one criterion has to count towards the score");
|
|
341
|
+
}
|
|
319
342
|
function stringify(value) {
|
|
320
343
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
321
344
|
}
|
|
@@ -341,28 +364,30 @@ function priceUsage(args) {
|
|
|
341
364
|
};
|
|
342
365
|
}
|
|
343
366
|
//#endregion
|
|
344
|
-
exports.BudgetExhausted =
|
|
345
|
-
exports.assertResumable =
|
|
367
|
+
exports.BudgetExhausted = require_warnings.BudgetExhausted;
|
|
368
|
+
exports.assertResumable = require_warnings.assertResumable;
|
|
346
369
|
exports.buildJudgePrompt = buildJudgePrompt;
|
|
347
|
-
exports.candidateFingerprint =
|
|
370
|
+
exports.candidateFingerprint = require_warnings.candidateFingerprint;
|
|
348
371
|
exports.compare = compare;
|
|
349
|
-
exports.componentNames =
|
|
350
|
-
exports.costExhausted =
|
|
351
|
-
exports.createBudget =
|
|
352
|
-
exports.createDeadline =
|
|
353
|
-
exports.createEvaluator =
|
|
372
|
+
exports.componentNames = require_warnings.componentNames;
|
|
373
|
+
exports.costExhausted = require_warnings.costExhausted;
|
|
374
|
+
exports.createBudget = require_warnings.createBudget;
|
|
375
|
+
exports.createDeadline = require_warnings.createDeadline;
|
|
376
|
+
exports.createEvaluator = require_warnings.createEvaluator;
|
|
354
377
|
exports.createJudge = createJudge;
|
|
355
|
-
exports.createMemoryCache =
|
|
378
|
+
exports.createMemoryCache = require_warnings.createMemoryCache;
|
|
356
379
|
exports.formatDemos = require_demos.formatDemos;
|
|
357
380
|
exports.harvestFewShotExamples = require_demos.harvestFewShotExamples;
|
|
358
381
|
exports.harvestRollouts = require_demos.harvestRollouts;
|
|
359
|
-
exports.isCandidateAccepted =
|
|
360
|
-
exports.isRunFinished =
|
|
382
|
+
exports.isCandidateAccepted = require_warnings.isCandidateAccepted;
|
|
383
|
+
exports.isRunFinished = require_warnings.isRunFinished;
|
|
361
384
|
exports.mapWithConcurrency = require_concurrency.mapWithConcurrency;
|
|
362
|
-
exports.measuredMean =
|
|
385
|
+
exports.measuredMean = require_warnings.measuredMean;
|
|
363
386
|
exports.parseDemos = require_demos.parseDemos;
|
|
364
387
|
exports.parseProposedText = require_text.parseProposedText;
|
|
365
388
|
exports.priceUsage = priceUsage;
|
|
366
|
-
exports.requireMeasuredMean =
|
|
367
|
-
exports.
|
|
389
|
+
exports.requireMeasuredMean = require_warnings.requireMeasuredMean;
|
|
390
|
+
exports.resolveValidationSet = require_warnings.resolveValidationSet;
|
|
391
|
+
exports.runFingerprint = require_warnings.runFingerprint;
|
|
392
|
+
exports.seedScoreWarnings = require_warnings.seedScoreWarnings;
|
|
368
393
|
exports.toTrainingJsonl = toTrainingJsonl;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { C as componentNames, S as UsageTotals, _ as EvaluationPhase, a as RunFinished, b as ScoreResult, c as RunWarning, d as seedScoreWarnings, f as Adapter, g as EvaluationContext, h as EvaluationBatch, i as Reporter, l as RunWarningCode, m as EvaluateArgs, n as OptimizerEvent, o as isCandidateAccepted, p as Candidate, r as ReportableEvent, s as isRunFinished, t as CandidateAccepted, u as resolveValidationSet, v as EvaluationSplit, x as TextModel, y as RolloutUsage } from "./reporting-bq007_2z.cjs";
|
|
2
2
|
import { n as EvaluationCache, r as createMemoryCache, t as CachedScore } from "./cache-CuSo0NJ8.cjs";
|
|
3
3
|
import { t as Rng } from "./rng-BR5MOedA.cjs";
|
|
4
|
-
import { a as harvestFewShotExamples, i as formatDemos, n as Demo, o as parseDemos, r as DemoRenderer, t as BootstrapResult } from "./demos-
|
|
5
|
-
import { a as EvaluateBatchArgs, c as Evaluator, d as costExhausted, f as createEvaluator, g as createBudget, h as Budget, i as BudgetExhausted, l as RetryPolicy, m as requireMeasuredMean, n as OptimizerResult, o as EvaluateTracedArgs, p as measuredMean, r as OptimizerTask, s as EvaluationEvent, t as Optimizer, u as ScoredBatch } from "./optimizer-
|
|
4
|
+
import { a as harvestFewShotExamples, i as formatDemos, n as Demo, o as parseDemos, r as DemoRenderer, t as BootstrapResult } from "./demos-ByaLZy-Z.cjs";
|
|
5
|
+
import { a as EvaluateBatchArgs, c as Evaluator, d as costExhausted, f as createEvaluator, g as createBudget, h as Budget, i as BudgetExhausted, l as RetryPolicy, m as requireMeasuredMean, n as OptimizerResult, o as EvaluateTracedArgs, p as measuredMean, r as OptimizerTask, s as EvaluationEvent, t as Optimizer, u as ScoredBatch } from "./optimizer-4Zv-Zt2t.cjs";
|
|
6
6
|
import { t as BatchSampler } from "./sampling-axOwfZf5.cjs";
|
|
7
7
|
//#region src/checkpoint.d.ts
|
|
8
8
|
/**
|
|
@@ -252,7 +252,7 @@ interface TrainingExample {
|
|
|
252
252
|
* candidate to leave in the input. Dropping it entirely moves the whole prompt
|
|
253
253
|
* into weights and gives up the ability to steer the model with text
|
|
254
254
|
* afterwards; keeping a short task statement distills away only the tokens the
|
|
255
|
-
* search accreted. See `docs/distillation.md
|
|
255
|
+
* search accreted. See `docs/distillation.md` in this package.
|
|
256
256
|
*/
|
|
257
257
|
type TrainingExampleRenderer<Datum, Output> = (args: {
|
|
258
258
|
rollout: Rollout<Datum, Output>;
|
|
@@ -279,6 +279,38 @@ declare function toTrainingJsonl<Datum, Output>(args: {
|
|
|
279
279
|
interface JudgeCriterion {
|
|
280
280
|
name: string;
|
|
281
281
|
description: string;
|
|
282
|
+
/**
|
|
283
|
+
* Share of the instance score this criterion carries, relative to the other
|
|
284
|
+
* criteria. Default 1, which is the unweighted mean.
|
|
285
|
+
*
|
|
286
|
+
* 0 removes a criterion from the aggregate, not from the search. It is still
|
|
287
|
+
* graded and still recorded in `objectiveScores`, which
|
|
288
|
+
* `paretoSelector({ frontier: "objective" })` and `"hybrid"` build their
|
|
289
|
+
* selection fronts from — so a candidate leading a zero-weight criterion
|
|
290
|
+
* still earns parent selection under those. Under the default instance
|
|
291
|
+
* frontier, 0 is enough. For a number that can never steer the search,
|
|
292
|
+
* compute it outside the judge.
|
|
293
|
+
*/
|
|
294
|
+
weight?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Grade, on the judge's own scale, that this criterion must reach for the
|
|
297
|
+
* instance to score at all. Below it the instance scores 0 whatever the
|
|
298
|
+
* other criteria said.
|
|
299
|
+
*
|
|
300
|
+
* A mean lets a search trade a hard requirement away: a candidate that tanks
|
|
301
|
+
* one non-negotiable criterion and aces three cosmetic ones outranks the
|
|
302
|
+
* incumbent that kept the rule. Anything a caller would not ship without is
|
|
303
|
+
* a gate rather than a term in the average.
|
|
304
|
+
*
|
|
305
|
+
* Enforce it once. A gate already makes the requirement non-negotiable, so a
|
|
306
|
+
* heavy `weight` on the same criterion redistributes score only among
|
|
307
|
+
* candidates that all cleared it — and pins that share of the aggregate near
|
|
308
|
+
* its ceiling, narrowing the range the search has left to move in. Gate it,
|
|
309
|
+
* then weight it low.
|
|
310
|
+
*
|
|
311
|
+
* @see docs/metric-preflight.md
|
|
312
|
+
*/
|
|
313
|
+
gate?: number;
|
|
282
314
|
}
|
|
283
315
|
type JudgePromptBuilder = (args: {
|
|
284
316
|
input: string;
|
|
@@ -356,4 +388,4 @@ declare function priceUsage(args: {
|
|
|
356
388
|
pricing?: TokenPricing;
|
|
357
389
|
}): RolloutUsage;
|
|
358
390
|
//#endregion
|
|
359
|
-
export { type Adapter, type BatchSampler, type BootstrapResult, type Budget, BudgetExhausted, type CachedScore, type Candidate, type CandidateAccepted, type ChatMessage, type Comparison, type ComparisonRun, type ComparisonSummary, type Deadline, type Demo, type DemoRenderer, type EvaluateArgs, type EvaluateBatchArgs, type EvaluateTracedArgs, type EvaluationBatch, type EvaluationCache, type EvaluationContext, type EvaluationEvent, type EvaluationPhase, type EvaluationSplit, type Evaluator, type HarvestResult, type Judge, type JudgeCriterion, type JudgePromptBuilder, type Optimizer, type OptimizerEvent, type OptimizerResult, type OptimizerTask, type ReportableEvent, type Reporter, type RetryPolicy, type Rng, type Rollout, type RolloutUsage, type RunFinished, type ScoreResult, type ScoredBatch, type TextModel, type TokenPricing, type TrainingExample, type TrainingExampleRenderer, type UsageTotals, assertResumable, buildJudgePrompt, candidateFingerprint, compare, componentNames, costExhausted, createBudget, createDeadline, createEvaluator, createJudge, createMemoryCache, formatDemos, harvestFewShotExamples, harvestRollouts, isCandidateAccepted, isRunFinished, mapWithConcurrency, measuredMean, parseDemos, parseProposedText, priceUsage, requireMeasuredMean, runFingerprint, toTrainingJsonl };
|
|
391
|
+
export { type Adapter, type BatchSampler, type BootstrapResult, type Budget, BudgetExhausted, type CachedScore, type Candidate, type CandidateAccepted, type ChatMessage, type Comparison, type ComparisonRun, type ComparisonSummary, type Deadline, type Demo, type DemoRenderer, type EvaluateArgs, type EvaluateBatchArgs, type EvaluateTracedArgs, type EvaluationBatch, type EvaluationCache, type EvaluationContext, type EvaluationEvent, type EvaluationPhase, type EvaluationSplit, type Evaluator, type HarvestResult, type Judge, type JudgeCriterion, type JudgePromptBuilder, type Optimizer, type OptimizerEvent, type OptimizerResult, type OptimizerTask, type ReportableEvent, type Reporter, type RetryPolicy, type Rng, type Rollout, type RolloutUsage, type RunFinished, type RunWarning, type RunWarningCode, type ScoreResult, type ScoredBatch, type TextModel, type TokenPricing, type TrainingExample, type TrainingExampleRenderer, type UsageTotals, assertResumable, buildJudgePrompt, candidateFingerprint, compare, componentNames, costExhausted, createBudget, createDeadline, createEvaluator, createJudge, createMemoryCache, formatDemos, harvestFewShotExamples, harvestRollouts, isCandidateAccepted, isRunFinished, mapWithConcurrency, measuredMean, parseDemos, parseProposedText, priceUsage, requireMeasuredMean, resolveValidationSet, runFingerprint, seedScoreWarnings, toTrainingJsonl };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { C as componentNames, S as UsageTotals, _ as EvaluationPhase, a as RunFinished, b as ScoreResult, c as RunWarning, d as seedScoreWarnings, f as Adapter, g as EvaluationContext, h as EvaluationBatch, i as Reporter, l as RunWarningCode, m as EvaluateArgs, n as OptimizerEvent, o as isCandidateAccepted, p as Candidate, r as ReportableEvent, s as isRunFinished, t as CandidateAccepted, u as resolveValidationSet, v as EvaluationSplit, x as TextModel, y as RolloutUsage } from "./reporting-bq007_2z.mjs";
|
|
2
2
|
import { n as EvaluationCache, r as createMemoryCache, t as CachedScore } from "./cache-CuSo0NJ8.mjs";
|
|
3
3
|
import { t as Rng } from "./rng-BR5MOedA.mjs";
|
|
4
|
-
import { a as harvestFewShotExamples, i as formatDemos, n as Demo, o as parseDemos, r as DemoRenderer, t as BootstrapResult } from "./demos-
|
|
5
|
-
import { a as EvaluateBatchArgs, c as Evaluator, d as costExhausted, f as createEvaluator, g as createBudget, h as Budget, i as BudgetExhausted, l as RetryPolicy, m as requireMeasuredMean, n as OptimizerResult, o as EvaluateTracedArgs, p as measuredMean, r as OptimizerTask, s as EvaluationEvent, t as Optimizer, u as ScoredBatch } from "./optimizer-
|
|
4
|
+
import { a as harvestFewShotExamples, i as formatDemos, n as Demo, o as parseDemos, r as DemoRenderer, t as BootstrapResult } from "./demos-ASsSXYXA.mjs";
|
|
5
|
+
import { a as EvaluateBatchArgs, c as Evaluator, d as costExhausted, f as createEvaluator, g as createBudget, h as Budget, i as BudgetExhausted, l as RetryPolicy, m as requireMeasuredMean, n as OptimizerResult, o as EvaluateTracedArgs, p as measuredMean, r as OptimizerTask, s as EvaluationEvent, t as Optimizer, u as ScoredBatch } from "./optimizer-Ds5mzYjz.mjs";
|
|
6
6
|
import { t as BatchSampler } from "./sampling-DFo_7RNJ.mjs";
|
|
7
7
|
//#region src/checkpoint.d.ts
|
|
8
8
|
/**
|
|
@@ -252,7 +252,7 @@ interface TrainingExample {
|
|
|
252
252
|
* candidate to leave in the input. Dropping it entirely moves the whole prompt
|
|
253
253
|
* into weights and gives up the ability to steer the model with text
|
|
254
254
|
* afterwards; keeping a short task statement distills away only the tokens the
|
|
255
|
-
* search accreted. See `docs/distillation.md
|
|
255
|
+
* search accreted. See `docs/distillation.md` in this package.
|
|
256
256
|
*/
|
|
257
257
|
type TrainingExampleRenderer<Datum, Output> = (args: {
|
|
258
258
|
rollout: Rollout<Datum, Output>;
|
|
@@ -279,6 +279,38 @@ declare function toTrainingJsonl<Datum, Output>(args: {
|
|
|
279
279
|
interface JudgeCriterion {
|
|
280
280
|
name: string;
|
|
281
281
|
description: string;
|
|
282
|
+
/**
|
|
283
|
+
* Share of the instance score this criterion carries, relative to the other
|
|
284
|
+
* criteria. Default 1, which is the unweighted mean.
|
|
285
|
+
*
|
|
286
|
+
* 0 removes a criterion from the aggregate, not from the search. It is still
|
|
287
|
+
* graded and still recorded in `objectiveScores`, which
|
|
288
|
+
* `paretoSelector({ frontier: "objective" })` and `"hybrid"` build their
|
|
289
|
+
* selection fronts from — so a candidate leading a zero-weight criterion
|
|
290
|
+
* still earns parent selection under those. Under the default instance
|
|
291
|
+
* frontier, 0 is enough. For a number that can never steer the search,
|
|
292
|
+
* compute it outside the judge.
|
|
293
|
+
*/
|
|
294
|
+
weight?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Grade, on the judge's own scale, that this criterion must reach for the
|
|
297
|
+
* instance to score at all. Below it the instance scores 0 whatever the
|
|
298
|
+
* other criteria said.
|
|
299
|
+
*
|
|
300
|
+
* A mean lets a search trade a hard requirement away: a candidate that tanks
|
|
301
|
+
* one non-negotiable criterion and aces three cosmetic ones outranks the
|
|
302
|
+
* incumbent that kept the rule. Anything a caller would not ship without is
|
|
303
|
+
* a gate rather than a term in the average.
|
|
304
|
+
*
|
|
305
|
+
* Enforce it once. A gate already makes the requirement non-negotiable, so a
|
|
306
|
+
* heavy `weight` on the same criterion redistributes score only among
|
|
307
|
+
* candidates that all cleared it — and pins that share of the aggregate near
|
|
308
|
+
* its ceiling, narrowing the range the search has left to move in. Gate it,
|
|
309
|
+
* then weight it low.
|
|
310
|
+
*
|
|
311
|
+
* @see docs/metric-preflight.md
|
|
312
|
+
*/
|
|
313
|
+
gate?: number;
|
|
282
314
|
}
|
|
283
315
|
type JudgePromptBuilder = (args: {
|
|
284
316
|
input: string;
|
|
@@ -356,4 +388,4 @@ declare function priceUsage(args: {
|
|
|
356
388
|
pricing?: TokenPricing;
|
|
357
389
|
}): RolloutUsage;
|
|
358
390
|
//#endregion
|
|
359
|
-
export { type Adapter, type BatchSampler, type BootstrapResult, type Budget, BudgetExhausted, type CachedScore, type Candidate, type CandidateAccepted, type ChatMessage, type Comparison, type ComparisonRun, type ComparisonSummary, type Deadline, type Demo, type DemoRenderer, type EvaluateArgs, type EvaluateBatchArgs, type EvaluateTracedArgs, type EvaluationBatch, type EvaluationCache, type EvaluationContext, type EvaluationEvent, type EvaluationPhase, type EvaluationSplit, type Evaluator, type HarvestResult, type Judge, type JudgeCriterion, type JudgePromptBuilder, type Optimizer, type OptimizerEvent, type OptimizerResult, type OptimizerTask, type ReportableEvent, type Reporter, type RetryPolicy, type Rng, type Rollout, type RolloutUsage, type RunFinished, type ScoreResult, type ScoredBatch, type TextModel, type TokenPricing, type TrainingExample, type TrainingExampleRenderer, type UsageTotals, assertResumable, buildJudgePrompt, candidateFingerprint, compare, componentNames, costExhausted, createBudget, createDeadline, createEvaluator, createJudge, createMemoryCache, formatDemos, harvestFewShotExamples, harvestRollouts, isCandidateAccepted, isRunFinished, mapWithConcurrency, measuredMean, parseDemos, parseProposedText, priceUsage, requireMeasuredMean, runFingerprint, toTrainingJsonl };
|
|
391
|
+
export { type Adapter, type BatchSampler, type BootstrapResult, type Budget, BudgetExhausted, type CachedScore, type Candidate, type CandidateAccepted, type ChatMessage, type Comparison, type ComparisonRun, type ComparisonSummary, type Deadline, type Demo, type DemoRenderer, type EvaluateArgs, type EvaluateBatchArgs, type EvaluateTracedArgs, type EvaluationBatch, type EvaluationCache, type EvaluationContext, type EvaluationEvent, type EvaluationPhase, type EvaluationSplit, type Evaluator, type HarvestResult, type Judge, type JudgeCriterion, type JudgePromptBuilder, type Optimizer, type OptimizerEvent, type OptimizerResult, type OptimizerTask, type ReportableEvent, type Reporter, type RetryPolicy, type Rng, type Rollout, type RolloutUsage, type RunFinished, type RunWarning, type RunWarningCode, type ScoreResult, type ScoredBatch, type TextModel, type TokenPricing, type TrainingExample, type TrainingExampleRenderer, type UsageTotals, assertResumable, buildJudgePrompt, candidateFingerprint, compare, componentNames, costExhausted, createBudget, createDeadline, createEvaluator, createJudge, createMemoryCache, formatDemos, harvestFewShotExamples, harvestRollouts, isCandidateAccepted, isRunFinished, mapWithConcurrency, measuredMean, parseDemos, parseProposedText, priceUsage, requireMeasuredMean, resolveValidationSet, runFingerprint, seedScoreWarnings, toTrainingJsonl };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as createBudget, _ as componentNames, c as BudgetExhausted, d as measuredMean, f as requireMeasuredMean, g as runFingerprint, h as candidateFingerprint, l as costExhausted, m as assertResumable, n as seedScoreWarnings, o as isCandidateAccepted, p as createDeadline, s as isRunFinished, t as resolveValidationSet, u as createEvaluator, y as createMemoryCache } from "./warnings-OxvDi9kN.mjs";
|
|
2
2
|
import { t as mapWithConcurrency } from "./concurrency-D58PWeSk.mjs";
|
|
3
3
|
import { i as signFlipPValue, n as holmAdjust } from "./math-Dqme4rYz.mjs";
|
|
4
|
-
import { a as harvestRollouts, n as harvestFewShotExamples, r as parseDemos, t as formatDemos } from "./demos-
|
|
4
|
+
import { a as harvestRollouts, n as harvestFewShotExamples, r as parseDemos, t as formatDemos } from "./demos-Brobjfuc.mjs";
|
|
5
5
|
import { t as parseProposedText } from "./text--v4Ffbus.mjs";
|
|
6
6
|
//#region src/compare.ts
|
|
7
7
|
const EXACT_LIMIT = 20;
|
|
@@ -238,6 +238,10 @@ function createJudge(args) {
|
|
|
238
238
|
const { model, criteria, scale = DEFAULT_SCALE, renderInput = stringify, renderOutput = stringify, buildPrompt = buildJudgePrompt } = args;
|
|
239
239
|
if (criteria.length === 0) throw new Error("createJudge requires at least one criterion");
|
|
240
240
|
if (!Number.isFinite(scale) || scale <= 0) throw new Error(`scale must be a positive number, received ${scale}`);
|
|
241
|
+
assertCriteria({
|
|
242
|
+
criteria,
|
|
243
|
+
scale
|
|
244
|
+
});
|
|
241
245
|
return async ({ input, output, expected, signal }) => {
|
|
242
246
|
return readVerdict({
|
|
243
247
|
response: await model({
|
|
@@ -281,6 +285,7 @@ function buildJudgePrompt(args) {
|
|
|
281
285
|
`Grade each criterion from 0 to ${scale}, where ${scale} is a perfect answer.`,
|
|
282
286
|
"",
|
|
283
287
|
"Then write feedback. It is read by a program that rewrites the system's instructions, not by a person reviewing this output, so say what the instructions should tell the system to do differently. Feedback about this particular answer is of no use to it.",
|
|
288
|
+
...expected === void 0 ? [] : ["", "Do not restate the expected answer, or any fact drawn from it, in the feedback. The instruction it is rewritten into is reused on inputs whose answers you have not seen: a fact copied out of the expected answer becomes an answer key memorised in the prompt, which raises the score on this input and teaches the system nothing. Name the kind of thing the answer was missing, not the thing itself."],
|
|
284
289
|
"",
|
|
285
290
|
"Reply in exactly this format and nothing else:",
|
|
286
291
|
...criteria.map((criterion) => `<score name="${criterion.name}">…</score>`),
|
|
@@ -299,6 +304,9 @@ function readVerdict(args) {
|
|
|
299
304
|
const graded = /* @__PURE__ */ new Map();
|
|
300
305
|
for (const match of response.matchAll(SCORE)) graded.set(match[1], Number(match[2]));
|
|
301
306
|
const objectiveScores = {};
|
|
307
|
+
let gated = false;
|
|
308
|
+
let weighted = 0;
|
|
309
|
+
let totalWeight = 0;
|
|
302
310
|
for (const criterion of criteria) {
|
|
303
311
|
const grade = graded.get(criterion.name);
|
|
304
312
|
if (grade === void 0 || Number.isNaN(grade)) return {
|
|
@@ -306,15 +314,30 @@ function readVerdict(args) {
|
|
|
306
314
|
feedback: `Judge did not grade "${criterion.name}".`,
|
|
307
315
|
transient: true
|
|
308
316
|
};
|
|
309
|
-
|
|
317
|
+
const normalized = clamp(grade / scale);
|
|
318
|
+
objectiveScores[criterion.name] = normalized;
|
|
319
|
+
if (criterion.gate !== void 0 && grade < criterion.gate) gated = true;
|
|
320
|
+
const weight = criterion.weight ?? 1;
|
|
321
|
+
weighted += normalized * weight;
|
|
322
|
+
totalWeight += weight;
|
|
310
323
|
}
|
|
311
|
-
const grades = Object.values(objectiveScores);
|
|
312
324
|
return {
|
|
313
|
-
score:
|
|
325
|
+
score: gated ? 0 : weighted / totalWeight,
|
|
314
326
|
feedback,
|
|
315
327
|
objectiveScores
|
|
316
328
|
};
|
|
317
329
|
}
|
|
330
|
+
function assertCriteria(args) {
|
|
331
|
+
const { criteria, scale } = args;
|
|
332
|
+
let totalWeight = 0;
|
|
333
|
+
for (const { name, weight = 1, gate } of criteria) {
|
|
334
|
+
if (!Number.isFinite(weight) || weight < 0) throw new Error(`weight on criterion "${name}" must be a non-negative number, received ${weight}`);
|
|
335
|
+
totalWeight += weight;
|
|
336
|
+
if (gate !== void 0 && (!Number.isFinite(gate) || gate <= 0)) throw new Error(`gate on criterion "${name}" must be greater than 0, received ${gate}; no grade can fall below 0`);
|
|
337
|
+
if (gate !== void 0 && gate > scale) throw new Error(`gate on criterion "${name}" is ${gate}, above the scale of ${scale}; no grade can reach it`);
|
|
338
|
+
}
|
|
339
|
+
if (totalWeight <= 0) throw new Error("criteria weights must sum to more than 0; at least one criterion has to count towards the score");
|
|
340
|
+
}
|
|
318
341
|
function stringify(value) {
|
|
319
342
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
320
343
|
}
|
|
@@ -340,4 +363,4 @@ function priceUsage(args) {
|
|
|
340
363
|
};
|
|
341
364
|
}
|
|
342
365
|
//#endregion
|
|
343
|
-
export { BudgetExhausted, assertResumable, buildJudgePrompt, candidateFingerprint, compare, componentNames, costExhausted, createBudget, createDeadline, createEvaluator, createJudge, createMemoryCache, formatDemos, harvestFewShotExamples, harvestRollouts, isCandidateAccepted, isRunFinished, mapWithConcurrency, measuredMean, parseDemos, parseProposedText, priceUsage, requireMeasuredMean, runFingerprint, toTrainingJsonl };
|
|
366
|
+
export { BudgetExhausted, assertResumable, buildJudgePrompt, candidateFingerprint, compare, componentNames, costExhausted, createBudget, createDeadline, createEvaluator, createJudge, createMemoryCache, formatDemos, harvestFewShotExamples, harvestRollouts, isCandidateAccepted, isRunFinished, mapWithConcurrency, measuredMean, parseDemos, parseProposedText, priceUsage, requireMeasuredMean, resolveValidationSet, runFingerprint, seedScoreWarnings, toTrainingJsonl };
|
package/dist/mipro/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_warnings = require("../warnings-CWRJF-jA.cjs");
|
|
3
3
|
const require_concurrency = require("../concurrency-C-cFzWW2.cjs");
|
|
4
4
|
const require_math = require("../math-BhlziRPc.cjs");
|
|
5
|
-
const require_demos = require("../demos-
|
|
5
|
+
const require_demos = require("../demos-9v5ts7F3.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");
|
|
@@ -218,7 +218,7 @@ var MiproOptimizer = class {
|
|
|
218
218
|
task
|
|
219
219
|
});
|
|
220
220
|
} finally {
|
|
221
|
-
await
|
|
221
|
+
await require_warnings.flushReporters(task.reporters ?? []);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
};
|
|
@@ -278,10 +278,14 @@ function buildDatasetSummaryPrompt(examples) {
|
|
|
278
278
|
async function runMipro(args) {
|
|
279
279
|
const { config, task } = args;
|
|
280
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;
|
|
281
|
-
const { seedCandidate, trainingSet, validationSet
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
const { seedCandidate, trainingSet, validationSet: requestedValidationSet, testSet, adapter, reflect, componentOptions, demoComponents, renderDemo, goldOutput, maxMetricCalls, renderDatum = renderDefault, batchSampler = require_sampling.createEpochShuffledSampler({ minibatchSize }), cache, cacheNamespace, retry, maxCostUsd, maxWallClockMs, instanceId = require_warnings.defaultInstanceId, reporters = [], onCheckpoint, resumeFrom, signal } = task;
|
|
282
|
+
const { validationSet, warnings } = require_warnings.resolveValidationSet({
|
|
283
|
+
validationSet: requestedValidationSet,
|
|
284
|
+
trainingSet
|
|
285
|
+
});
|
|
286
|
+
const emit = require_warnings.createEmitter(reporters);
|
|
287
|
+
const deadline = require_warnings.createDeadline({ maxWallClockMs });
|
|
288
|
+
const components = require_warnings.componentNames(seedCandidate);
|
|
285
289
|
if (trainingSet.length === 0) throw new Error("optimize requires a non-empty trainingSet");
|
|
286
290
|
if (validationSet.length === 0) throw new Error("optimize requires a non-empty validationSet");
|
|
287
291
|
if (components.length === 0) throw new Error("optimize requires a seed candidate with at least one component");
|
|
@@ -299,24 +303,24 @@ async function runMipro(args) {
|
|
|
299
303
|
datum,
|
|
300
304
|
index
|
|
301
305
|
})) ?? [];
|
|
302
|
-
const fingerprint =
|
|
306
|
+
const fingerprint = require_warnings.runFingerprint({
|
|
303
307
|
seedCandidate,
|
|
304
308
|
trainingIds,
|
|
305
309
|
validationIds,
|
|
306
310
|
seed,
|
|
307
311
|
...cacheNamespace === void 0 ? {} : { cacheNamespace }
|
|
308
312
|
});
|
|
309
|
-
|
|
313
|
+
require_warnings.assertResumable({
|
|
310
314
|
fingerprint,
|
|
311
315
|
...resumeFrom === void 0 ? {} : { snapshot: resumeFrom }
|
|
312
316
|
});
|
|
313
317
|
const rng = require_rng.createSeededRng(seed, resumeFrom?.rngState);
|
|
314
|
-
const budget =
|
|
318
|
+
const budget = require_warnings.createBudget({
|
|
315
319
|
maxMetricCalls,
|
|
316
320
|
spent: resumeFrom?.metricCalls ?? 0
|
|
317
321
|
});
|
|
318
|
-
const evaluationCache = cache === false ? void 0 : cache ??
|
|
319
|
-
const evaluator =
|
|
322
|
+
const evaluationCache = cache === false ? void 0 : cache ?? require_warnings.createMemoryCache();
|
|
323
|
+
const evaluator = require_warnings.createEvaluator({
|
|
320
324
|
adapter,
|
|
321
325
|
budget,
|
|
322
326
|
...retry === void 0 ? {} : { retry },
|
|
@@ -380,7 +384,7 @@ async function runMipro(args) {
|
|
|
380
384
|
for (let index = 0; index < demoSets; index += 1) {
|
|
381
385
|
const affordable = Math.min(trainingSet.length, budget.remaining() - validationSet.length);
|
|
382
386
|
if (affordable < 1) break;
|
|
383
|
-
if (
|
|
387
|
+
if (require_warnings.costExhausted({
|
|
384
388
|
usage: evaluator.usage(),
|
|
385
389
|
maxCostUsd
|
|
386
390
|
})) break;
|
|
@@ -474,7 +478,7 @@ async function runMipro(args) {
|
|
|
474
478
|
});
|
|
475
479
|
}
|
|
476
480
|
const seedEvaluation = resumeFrom === void 0 ? await fullSweep(seedCandidate, "seed") : void 0;
|
|
477
|
-
const seedScore = seedEvaluation === void 0 ? resumeFrom.seedScore :
|
|
481
|
+
const seedScore = seedEvaluation === void 0 ? resumeFrom.seedScore : require_warnings.requireMeasuredMean({
|
|
478
482
|
batch: seedEvaluation,
|
|
479
483
|
phase: "seed"
|
|
480
484
|
});
|
|
@@ -485,7 +489,7 @@ async function runMipro(args) {
|
|
|
485
489
|
candidateId: 0,
|
|
486
490
|
candidate: seedCandidate,
|
|
487
491
|
aggregateScore: seedScore,
|
|
488
|
-
instanceScores:
|
|
492
|
+
instanceScores: require_warnings.instanceRow(seedEvaluation),
|
|
489
493
|
...trackBestOutputs ? { outputs: seedEvaluation.outputs } : {}
|
|
490
494
|
});
|
|
491
495
|
if (resumeFrom === void 0) surrogateInput.push({
|
|
@@ -559,12 +563,12 @@ async function runMipro(args) {
|
|
|
559
563
|
try {
|
|
560
564
|
evaluation = await fullSweep(candidate, "validation");
|
|
561
565
|
} catch (err) {
|
|
562
|
-
if (err instanceof
|
|
566
|
+
if (err instanceof require_warnings.BudgetExhausted) return "budgetExhausted";
|
|
563
567
|
if (signal?.aborted) return "aborted";
|
|
564
568
|
throw err;
|
|
565
569
|
}
|
|
566
570
|
fullEvaluations += 1;
|
|
567
|
-
const score =
|
|
571
|
+
const score = require_warnings.measuredMean(evaluation);
|
|
568
572
|
if (score === void 0) return "swept";
|
|
569
573
|
surrogateInput.push({
|
|
570
574
|
choices,
|
|
@@ -585,7 +589,7 @@ async function runMipro(args) {
|
|
|
585
589
|
candidateId: acceptedCandidates,
|
|
586
590
|
candidate,
|
|
587
591
|
aggregateScore: score,
|
|
588
|
-
instanceScores:
|
|
592
|
+
instanceScores: require_warnings.instanceRow(evaluation),
|
|
589
593
|
...trackBestOutputs ? { outputs: evaluation.outputs } : {}
|
|
590
594
|
});
|
|
591
595
|
}
|
|
@@ -596,7 +600,7 @@ async function runMipro(args) {
|
|
|
596
600
|
stopReason = "aborted";
|
|
597
601
|
break;
|
|
598
602
|
}
|
|
599
|
-
if (
|
|
603
|
+
if (require_warnings.costExhausted({
|
|
600
604
|
usage: evaluator.usage(),
|
|
601
605
|
maxCostUsd
|
|
602
606
|
})) {
|
|
@@ -641,9 +645,9 @@ async function runMipro(args) {
|
|
|
641
645
|
candidateId: null,
|
|
642
646
|
iteration: trial
|
|
643
647
|
});
|
|
644
|
-
minibatchScore =
|
|
648
|
+
minibatchScore = require_warnings.measuredMean(evaluation);
|
|
645
649
|
} catch (err) {
|
|
646
|
-
if (err instanceof
|
|
650
|
+
if (err instanceof require_warnings.BudgetExhausted) {
|
|
647
651
|
stopReason = "budgetExhausted";
|
|
648
652
|
break;
|
|
649
653
|
}
|
|
@@ -700,15 +704,16 @@ async function runMipro(args) {
|
|
|
700
704
|
iteration: trial,
|
|
701
705
|
charge: false
|
|
702
706
|
});
|
|
703
|
-
const testScore = heldOut === void 0 ? void 0 :
|
|
707
|
+
const testScore = heldOut === void 0 ? void 0 : require_warnings.measuredMean(heldOut);
|
|
704
708
|
emit({
|
|
705
709
|
type: "finish",
|
|
706
710
|
reason: stopReason,
|
|
711
|
+
warnings,
|
|
707
712
|
bestCandidateId: acceptedCandidates,
|
|
708
713
|
bestScore,
|
|
709
714
|
metricCalls: budget.spent(),
|
|
710
715
|
...testScore === void 0 ? {} : { testScore },
|
|
711
|
-
...heldOut === void 0 ? {} : { testInstanceScores:
|
|
716
|
+
...heldOut === void 0 ? {} : { testInstanceScores: require_warnings.instanceRow(heldOut) },
|
|
712
717
|
...heldOut === void 0 || !trackBestOutputs ? {} : { testOutputs: heldOut.outputs }
|
|
713
718
|
});
|
|
714
719
|
return {
|
|
@@ -731,6 +736,7 @@ async function runMipro(args) {
|
|
|
731
736
|
metricCalls: budget.spent(),
|
|
732
737
|
reflectionCalls,
|
|
733
738
|
cacheHits: evaluator.cacheHits(),
|
|
739
|
+
warnings,
|
|
734
740
|
stopReason
|
|
735
741
|
};
|
|
736
742
|
}
|
|
@@ -762,6 +768,6 @@ function assertConfig(config) {
|
|
|
762
768
|
//#endregion
|
|
763
769
|
exports.MiproOptimizer = MiproOptimizer;
|
|
764
770
|
exports.buildMiproPrompt = buildMiproPrompt;
|
|
765
|
-
exports.isCandidateAccepted =
|
|
766
|
-
exports.isRunFinished =
|
|
771
|
+
exports.isCandidateAccepted = require_warnings.isCandidateAccepted;
|
|
772
|
+
exports.isRunFinished = require_warnings.isRunFinished;
|
|
767
773
|
exports.proposeConfiguration = proposeConfiguration;
|
package/dist/mipro/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as UsageTotals, a as RunFinished, f as Adapter, i as Reporter, n as OptimizerEvent, o as isCandidateAccepted, p as Candidate, r as ReportableEvent, s as isRunFinished, t as CandidateAccepted, x as TextModel } from "../reporting-bq007_2z.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-ByaLZy-Z.cjs";
|
|
5
|
+
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-4Zv-Zt2t.cjs";
|
|
6
6
|
import { t as BatchSampler } from "../sampling-axOwfZf5.cjs";
|
|
7
7
|
//#region src/mipro/optimize.d.ts
|
|
8
8
|
type MiproPromptBuilder = (args: {
|
package/dist/mipro/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as UsageTotals, a as RunFinished, f as Adapter, i as Reporter, n as OptimizerEvent, o as isCandidateAccepted, p as Candidate, r as ReportableEvent, s as isRunFinished, t as CandidateAccepted, x as TextModel } from "../reporting-bq007_2z.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-ASsSXYXA.mjs";
|
|
5
|
+
import { n as OptimizerResult, r as OptimizerTask, s as EvaluationEvent, t as Optimizer } from "../optimizer-Ds5mzYjz.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: {
|
package/dist/mipro/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { S as createBudget, _ as componentNames, a as instanceRow, b as defaultInstanceId, c as BudgetExhausted, d as measuredMean, f as requireMeasuredMean, g as runFingerprint, i as flushReporters, l as costExhausted, m as assertResumable, o as isCandidateAccepted, p as createDeadline, r as createEmitter, s as isRunFinished, t as resolveValidationSet, u as createEvaluator, y as createMemoryCache } from "../warnings-OxvDi9kN.mjs";
|
|
2
2
|
import { t as mapWithConcurrency } from "../concurrency-D58PWeSk.mjs";
|
|
3
3
|
import { r as mean } from "../math-Dqme4rYz.mjs";
|
|
4
|
-
import { n as harvestFewShotExamples, t as formatDemos } from "../demos-
|
|
4
|
+
import { n as harvestFewShotExamples, t as formatDemos } from "../demos-Brobjfuc.mjs";
|
|
5
5
|
import { t as parseProposedText } from "../text--v4Ffbus.mjs";
|
|
6
6
|
import { t as createSeededRng } from "../rng-Dtc5eZ_W.mjs";
|
|
7
7
|
import { t as createEpochShuffledSampler } from "../sampling-CfHt7Gue.mjs";
|
|
@@ -277,7 +277,11 @@ function buildDatasetSummaryPrompt(examples) {
|
|
|
277
277
|
async function runMipro(args) {
|
|
278
278
|
const { config, task } = args;
|
|
279
279
|
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;
|
|
280
|
-
const { seedCandidate, trainingSet, validationSet
|
|
280
|
+
const { seedCandidate, trainingSet, validationSet: requestedValidationSet, testSet, adapter, reflect, componentOptions, demoComponents, renderDemo, goldOutput, maxMetricCalls, renderDatum = renderDefault, batchSampler = createEpochShuffledSampler({ minibatchSize }), cache, cacheNamespace, retry, maxCostUsd, maxWallClockMs, instanceId = defaultInstanceId, reporters = [], onCheckpoint, resumeFrom, signal } = task;
|
|
281
|
+
const { validationSet, warnings } = resolveValidationSet({
|
|
282
|
+
validationSet: requestedValidationSet,
|
|
283
|
+
trainingSet
|
|
284
|
+
});
|
|
281
285
|
const emit = createEmitter(reporters);
|
|
282
286
|
const deadline = createDeadline({ maxWallClockMs });
|
|
283
287
|
const components = componentNames(seedCandidate);
|
|
@@ -703,6 +707,7 @@ async function runMipro(args) {
|
|
|
703
707
|
emit({
|
|
704
708
|
type: "finish",
|
|
705
709
|
reason: stopReason,
|
|
710
|
+
warnings,
|
|
706
711
|
bestCandidateId: acceptedCandidates,
|
|
707
712
|
bestScore,
|
|
708
713
|
metricCalls: budget.spent(),
|
|
@@ -730,6 +735,7 @@ async function runMipro(args) {
|
|
|
730
735
|
metricCalls: budget.spent(),
|
|
731
736
|
reflectionCalls,
|
|
732
737
|
cacheHits: evaluator.cacheHits(),
|
|
738
|
+
warnings,
|
|
733
739
|
stopReason
|
|
734
740
|
};
|
|
735
741
|
}
|