UNPKG

axiom

Version:

Axiom AI SDK provides - an API to wrap your AI calls with observability instrumentation. - offline evals - online evals

42 lines (41 loc) 1.09 kB
// src/scorers/aggregations.ts var Mean = () => ({ type: "mean", aggregate: (scores) => scores.length === 0 ? 0 : scores.reduce((a, b) => a + b, 0) / scores.length }); var Median = () => ({ type: "median", aggregate: (scores) => { if (scores.length === 0) return 0; const sorted = [...scores].sort((a, b) => a - b); const mid = Math.floor(sorted.length / 2); return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2; } }); var PassAtK = (opts = {}) => { const threshold = opts.threshold ?? 1; return { type: "pass@k", threshold, aggregate: (scores) => scores.some((s) => s >= threshold) ? 1 : 0 }; }; var PassHatK = (opts = {}) => { const threshold = opts.threshold ?? 1; return { type: "pass^k", threshold, aggregate: (scores) => scores.length === 0 ? 0 : scores.every((s) => s >= threshold) ? 1 : 0 }; }; var AtLeastOneTrialPasses = PassAtK; var AllTrialsPass = PassHatK; export { Mean, Median, PassAtK, PassHatK, AtLeastOneTrialPasses, AllTrialsPass }; //# sourceMappingURL=chunk-73F2PMAH.js.map